IL2055: Call to 'System.Type.MakeGenericType' cannot be statically analyzed by the trimmer
Cause
A call to Type.MakeGenericType(Type[]) cannot be statically analyzed by the trimmer.
Rule description
This can either be that the type on which MakeGenericType(Type[]) is called cannot be statically determined, or that the type parameters to be used for generic arguments cannot be statically determined. If the open generic type has DynamicallyAccessedMembersAttribute annotations on any of its generic parameters, the trimmer currently cannot validate that the requirements are fulfilled by the calling method.
Example
class Lazy<[DynamicallyAccessedMembers(DynamicallyAccessedMemberType.PublicParameterlessConstructor)] T>
{
// ...
}
void TestMethod(Type unknownType)
{
// IL2055 Trim analysis: Call to `System.Type.MakeGenericType(Type[])` can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic type.
typeof(Lazy<>).MakeGenericType(new Type[] { typeof(TestType) });
// IL2055 Trim analysis: Call to `System.Type.MakeGenericType(Type[])` can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic type.
unknownType.MakeGenericType(new Type[] { typeof(TestType) });
}
الملاحظات
إرسال الملاحظات وعرضها المتعلقة بـ