using System.Diagnostics.CodeAnalysis;
// warning IL2062: Value passed to parameter 's' of method 'G(String)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements.
G(typeof(C).AssemblyQualifiedName);
static void G([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string s) {
Activator.CreateInstance(Type.GetType(s));
}
class C {}
This produces a warning because the dataflow analysis treats the result of typeof(C).AssemblyQualifiedName) as unknown. Instead it should track the result as a known type name and not produce any warnings (note that G("C, assemblyname") works and does not warn).
This produces a warning because the dataflow analysis treats the result of
typeof(C).AssemblyQualifiedName)
as unknown. Instead it should track the result as a known type name and not produce any warnings (note thatG("C, assemblyname")
works and does not warn).