IL2057: Unrecognized value passed to the typeName parameter of 'System.Type.GetType(String)'

Cause

An unrecognized value was passed to the typeName parameter of Type.GetType(String).

Rule description

If the type name passed to the typeName parameter of GetType(String) is statically known, the trimmer can make sure it is preserved and that the application code will continue to work after trimming. If the type is unknown and the trimmer cannot see the type being used anywhere else, the trimmer might end up removing it from the application, potentially breaking it.

Example

void TestMethod()
{
    string typeName = ReadName();

    // IL2057 Trim analysis: Unrecognized value passed to the parameter 'typeName' of method 'System.Type.GetType(String typeName)'
    Type.GetType(typeName);
}