Description
In some instances, the NativeAOT compiler won't produce a warning when accessing methods annotated with Requires when accessed via reflection. See reproduction steps
Reproduction Steps
// Missing warning being generated// [ExpectedWarning ("IL2026", "--RequiresOnlyThroughReflection--")]publicstaticvoidMain(){typeof(RequiresAccessedThrough).GetMethod("RequiresOnlyThroughReflection",System.Reflection.BindingFlags.Static|System.Reflection.BindingFlags.NonPublic).Invoke(null,newobject[0]);}classRequiresAccessedThrough{[RequiresUnreferencedCode("Message for --RequiresOnlyThroughReflection--")]staticvoidRequiresOnlyThroughReflection(){}}Expected behavior
A warning should be generated when trying to access the method via reflection
Actual behavior
A warning is not generated
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Description
In some instances, the NativeAOT compiler won't produce a warning when accessing methods annotated with Requires when accessed via reflection. See reproduction steps
Reproduction Steps
Expected behavior
A warning should be generated when trying to access the method via reflection
Actual behavior
A warning is not generated
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response