Skip to content

Commit 3a36040

Browse files
authored
Implement parity for RAF and RDC attributes in NativeAOT (#83085)
The `RequiresUnreferencedCode` (RDC), `RequiresAssemblyFiles` (RAF) and `RequiresDynamicCode` (RDC) attributes should behave the same way in NativeAOT compiler. This change implements the necessary bits to make them almost 100% the same. The only difference left is type hierarchy marking doesn't produce RAF/RDC related warnings - this is for now intentional, as it would probably produce unnecessary noise and the need for this seems to be really small. Test changes are to basically fill in the missing expected warnings. We already have solid tests for pretty much all scenarios, they just didn't baseline these warnings since no tool produced them (illink doesn't produce RAF/RDC warnings, analyzer only produces them on direct access, not on reflection access). This doesn't yet implement the IL3000 and IL3001 warnings in NativeAOT - that will be done in a subsequent change.
1 parent e310f87 commit 3a36040

File tree

11 files changed

+264
-58
lines changed

11 files changed

+264
-58
lines changed

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMarker.cs

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,35 @@ internal void CheckAndWarnOnReflectionAccess(in MessageOrigin origin, TypeSystem
215215
}
216216
else
217217
{
218-
var diagnosticContext = new DiagnosticContext(
219-
origin,
220-
_logger.ShouldSuppressAnalysisWarningsForRequires(origin.MemberDefinition, DiagnosticUtilities.RequiresUnreferencedCodeAttribute),
221-
_logger.ShouldSuppressAnalysisWarningsForRequires(origin.MemberDefinition, DiagnosticUtilities.RequiresDynamicCodeAttribute),
222-
_logger.ShouldSuppressAnalysisWarningsForRequires(origin.MemberDefinition, DiagnosticUtilities.RequiresAssemblyFilesAttribute),
223-
_logger);
218+
ReportRequires(origin, entity, DiagnosticUtilities.RequiresUnreferencedCodeAttribute);
219+
}
220+
}
224221

225-
string arg1 = MessageFormat.FormatRequiresAttributeMessageArg(DiagnosticUtilities.GetRequiresAttributeMessage(requiresAttribute.Value));
226-
string arg2 = MessageFormat.FormatRequiresAttributeUrlArg(DiagnosticUtilities.GetRequiresAttributeUrl(requiresAttribute.Value));
222+
if (entity.DoesMemberRequire(DiagnosticUtilities.RequiresAssemblyFilesAttribute, out _))
223+
{
224+
if (_typeHierarchyDataFlowOrigin is not null)
225+
{
226+
// For now we decided to not report single-file warnings due to type hierarchy marking.
227+
// It is considered too complex to figure out for the user and the likelihood of this
228+
// causing problems is pretty low.
229+
}
230+
else
231+
{
232+
ReportRequires(origin, entity, DiagnosticUtilities.RequiresAssemblyFilesAttribute);
233+
}
234+
}
227235

228-
diagnosticContext.AddDiagnostic(DiagnosticId.RequiresUnreferencedCode, entity.GetDisplayName(), arg1, arg2);
236+
if (entity.DoesMemberRequire(DiagnosticUtilities.RequiresDynamicCodeAttribute, out _))
237+
{
238+
if (_typeHierarchyDataFlowOrigin is not null)
239+
{
240+
// For now we decided to not report dynamic code warnings due to type hierarchy marking.
241+
// It is considered too complex to figure out for the user and the likelihood of this
242+
// causing problems is pretty low.
243+
}
244+
else
245+
{
246+
ReportRequires(origin, entity, DiagnosticUtilities.RequiresDynamicCodeAttribute);
229247
}
230248
}
231249

@@ -258,5 +276,17 @@ internal void CheckAndWarnOnReflectionAccess(in MessageOrigin origin, TypeSystem
258276
}
259277
}
260278
}
279+
280+
private void ReportRequires(in MessageOrigin origin, TypeSystemEntity entity, string requiresAttributeName)
281+
{
282+
var diagnosticContext = new DiagnosticContext(
283+
origin,
284+
_logger.ShouldSuppressAnalysisWarningsForRequires(origin.MemberDefinition, DiagnosticUtilities.RequiresUnreferencedCodeAttribute),
285+
_logger.ShouldSuppressAnalysisWarningsForRequires(origin.MemberDefinition, DiagnosticUtilities.RequiresDynamicCodeAttribute),
286+
_logger.ShouldSuppressAnalysisWarningsForRequires(origin.MemberDefinition, DiagnosticUtilities.RequiresAssemblyFilesAttribute),
287+
_logger);
288+
289+
ReflectionMethodBodyScanner.CheckAndReportRequires(diagnosticContext, entity, requiresAttributeName);
290+
}
261291
}
262292
}

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static bool RequiresReflectionMethodBodyScannerForCallSite(FlowAnnotation
3636
flowAnnotations.RequiresDataflowAnalysisDueToSignature(method) ||
3737
GenericArgumentDataFlow.RequiresGenericArgumentDataFlow(flowAnnotations, method) ||
3838
method.DoesMethodRequire(DiagnosticUtilities.RequiresUnreferencedCodeAttribute, out _) ||
39+
method.DoesMethodRequire(DiagnosticUtilities.RequiresAssemblyFilesAttribute, out _) ||
3940
method.DoesMethodRequire(DiagnosticUtilities.RequiresDynamicCodeAttribute, out _) ||
4041
IsPInvokeDangerous(method, out _, out _);
4142
}
@@ -51,6 +52,7 @@ public static bool RequiresReflectionMethodBodyScannerForAccess(FlowAnnotations
5152
return flowAnnotations.RequiresDataflowAnalysisDueToSignature(field) ||
5253
GenericArgumentDataFlow.RequiresGenericArgumentDataFlow(flowAnnotations, field) ||
5354
field.DoesFieldRequire(DiagnosticUtilities.RequiresUnreferencedCodeAttribute, out _) ||
55+
field.DoesFieldRequire(DiagnosticUtilities.RequiresAssemblyFilesAttribute, out _) ||
5456
field.DoesFieldRequire(DiagnosticUtilities.RequiresDynamicCodeAttribute, out _);
5557
}
5658

