Open
Description
void GenericMethod<[DynamicallyAccessedMembers(PublicMethods)] T>() {}
void Test(Type type)
{
// IL2070: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to
// MakeGenericMethod'. The parameter 'type' of method 'Test' does not have matching annotations. The source value must
// declare at least the same requirements as those declared on the target location it is assigned to.
typeof(TestType).GetMethod("GenericMethod").MakeGenericMethod(type);
}
The problem is that we pass the MethodDefinition
as the "target" of the annotation match in AnalyzeGenericInstantiationTypeArray
. We should pass the generic parameter instead.
This will hit a TODO here:
https://github.com/mono/linker/blob/e1c0c83d24d619ba37cdfc8bd7f8c8ebaf9f309b/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs#L2104
These should be removed and tests validated for these (we should already have tests covering the scenarios, we just need to update them to the new warning code).
This needs to be fixed in 6 as it changes the warning code reported.
Metadata
Metadata
Assignees
Labels
No labels