IL2041: 'DynamicallyAccessedMembersAttribute' is not allowed on methods

Cause

DynamicallyAccessedMembersAttribute was put directly on a method. This is only allowed for instance methods on Type. This attribute should usually be placed on the return value of the method or one of the parameters.

Example

// IL2041: The 'DynamicallyAccessedMembersAttribute' is not allowed on methods. It is allowed on method return value or method parameters though.
[DynamicallyAccessedMembers(DynamicallyAccessedMemberType.PublicMethods)]

[return: DynamicallyAccessedMembers(DynamicallyAccessedMemberType.PublicMethods)]
public Type GetInterestingType()
{
}