src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptionsUpdateHandler.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Diagnostics.CodeAnalysis;
66
using System.Reflection.Metadata;
7+
using System.Runtime.CompilerServices;
78
using System.Text.Json;
89
using System.Text.Json.Serialization.Metadata;
910

@@ -16,7 +17,6 @@ namespace System.Text.Json
1617
/// <summary>Handler used to clear JsonSerializerOptions reflection cache upon a metadata update.</summary>
1718
internal static class JsonSerializerOptionsUpdateHandler
1819
{
19-
[RequiresDynamicCode(JsonSerializer.SerializationRequiresDynamicCodeMessage)]
2020
public static void ClearCache(Type[]? types)
2121
{
2222
// Ignore the types, and just clear out all reflection caches from serializer options.
@@ -25,8 +25,13 @@ public static void ClearCache(Type[]? types)
2525
options.Key.ClearCaches();
2626
}
2727

28-
// Flush the dynamic method cache
29-
ReflectionEmitCachingMemberAccessor.Clear();
28+
if (RuntimeFeature.IsDynamicCodeSupported)
29+
{
30+
// Flush the dynamic method cache
31+
#pragma warning disable IL3050 // The analyzer doesn't understand runtime feature conditions: https://github.com/dotnet/linker/issues/2715
32+
ReflectionEmitCachingMemberAccessor.Clear();
33+
#pragma warning restore IL3050
34+
}
3035
}
3136
}
3237
}

src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class VirtualMethodHierarchyDataflowAnnotationValidation
2626
{
2727
// The code below marks methods which have RUC on them, it's not the point of this test to validate these here
2828
[UnconditionalSuppressMessage ("test", "IL2026")]
29+
// The code below marks methods which have RDC on them, it's not the point of this test to validate these here
30+
[UnconditionalSuppressMessage ("test", "IL3050")]
2931
public static void Main ()
3032
{
3133
// The test uses data flow annotation to mark all public methods on the specified types

src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/BasicRequires.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public static void Main ()
3333
TestRequiresFromNameOf ();
3434
OnEventMethod.Test ();
3535
RequiresOnGenerics.Test ();
36+
AssemblyFilesOnly.Test ();
37+
DynamicCodeOnly.Test ();
3638
}
3739

3840
[ExpectedWarning ("IL2026", "Message for --RequiresWithMessageOnly--.")]
@@ -189,8 +191,8 @@ public static void GenericTypeWithStaticMethodWhichRequires () { }
189191
}
190192

