-
Notifications
You must be signed in to change notification settings - Fork 128
Closed
dotnet/runtime
#104760Description
There is already a defined behavior for the interaction between RequiresUnreferencedCode and DynamicallyAccessedMembers. For example, there is the following doc that explains the interaction between DAM and RUC on a type.
This PR is to discuss what should be the behavior in the case we access members annotated with RequiresAssemblyFiles or RequiresDynamicCode via reflection/DAM.
Currently:
- Both attributes don't warn when accessed via reflection nor the marking made via DynamicallyAccessedMembers.
- Code in runtime for NativeAOT will only warn on reflection access if the member is annotated with RequiresUnreferencedCode
The question becomes what should happen with the following:
[RequiresAssemblyFiles ("RAF")]
[RequiresDynamicCode ("RDC")]
class DangerousClass
{
public static void DangerousMethod () { }
}
static void TestDAMAccess ()
{
typeof (DangerousClass).RequiresPublicMethods ();
}
public static void RequiresPublicMethods ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] this Type type) { }Currently, we will mark the members and threat DAM as reflection access but not generate any warnings about it. Eventually, if the method ends up being called we will get runtime errors without any previous warning.
Metadata
Metadata
Assignees
Type
Projects
Status
No status