In System.ComponentModel.TypeConverter, there are a few instances where it will call Type.GetType(string), and then use the Type to pass into other methods.
An example is the ProvidePropertyAttribute - https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.providepropertyattribute
This attribute can take a string receiverTypeName parameter in its constructor. In order to support this, we need to mark that parameter as DynamicallyAccessedMembers so the linker will see that the Type is being used and not trim the Type. However, in order to use DynamicallyAccessedMembers, we need to specify a DynamicallyAccessedMemberTypes enum. Putting DynamicallyAccessedMemberTypes.None should mark the Type as being preserved, but not mark any of its members.
This also applies to the EditorAttribute's string? baseTypeName parameter. The code calls Type.GetType using this string, but doesn't reflect on anything else on the Type. The Type needs to be preserved, but not necessarily any of its members.
For now I've been using DynamicallyAccessedMemberTypes.PublicParameterlessConstructor to preserve these Types.
cc @vitek-karas @MichalStrehovsky @marek-safar
In
System.ComponentModel.TypeConverter, there are a few instances where it will callType.GetType(string), and then use the Type to pass into other methods.An example is the
ProvidePropertyAttribute- https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.providepropertyattributeThis attribute can take a
string receiverTypeNameparameter in its constructor. In order to support this, we need to mark that parameter asDynamicallyAccessedMembersso the linker will see that the Type is being used and not trim the Type. However, in order to useDynamicallyAccessedMembers, we need to specify aDynamicallyAccessedMemberTypesenum. PuttingDynamicallyAccessedMemberTypes.Noneshould mark the Type as being preserved, but not mark any of its members.This also applies to the
EditorAttribute'sstring? baseTypeNameparameter. The code callsType.GetTypeusing this string, but doesn't reflect on anything else on the Type. The Type needs to be preserved, but not necessarily any of its members.For now I've been using
DynamicallyAccessedMemberTypes.PublicParameterlessConstructorto preserve these Types.cc @vitek-karas @MichalStrehovsky @marek-safar