191193
[ExpectedWarning ("IL2026", "--GenericTypeWithStaticMethodWhichRequires--")]
192-
[ExpectedWarning ("IL3002", "--GenericTypeWithStaticMethodWhichRequires--", ProducedBy = Tool.Analyzer)]
193-
[ExpectedWarning ("IL3050", "--GenericTypeWithStaticMethodWhichRequires--", ProducedBy = Tool.Analyzer)]
194+
[ExpectedWarning ("IL3002", "--GenericTypeWithStaticMethodWhichRequires--", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
195+
[ExpectedWarning ("IL3050", "--GenericTypeWithStaticMethodWhichRequires--", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
194196
public static void GenericTypeWithStaticMethodViaLdftn ()
195197
{
196198
var _ = new Action (GenericWithStaticMethod<TestType>.GenericTypeWithStaticMethodWhichRequires);
@@ -207,5 +209,29 @@ public static void Test ()
207209
MakeNew2<TestType> ();
208210
}
209211
}
212+
213+
class AssemblyFilesOnly
214+
{
215+
[RequiresAssemblyFiles("--Requires--")]
216+
static void Requires () { }
217+
218+
[ExpectedWarning("IL3002", "--Requires--", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
219+
public static void Test()
220+
{
221+
Requires ();
222+
}
223+
}
224+
225+
class DynamicCodeOnly
226+
{
227+
[RequiresDynamicCode ("--Requires--")]
228+
static void Requires () { }
229+
230+
[ExpectedWarning ("IL3050", "--Requires--", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
231+
public static void Test ()
232+
{
233+
Requires ();
234+
}
235+
}
210236
}
211237
}

src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresAccessedThrough.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ static void RequiresOnlyThroughReflection ()
4141
{
4242
}
4343

44+
// https://github.com/dotnet/linker/issues/2739 - the discussion there explains why (at least for now) we don't produce
45+
// RAF and RDC warnings from the analyzer in these cases.
4446
[ExpectedWarning ("IL2026", "--RequiresOnlyThroughReflection--")]
47+
[ExpectedWarning ("IL3002", "--RequiresOnlyThroughReflection--", ProducedBy = Tool.NativeAot)]
48+
[ExpectedWarning ("IL3050", "--RequiresOnlyThroughReflection--", ProducedBy = Tool.NativeAot)]
4549
static void TestRequiresOnlyThroughReflection ()
4650
{
4751
typeof (RequiresAccessedThrough)
@@ -59,6 +63,8 @@ public static void RequiresOnlyThroughReflection ()
5963
}
6064

6165
[ExpectedWarning ("IL2026", "--GenericType.RequiresOnlyThroughReflection--")]
66+
[ExpectedWarning ("IL3002", "--GenericType.RequiresOnlyThroughReflection--", ProducedBy = Tool.NativeAot)]
67+
[ExpectedWarning ("IL3050", "--GenericType.RequiresOnlyThroughReflection--", ProducedBy = Tool.NativeAot)]
6268
public static void Test ()
6369
{
6470
typeof (AccessedThroughReflectionOnGenericType<T>)
@@ -218,12 +224,12 @@ static bool PropertyWithLdToken {
218224
}
219225
}
220226

221-
// NativeAOT should produce diagnostics when using Func
222-
// https://github.com/dotnet/runtime/issues/73321
223227
[ExpectedWarning ("IL2026", "--PropertyWithLdToken.get--")]
224228
[ExpectedWarning ("IL2026", "--PropertyWithLdToken.get--", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
225-
[ExpectedWarning ("IL3002", "--PropertyWithLdToken.get--", ProducedBy = Tool.Analyzer)]
226-
[ExpectedWarning ("IL3050", "--PropertyWithLdToken.get--", ProducedBy = Tool.Analyzer)]
229+
[ExpectedWarning ("IL3002", "--PropertyWithLdToken.get--", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
230+
[ExpectedWarning ("IL3002", "--PropertyWithLdToken.get--", ProducedBy = Tool.NativeAot)]
231+
[ExpectedWarning ("IL3050", "--PropertyWithLdToken.get--", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
232+
[ExpectedWarning ("IL3050", "--PropertyWithLdToken.get--", ProducedBy = Tool.NativeAot)]
227233
public static void Test ()
228234
{
229235
Expression<Func<bool>> getter = () => PropertyWithLdToken;

src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresAttributeMismatch.cs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,67 @@ class RequiresAttributeMismatch
2323
{
2424
// Base/Derived and Implementation/Interface differs between ILLink and analyzer https://github.com/dotnet/linker/issues/2533
2525
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get")]
26+
[ExpectedWarning ("IL3002", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
27+
[ExpectedWarning ("IL3050", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
2628
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get")]
29+
[ExpectedWarning ("IL3002", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
30+
[ExpectedWarning ("IL3050", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
2731
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get")]
32+
[ExpectedWarning ("IL3002", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
33+
[ExpectedWarning ("IL3050", "BaseClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
2834
[ExpectedWarning ("IL2026", "DerivedClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
35+
[ExpectedWarning ("IL3002", "DerivedClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
36+
[ExpectedWarning ("IL3050", "DerivedClassWithRequires.VirtualPropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
2937
[ExpectedWarning ("IL2026", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInAccesor.set", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
38+
[ExpectedWarning ("IL3002", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInAccesor.set", ProducedBy = Tool.NativeAot)]
3039
[ExpectedWarning ("IL2026", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInProperty.get", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
40+
[ExpectedWarning ("IL3002", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInProperty.get", ProducedBy = Tool.NativeAot)]
3141
[ExpectedWarning ("IL2026", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInProperty.set", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
42+
[ExpectedWarning ("IL3002", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInProperty.set", ProducedBy = Tool.NativeAot)]
43+
[ExpectedWarning ("IL2026", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInPropertyAndAccessor.set", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
44+
[ExpectedWarning ("IL3002", "DerivedClassWithAllWarnings.VirtualPropertyAnnotationInPropertyAndAccessor.set", ProducedBy = Tool.NativeAot)]
3245
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualMethod()")]
46+
[ExpectedWarning ("IL3002", "BaseClassWithRequires.VirtualMethod()", ProducedBy = Tool.NativeAot)]
47+
[ExpectedWarning ("IL3050", "BaseClassWithRequires.VirtualMethod()", ProducedBy = Tool.NativeAot)]
3348
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualMethod()")]
49+
[ExpectedWarning ("IL3002", "BaseClassWithRequires.VirtualMethod()", ProducedBy = Tool.NativeAot)]
50+
[ExpectedWarning ("IL3050", "BaseClassWithRequires.VirtualMethod()", ProducedBy = Tool.NativeAot)]
3451
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualMethod()")]
52+
[ExpectedWarning ("IL3002", "BaseClassWithRequires.VirtualMethod()", ProducedBy = Tool.NativeAot)]
53+
[ExpectedWarning ("IL3050", "BaseClassWithRequires.VirtualMethod()", ProducedBy = Tool.NativeAot)]
3554
[ExpectedWarning ("IL2026", "DerivedClassWithRequires.VirtualMethod()", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
55+
[ExpectedWarning ("IL3002", "DerivedClassWithRequires.VirtualMethod()", ProducedBy = Tool.NativeAot)]
56+
[ExpectedWarning ("IL3050", "DerivedClassWithRequires.VirtualMethod()", ProducedBy = Tool.NativeAot)]
3657
[ExpectedWarning ("IL2026", "IBaseWithRequires.PropertyAnnotationInAccesor.get")]
37-
[ExpectedWarning ("IL2026", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor.set", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
58+
[ExpectedWarning ("IL3002", "IBaseWithRequires.PropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
59+
[ExpectedWarning ("IL3050", "IBaseWithRequires.PropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
60+
[ExpectedWarning ("IL2026", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor.set")]
61+
[ExpectedWarning ("IL3002", "IBaseWithRequires.PropertyAnnotationInPropertyAndAccessor.set", ProducedBy = Tool.NativeAot)]
3862
[ExpectedWarning ("IL2026", "IBaseWithRequires.Method()")]
63+
[ExpectedWarning ("IL3002", "IBaseWithRequires.Method()", ProducedBy = Tool.NativeAot)]
64+
[ExpectedWarning ("IL3050", "IBaseWithRequires.Method()", ProducedBy = Tool.NativeAot)]
3965
[ExpectedWarning ("IL2026", "ImplementationClassWithRequires.Method()", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
66+
[ExpectedWarning ("IL3002", "ImplementationClassWithRequires.Method()", ProducedBy = Tool.NativeAot)]
67+
[ExpectedWarning ("IL3050", "ImplementationClassWithRequires.Method()", ProducedBy = Tool.NativeAot)]
4068
[ExpectedWarning ("IL2026", "ImplementationClassWithRequires.PropertyAnnotationInAccesor.get", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
69+
[ExpectedWarning ("IL3002", "ImplementationClassWithRequires.PropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
70+
[ExpectedWarning ("IL3050", "ImplementationClassWithRequires.PropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
4171
[ExpectedWarning ("IL2026", "ImplementationClassWithRequires.PropertyAnnotationInPropertyAndAccessor.get", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
72+
[ExpectedWarning ("IL3002", "ImplementationClassWithRequires.PropertyAnnotationInPropertyAndAccessor.get", ProducedBy = Tool.NativeAot)]
4273
[ExpectedWarning ("IL2026", "ImplementationClassWithoutRequires.PropertyAnnotationInPropertyAndAccessor.get", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
74+
[ExpectedWarning ("IL3002", "ImplementationClassWithoutRequires.PropertyAnnotationInPropertyAndAccessor.get", ProducedBy = Tool.NativeAot)]
4375
[ExpectedWarning ("IL2026", "ImplementationClassWithRequiresInSource.Method()", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
76+
[ExpectedWarning ("IL3002", "ImplementationClassWithRequiresInSource.Method()", ProducedBy = Tool.NativeAot)]
77+
[ExpectedWarning ("IL3050", "ImplementationClassWithRequiresInSource.Method()", ProducedBy = Tool.NativeAot)]
4478
[ExpectedWarning ("IL2026", "ImplementationClassWithRequiresInSource.PropertyAnnotationInAccesor.get", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
79+
[ExpectedWarning ("IL3002", "ImplementationClassWithRequiresInSource.PropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
80+
[ExpectedWarning ("IL3050", "ImplementationClassWithRequiresInSource.PropertyAnnotationInAccesor.get", ProducedBy = Tool.NativeAot)]
4581
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get")]
82+
[ExpectedWarning ("IL3002", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get", ProducedBy = Tool.NativeAot)]
4683
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get")]
84+
[ExpectedWarning ("IL3002", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get", ProducedBy = Tool.NativeAot)]
4785
[ExpectedWarning ("IL2026", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get")]
48-
[ExpectedWarning ("IL2026", "PropertyAnnotationInPropertyAndAccessor.set")]
86+
[ExpectedWarning ("IL3002", "BaseClassWithRequires.VirtualPropertyAnnotationInPropertyAndAccessor.get", ProducedBy = Tool.NativeAot)]
4987

5088
public static void Main ()
5189
{
@@ -492,11 +530,23 @@ public string PropertyAnnotationInAccesor {
492530
class StaticInterfaceMethods
493531
{
494532
[ExpectedWarning ("IL2026")]
533+
[ExpectedWarning ("IL3002", ProducedBy = Tool.NativeAot)]
534+
[ExpectedWarning ("IL3050", ProducedBy = Tool.NativeAot)]
495535
[ExpectedWarning ("IL2026")]
536+
[ExpectedWarning ("IL3002", ProducedBy = Tool.NativeAot)]
537+
[ExpectedWarning ("IL3050", ProducedBy = Tool.NativeAot)]
496538
[ExpectedWarning ("IL2026")]
539+
[ExpectedWarning ("IL3002", ProducedBy = Tool.NativeAot)]
540+
[ExpectedWarning ("IL3050", ProducedBy = Tool.NativeAot)]
497541
[ExpectedWarning ("IL2026")]
542+
[ExpectedWarning ("IL3002", ProducedBy = Tool.NativeAot)]
543+
[ExpectedWarning ("IL3050", ProducedBy = Tool.NativeAot)]
498544
[ExpectedWarning ("IL2026")]
545+
[ExpectedWarning ("IL3002", ProducedBy = Tool.NativeAot)]
546+
[ExpectedWarning ("IL3050", ProducedBy = Tool.NativeAot)]
499547
[ExpectedWarning ("IL2026")]
548+
[ExpectedWarning ("IL3002", ProducedBy = Tool.NativeAot)]
549+
[ExpectedWarning ("IL3050", ProducedBy = Tool.NativeAot)]
500550
public static void Test ()
501551
{
502552
typeof (IRequires).RequiresPublicMethods ();
@@ -506,6 +556,7 @@ public static void Test ()
506556
typeof (ImplIRequiresMismatching).RequiresPublicMethods ();
507557
typeof (ImplIRequiresMatching).RequiresPublicMethods ();
508558
}
559+
509560
interface IRequires
510561
{
511562
[RequiresUnreferencedCode ("Message for --StaticInterfaceMethods.IRequires.VirtualMethod--")]

0 commit comments

Comments
 (0)