You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The RequiresAttributeMismatch test uses DynamicallyAccessedMembersAttribute to mark as Required the methods on several classes by using a helper function called RequiresPublicMethods()
The classes are divided into Base/Derived classes and Virtual/Override classes, the attribute values inside these classes must match otherwise we should generate a warning stating that Base/Derive or Virtual/Override don't match.
Although NativeAOT warns about the usage of the methods being accessed by DAM, the attribute mismatch warnings are not existent.
Code that handles the attribute mismatch is in:
//These warnings for access are correctly generated[ExpectedWarning("IL2026","BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get")][ExpectedWarning("IL2026","BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get")][ExpectedWarning("IL2026","BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get")][ExpectedWarning("IL2026","BaseClassWithRequires.VirtualMethod()")][ExpectedWarning("IL2026","BaseClassWithRequires.VirtualMethod()")][ExpectedWarning("IL2026","BaseClassWithRequires.VirtualMethod()")][ExpectedWarning("IL2026","BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get")][ExpectedWarning("IL2026","BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get")][ExpectedWarning("IL2026","BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get")]publicstaticvoidMain(){typeof(BaseClassWithRequires).RequiresPublicMethods();typeof(DerivedClassWithoutRequires).RequiresPublicMethods();}classBaseClassWithRequires{[RequiresUnreferencedCode("Message")][RequiresAssemblyFiles("Message")][RequiresDynamicCode("Message")]publicvirtualvoidVirtualMethod(){}publicvirtualstringVirtualPropertyAnnotationInAccesor{[RequiresUnreferencedCode("Message")][RequiresAssemblyFiles("Message")][RequiresDynamicCode("Message")]get;set;}[RequiresAssemblyFiles("Message")]publicvirtualstringVirtualPropertyAnnotationInProperty{get;set;}[RequiresAssemblyFiles("Message")]publicvirtualstringVirtualPropertyAnnotationInPropertyAndAccessor{[RequiresAssemblyFiles("Message")][RequiresUnreferencedCode("Message")]get;set;}}classDerivedClassWithoutRequires:BaseClassWithRequires{[ExpectedWarning("IL2046","DerivedClassWithoutRequires.VirtualMethod()","BaseClassWithRequires.VirtualMethod()")][ExpectedWarning("IL3003","DerivedClassWithoutRequires.VirtualMethod()","BaseClassWithRequires.VirtualMethod()",ProducedBy=ProducedBy.Analyzer)][ExpectedWarning("IL3051","DerivedClassWithoutRequires.VirtualMethod()","BaseClassWithRequires.VirtualMethod()",ProducedBy=ProducedBy.Analyzer)]publicoverridevoidVirtualMethod(){}privatestringname;publicoverridestringVirtualPropertyAnnotationInAccesor{[ExpectedWarning("IL2046","DerivedClassWithoutRequires.VirtualPropertyAnnotationInAccesor.get","BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get")][ExpectedWarning("IL3003","DerivedClassWithoutRequires.VirtualPropertyAnnotationInAccesor.get","BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get",ProducedBy=ProducedBy.Analyzer)][ExpectedWarning("IL3051","DerivedClassWithoutRequires.VirtualPropertyAnnotationInAccesor.get","BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get",ProducedBy=ProducedBy.Analyzer)]get{returnname;}set{name=value;}}[ExpectedWarning("IL3003","DerivedClassWithoutRequires.VirtualPropertyAnnotationInProperty","BaseClassWithRequires.VirtualPropertyAnnotationInProperty",ProducedBy=ProducedBy.Analyzer)]publicoverridestringVirtualPropertyAnnotationInProperty{get;set;}[ExpectedWarning("IL3003","DerivedClassWithoutRequires.VirtualPropertyAnnotationInPropertyAndAccessor","BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor",ProducedBy=ProducedBy.Analyzer)]publicoverridestringVirtualPropertyAnnotationInPropertyAndAccessor{[ExpectedWarning("IL2046","VirtualPropertyAnnotationInPropertyAndAccessor.get","BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get")][ExpectedWarning("IL3003","DerivedClassWithoutRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get","BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get",ProducedBy=ProducedBy.Analyzer)]get;set;}}
Expected behavior
Generate IL2046, IL3003 and IL3051 depending on the Requires attribute being mismatched
Actual behavior
Only warnings for access are generated
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered:
Description
The RequiresAttributeMismatch test uses DynamicallyAccessedMembersAttribute to mark as Required the methods on several classes by using a helper function called RequiresPublicMethods()
The classes are divided into Base/Derived classes and Virtual/Override classes, the attribute values inside these classes must match otherwise we should generate a warning stating that Base/Derive or Virtual/Override don't match.
Although NativeAOT warns about the usage of the methods being accessed by DAM, the attribute mismatch warnings are not existent.
Code that handles the attribute mismatch is in:
runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/UsageBasedMetadataManager.cs
Lines 729 to 736 in f54c15a
Reproduction Steps
Expected behavior
Generate IL2046, IL3003 and IL3051 depending on the Requires attribute being mismatched
Actual behavior
Only warnings for access are generated
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: