Enable more ILLink tests in NativeAOT (#85651)
authorVitek Karas <10670590+vitek-karas@users.noreply.github.com>
Thu, 4 May 2023 07:59:13 +0000 (00:59 -0700)
committerGitHub <noreply@github.com>
Thu, 4 May 2023 07:59:13 +0000 (00:59 -0700)
Product fixes:
* Fix tracking of arrays in NativeAOT
* Fix handling of arrays in ILLink

Test fixes:
* Consider reflection enabled methods as marked (even if they don't have an entrypoint, like interface methods)
* Fix where to look for ilasm
* Better handling of compiled dependenceis
* Ignore some more compiler generated code (which can't be marked as kept)

Enables several more data flow tests from linker for AOT as well.
Updates some bug links to point to runtime repo.

23 files changed:
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Compilation.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/FlowAnnotations.cs
src/coreclr/tools/aot/Mono.Linker.Tests/Mono.Linker.Tests.csproj
src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs
src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs
src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILInputCompiler.cs
src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs
src/tools/illink/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ByRefDataflow.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/CompilerGeneratedCodeInPreservedAssembly.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ComplexTypeHandling.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ConstructedTypesDataFlow.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/MakeGenericDataFlow.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/MemberTypes.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/MemberTypesAllOnCopyAssembly.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/MethodByRefParameterDataFlow.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/NullableAnnotations.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/RefFieldDataFlow.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/StaticInterfaceMethodDataflow.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/TypeInfoIntrinsics.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMethod.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/SuppressWarningsUsingTargetViaXmlNetCore.cs

index 48c1c0b7cc34360bcf6835f94291e3bd511ce495..b6a0997701b732062c5d8d9bee860cc2e6bce809 100644 (file)
@@ -626,8 +626,8 @@ namespace ILCompiler
             {
                 foreach (var node in MarkedNodes)
                 {
-                    if (node is IMethodBodyNode)
-                        yield return ((IMethodBodyNode)node).Method;
+                    if (node is IMethodBodyNode methodBodyNode)
+                        yield return methodBodyNode.Method;
                 }
             }
         }
@@ -639,9 +639,7 @@ namespace ILCompiler
                 foreach (var node in MarkedNodes)
                 {
                     if (node is ConstructedEETypeNode || node is CanonicalEETypeNode)
-                    {
                         yield return ((IEETypeNode)node).Type;
-                    }
                 }
             }
         }
@@ -652,10 +650,20 @@ namespace ILCompiler
             {
                 foreach (var node in MarkedNodes)
                 {
-                    if (node is IEETypeNode)
-                    {
-                        yield return ((IEETypeNode)node).Type;
-                    }
+                    if (node is IEETypeNode typeNode)
+                        yield return typeNode.Type;
+                }
+            }
+        }
+
+        public IEnumerable<MethodDesc> ReflectedMethods
+        {
+            get
+            {
+                foreach (var node in MarkedNodes)
+                {
+                    if (node is ReflectedMethodNode reflectedMethod)
+                        yield return reflectedMethod.Method;
                 }
             }
         }
index b9312b0e10969f5a7a38e5124e363ccdf4c2a0d7..e489edce4ad806680f6d7426c3887f7888070d76 100644 (file)
@@ -1025,6 +1025,10 @@ namespace ILLink.Shared.TrimAnalysis
                 // All values except for Nullable<T>, including Nullable<> (with no type arguments)
                 return new SystemTypeValue(genericArgumentType);
             }
+            else if (genericArgument is ArrayType arrayType)
+            {
+                return new SystemTypeValue(arrayType);
+            }
             else
             {
                 return UnknownValue.Instance;
index 72fd7dffe14948115f99f02e985906135bb9372f..dc1dd6f608ced3dad3db2790470454b14246be61 100644 (file)
@@ -38,6 +38,9 @@
     <RuntimeHostConfigurationOption Include="Mono.Linker.Tests.ArtifactsDir">
       <Value>$(ArtifactsDir)</Value>
     </RuntimeHostConfigurationOption>
+    <RuntimeHostConfigurationOption Include="Mono.Linker.Tests.ILToolsDir">
+      <Value>$(CoreCLRArtifactsPath)</Value>
+    </RuntimeHostConfigurationOption>
     <RuntimeHostConfigurationOption Include="Mono.Linker.Tests.ArtifactsBinDir">
       <Value>$(ArtifactsBinDir)</Value>
     </RuntimeHostConfigurationOption>
index b2ef85209147941cdb1ab23658ddc3359c8768bd..961e4b6a9c0152a4803c37cab086361d7b8dcb33 100644 (file)
@@ -8,8 +8,6 @@ using System.Linq;
 using System.Text;
 using FluentAssertions;
 using ILCompiler;
-using ILCompiler.DependencyAnalysis;
-using Internal.IL.Stubs;
 using Internal.TypeSystem;
 using Internal.TypeSystem.Ecma;
 using Mono.Cecil;
@@ -42,7 +40,10 @@ namespace Mono.Linker.Tests.TestCasesRunner
 
                                // Ignore NativeAOT injected members
                                "<Module>.StartupCodeMain(Int32,IntPtr)",
-                               "<Module>.MainMethodWrapper()"
+                               "<Module>.MainMethodWrapper()",
+
+                               // Ignore compiler generated code which can't be reasonably matched to the source method
+                               "<PrivateImplementationDetails>",
                        };
 
                public AssemblyChecker (
@@ -130,6 +131,10 @@ namespace Mono.Linker.Tests.TestCasesRunner
                                AddMethod (method);
                        }
 
+                       foreach (MethodDesc method in testResult.TrimmingResults.ReflectedMethods) {
+                               AddMethod (method);
+                       }
+
                        void AddMethod (MethodDesc method)
                        {
                                MethodDesc methodDef = method.GetTypicalMethodDefinition ();
index 2864f4c2c88566e0c7e15adecee17c9dfd955aac..d5fa880badfefeb18e9450219c927b3dc6914766 100644 (file)
@@ -64,6 +64,16 @@ namespace Mono.Linker.Tests.TestCasesRunner
 
                        compilationRoots.Add (new MainMethodRootProvider (entrypointModule, CreateInitializerList (typeSystemContext, options), generateLibraryAndModuleInitializers: true));
 
+                       foreach (var rootedAssembly in options.AdditionalRootAssemblies) {
+                               EcmaModule module = typeSystemContext.GetModuleForSimpleName (rootedAssembly);
+
+                               // We only root the module type. The rest will fall out because we treat rootedAssemblies
+                               // same as conditionally rooted ones and here we're fulfilling the condition ("something is used").
+                               compilationRoots.Add (
+                                       new GenericRootProvider<ModuleDesc> (module,
+                                       (ModuleDesc module, IRootingServiceProvider rooter) => rooter.AddReflectionRoot (module.GetGlobalModuleType (), "Command line root")));
+                       }
+
                        ILProvider ilProvider = new NativeAotILProvider ();
 
                        Logger logger = new Logger (
index bffa9822c358f5cc23946f66e44e5cb752c39d1d..22b7a621acc6de67ac39321d2678a6dec931917c 100644 (file)
@@ -61,10 +61,9 @@ namespace Mono.Linker.Tests.TestCasesRunner
 #if NETCOREAPP
                        var extension = RuntimeInformation.IsOSPlatform (OSPlatform.Windows) ? ".exe" : "";
 
-                       // working directory is artifacts/bin/Mono.Linker.Tests/<config>/<tfm>
-                       var toolsDir = Path.Combine (Directory.GetCurrentDirectory (), "..", "..", "..", "..", "tools");
+                       var toolsDir = (string) AppContext.GetData ("Mono.Linker.Tests.ILToolsDir")!;
 
-                       var ilasmPath = Path.GetFullPath (Path.Combine (toolsDir, "ilasm", $"ilasm{extension}")).ToNPath ();
+                       var ilasmPath = Path.GetFullPath (Path.Combine (toolsDir, $"ilasm{extension}")).ToNPath ();
                        if (ilasmPath.FileExists ())
                                return ilasmPath;
 
index 50442019768c011ad4180494d14d410702b0e0bc..5e9a63db86c05407eed8e1cfeecb1296ca735a28 100644 (file)
@@ -129,11 +129,9 @@ namespace Mono.Linker.Tests.TestCasesRunner
                        foreach (var inputReference in sandbox.InputDirectory.Files ()) {
                                var ext = inputReference.ExtensionWithDot;
                                if (ext == ".dll" || ext == ".exe") {
-                                       if (caseDefinedOptions.AssembliesAction.Contains (("link", inputReference.FileNameWithoutExtension))) {
-                                               builder.AddLinkAssembly (inputReference);
-                                       } else {
-                                               builder.AddReference (inputReference);
-                                       }
+                                       // It's important to add all assemblies as "link" assemblies since the default configuration
+                                       // is to run the compiler in multi-file mode which will not process anything which is just in the reference set.
+                                       builder.AddLinkAssembly (inputReference);
                                }
                        }
                        var coreAction = caseDefinedOptions.TrimMode ?? "skip";
index 0b357b56330f5cb85b97bdf6ace310e533444cce..28780d1123915847f0814508e31b9354827337fb 100644 (file)
@@ -303,12 +303,14 @@ namespace Mono.Linker.Dataflow
                                                if (staticType is null) {
                                                        // We don't know anything about the type GetType was called on. Track this as a usual result of a method call without any annotations
                                                        AddReturnValue (context.Annotations.FlowAnnotations.GetMethodReturnValue (calledMethodDefinition));
-                                               } else if (staticType.IsSealed || staticType.IsTypeOf ("System", "Delegate")) {
+                                               } else if (staticType.IsSealed || staticType.IsTypeOf ("System", "Delegate") || staticType.IsTypeOf ("System", "Array")) {
                                                        // We can treat this one the same as if it was a typeof() expression
 
                                                        // We can allow Object.GetType to be modeled as System.Delegate because we keep all methods
                                                        // on delegates anyway so reflection on something this approximation would miss is actually safe.
 
+                                                       // We can also treat all arrays as "sealed" since it's not legal to derive from Array type (even though it is not sealed itself)
+
                                                        // We ignore the fact that the type can be annotated (see below for handling of annotated types)
                                                        // This means the annotations (if any) won't be applied - instead we rely on the exact knowledge
                                                        // of the type. So for example even if the type is annotated with PublicMethods
index bd89abc447dce7ab8d255db3a88e5bd8bf5188b5..b7c71da382b7319f68549d7e8318e5c601263572 100644 (file)
@@ -179,7 +179,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        [Kept]
-                       // https://github.com/dotnet/linker/issues/2874
+                       // https://github.com/dotnet/runtime/issues/85464
                        [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        public static void Test ()
index 722720553ad3e017b8c6b3207c144b5630be38c2..9e382e40a380c104d9f83e6acf2c5ab131792c62 100644 (file)
@@ -10,8 +10,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
-       // This test tries to hit a case where the entire assemly is preserved (via descriptor, NOT action)
+       // This test tries to hit a case where the entire assembly is preserved (via descriptor, NOT action)
        // meaning we will go and mark all types and members in it.
        // At the same time there's a compiler generated method (local function) which is called from
        // a branch which will be removed due to constant propagation.
@@ -44,7 +43,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                                }
 
                                // Analyzer doesn't implement constant propagation and branch removal, so it reaches this code
-                               [ExpectedWarning ("IL2026", ProducedBy = Tool.Analyzer)]
+                               // NativeAOT behavioral difference:
+                               //   https://github.com/dotnet/runtime/issues/85161
+                               [ExpectedWarning ("IL2026", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
                                void LocalWithWarning ()
                                {
                                        // No warning
@@ -64,7 +65,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        // Analyzer doesn't implement constant propagation and branch removal, so it reaches this code
-                       [ExpectedWarning ("IL2026", ProducedBy = Tool.Analyzer)]
+                       // NativeAOT behavioral difference:
+                       //   https://github.com/dotnet/runtime/issues/85161
+                       [ExpectedWarning ("IL2026", ProducedBy = Tool.Analyzer | Tool.NativeAot)]
                        void LocalWithWarning ()
                        {
                                Requires ();
index 594a1926eece37c101b81eb0065e970b7002a469..343edfcc63c46fa1ee15baa8cdd862bdbe1e1556 100644 (file)
@@ -11,8 +11,9 @@ using Mono.Linker.Tests.Cases.Expectations.Assertions;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
-       [KeptAttributeAttribute (typeof (IgnoreTestCaseAttribute), By = Tool.Trimmer)]
+       [ExpectedNoWarnings]
+       [UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Applying DAM PublicMethods on an array will mark Array.CreateInstance which has RDC on it")]
+       [KeptAttributeAttribute(typeof(UnconditionalSuppressMessageAttribute))]
        public class ComplexTypeHandling
        {
                public static void Main ()
@@ -93,7 +94,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        _ = new RequirePublicMethodsGeneric<T[]> ();
                }
 
-               [Kept]
+               [Kept (By = Tool.Trimmer)] // NativeAOT doesn't preserve array element types just due to the usage of the array type
                sealed class ArrayGetTypeFromMethodParamElement
                {
                        // This method should not be marked, instead Array.* should be marked
@@ -112,7 +113,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        TestArrayGetTypeFromMethodParamHelper (null);
                }
 
-               [Kept]
+               [Kept (By = Tool.Trimmer)] // NativeAOT doesn't preserve array element types just due to the usage of the array type
                sealed class ArrayGetTypeFromFieldElement
                {
                        // This method should not be marked, instead Array.* should be marked
@@ -141,11 +142,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        RequirePublicMethods (Type.GetType ("Mono.Linker.Tests.Cases.DataFlow.ComplexTypeHandling+ArrayTypeGetTypeElement[]"));
                }
 
-               // Technically there's no reason to mark this type since it's only used as an array element type and CreateInstance
-               // doesn't work on arrays, but the currently implementation will preserve it anyway due to how it processes
+               // Trimmer: Technically there's no reason to mark this type since it's only used as an array element type and CreateInstance
+               // doesn't work on arrays, but the current implementation will preserve it anyway due to how it processes
                // string -> Type resolution. This will only impact code which would have failed at runtime, so very unlikely to
                // actually occur in real apps (and even if it does happen, it just increases size, doesn't break behavior).
-               [Kept]
+               [Kept (By = Tool.Trimmer)] // NativeAOT doesn't preserve array element types just due to the usage of the array type
                class ArrayCreateInstanceByNameElement
                {
                        public ArrayCreateInstanceByNameElement ()
@@ -154,12 +155,13 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                }
 
                [Kept]
+               [ExpectedWarning ("IL2032", ProducedBy = Tool.NativeAot)] // https://github.com/dotnet/runtime/issues/82447
                static void TestArrayCreateInstanceByName ()
                {
                        Activator.CreateInstance ("test", "Mono.Linker.Tests.Cases.DataFlow.ComplexTypeHandling+ArrayCreateInstanceByNameElement[]");
                }
 
-               [Kept]
+               [Kept (By = Tool.Trimmer)] // NativeAOT doesn't preserve array element types just due to the usage of the array type
                class ArrayInAttributeParamElement
                {
                        // This method should not be marked, instead Array.* should be marked
@@ -169,10 +171,17 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                [Kept]
                [KeptAttributeAttribute (typeof (RequiresPublicMethodAttribute))]
                [RequiresPublicMethod (typeof (ArrayInAttributeParamElement[]))]
-               static void TestArrayInAttributeParameter ()
+               static void TestArrayInAttributeParameterImpl ()
                {
                }
 
+               [Kept]
+               static void TestArrayInAttributeParameter()
+               {
+                       // Have to access the method through reflection, otherwise NativeAOT will remove all attributes on it
+                       // since they're not accessible.
+                       typeof (ComplexTypeHandling).GetMethod (nameof (TestArrayInAttributeParameterImpl), System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).Invoke (null, new object[] { });
+               }
 
                [Kept]
                private static void RequirePublicMethods (
index 22584259fcdb7f7d256bd8b32097da2ac2ef7c7c..3bc10b9aa5f919b4b9d6bb7ff334ee38b4af58c3 100644 (file)
@@ -12,7 +12,6 @@ using Mono.Linker.Tests.Cases.Expectations.Helpers;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
        [ExpectedNoWarnings]
        [SkipKeptItemsValidation]
        class ConstructedTypesDataFlow
index b8ef7d98ea7e0ea54282a06592812cdd0776d1c4..579a775301f5bd2effd92b23b8d12f5420253867 100644 (file)
@@ -7,7 +7,6 @@ using BindingFlags = System.Reflection.BindingFlags;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
        [SkipKeptItemsValidation]
        [ExpectedNoWarnings]
        [UnconditionalSuppressMessage ("AOT", "IL3050", Justification = "These tests are not targetted at AOT scenarios")]
@@ -85,7 +84,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        // https://github.com/dotnet/linker/issues/2755
-                       [ExpectedWarning ("IL2055", nameof (Type.MakeGenericType), ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2055", nameof (Type.MakeGenericType), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestWithUnknownTypeArray (Type[] types)
                        {
                                typeof (GenericWithPublicFieldsArgument<>).MakeGenericType (types);
@@ -100,7 +99,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        // https://github.com/dotnet/linker/issues/2755
-                       [ExpectedWarning ("IL2055", nameof (Type.MakeGenericType), ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2055", nameof (Type.MakeGenericType), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestWithArrayUnknownLengthSet (int arrayLen)
                        {
                                Type[] types = new Type[arrayLen];
@@ -424,14 +423,14 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        // https://github.com/dotnet/linker/issues/2755
-                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestUnknownMethod (MethodInfo mi)
                        {
                                mi.MakeGenericMethod (typeof (TestType));
                        }
 
                        // https://github.com/dotnet/linker/issues/2755
-                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestUnknownMethodButNoTypeArguments (MethodInfo mi)
                        {
                                // Technically trimming could figure this out, but it's not worth the complexity - such call will always fail at runtime.
@@ -542,7 +541,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        // https://github.com/dotnet/linker/issues/2755
-                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestWithUnknownTypeArray (Type[] types)
                        {
                                typeof (MakeGenericMethod).GetMethod (nameof (GenericWithRequirements), BindingFlags.Static)
@@ -559,7 +558,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        // https://github.com/dotnet/linker/issues/2158 - analyzer doesn't work the same as ILLink, it simply doesn't handle refs
-                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestWithArrayUnknownIndexSetByRef (int indexToSet)
                        {
                                Type[] types = new Type[1];
@@ -571,7 +570,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        // https://github.com/dotnet/linker/issues/2755
-                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2060", nameof (MethodInfo.MakeGenericMethod), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestWithArrayUnknownLengthSet (int arrayLen)
                        {
                                Type[] types = new Type[arrayLen];
index 9d3bcbf511995315d9ef541e182c9a430e131cc4..7bcdeb59729c38a078ef2961e079dbbfd029aa2d 100644 (file)
@@ -11,69 +11,15 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
-       [KeptAttributeAttribute (typeof (IgnoreTestCaseAttribute), By = Tool.Trimmer)]
        [SetupCompileArgument ("/optimize+")]
        [ExpectedNoWarnings]
        public class MemberTypes
        {
-               // Some of the types below declare delegates and will mark all members on them, this includes the Delegate .ctor(object, string) which has RUC and other members
-               [ExpectedWarning ("IL2026", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2026", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2026", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2026", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2026", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2026", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               [ExpectedWarning ("IL2026", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               [ExpectedWarning ("IL2026", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               [ExpectedWarning ("IL2026", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               [ExpectedWarning ("IL2026", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               // Some of the types below declare delegates and will mark all members on them, this includes the Delegate .ctor(Type, string) which has DAM annotations and other members
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".Delegate")]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (Delegate.CreateDelegate))]
-               [ExpectedWarning ("IL2111", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               [ExpectedWarning ("IL2111", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               [ExpectedWarning ("IL2111", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               [ExpectedWarning ("IL2111", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               [ExpectedWarning ("IL2111", nameof (MulticastDelegate) + ".MulticastDelegate")]
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".BindToMethodName", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".BindToMethodName", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".BindToMethodName", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".BindToMethodName", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2111", nameof (Delegate) + ".BindToMethodName", ProducedBy = Tool.Trimmer)]
+               // This is an easy way to suppress all trim related warnings in the Main method
+               // This test is about marking, not diagnostics and this Main will produce several warnings due to it accssing
+               // some problematic APIs (Delegate.Create for example) via reflection.
+               [RequiresUnreferencedCode("test")]
+               [KeptAttributeAttribute(typeof(RequiresUnreferencedCodeAttribute))]
                public static void Main ()
                {
                        RequirePublicParameterlessConstructor (typeof (PublicParameterlessConstructorType));
index 4ac5f0edfe274c2d536cd4f6077bc112ba91c97b..716662e19e88d150397ee6415ec056546f0737b8 100644 (file)
@@ -13,8 +13,6 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
-       [KeptAttributeAttribute (typeof (IgnoreTestCaseAttribute), By = Tool.Trimmer)]
        [ExpectedNoWarnings]
 
        [SetupCompileBefore ("base.dll", new[] { "Dependencies/MemberTypesAllBaseTypeAssembly.cs" })]
@@ -67,7 +65,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow
        [KeptTypeInAssembly ("base.dll", "Mono.Linker.Tests.Cases.DataFlow.Dependencies.MemberTypesAllBaseType/PrivateNestedType")]
        [KeptMemberInAssembly ("base.dll", "Mono.Linker.Tests.Cases.DataFlow.Dependencies.MemberTypesAllBaseType/PrivateNestedType", new string[] { "PrivateMethod()" })]
 
-       [KeptMember (".ctor()")]
+       // https://github.com/dotnet/runtime/issues/78752
+       [KeptMember (".ctor()", By = Tool.Trimmer)]
        public class MemberTypesAllOnCopyAssembly
        {
                public static void Main ()
index 207152b82030d313881b8e3dec4032e5af4ae7d4..b4ca654728bff1b3e83d14a6c62913aaa7451928 100644 (file)
@@ -11,7 +11,6 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
        [SkipKeptItemsValidation]
        [ExpectedNoWarnings]
        class MethodByRefParameterDataFlow
@@ -202,11 +201,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicFields)]
                        static ref Type GetTypeRefWithMethodsAndFields () { throw null; }
 
-                       [ExpectedWarning ("IL2067", "t", "InnerMethodWithDam")]
-                       [ExpectedWarning ("IL2067", "tWithMethodsAndFields", "InnerMethodWithDam")]
+                       [ExpectedWarning ("IL2067", "'t'", "InnerMethodWithDam")]
+                       [ExpectedWarning ("IL2067", "'tWithMethodsAndFields'", "InnerMethodWithDam")]
                        [ExpectedWarning ("IL2072", nameof (GetTypeRefWithoutAnnotations), "InnerMethodWithDam")]
                        [ExpectedWarning ("IL2068", nameof (GetTypeRefWithMethodsAndFields), "InnerMethodWithDam")]
-                       static void MethodWithLocaMethodWithDam (Type t, [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type tWithMethods, [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicFields)] Type tWithMethodsAndFields)
+                       static void MethodWithLocalMethodWithDam (Type t, [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type tWithMethods, [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods | DynamicallyAccessedMemberTypes.PublicFields)] Type tWithMethodsAndFields)
                        {
                                // 2067
                                InnerMethodWithDam (ref t);
@@ -233,7 +232,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
 
                        public static void Test ()
                        {
-                               MethodWithLocaMethodWithDam (null, null, null);
+                               MethodWithLocalMethodWithDam (null, null, null);
                        }
                }
 
index d81811826260dde70d1262f65184257c05df8db1..348df96e99b076643ac45c05f47c2845376f2e11 100644 (file)
@@ -10,8 +10,6 @@ using DAMT = System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
-       [KeptAttributeAttribute (typeof (IgnoreTestCaseAttribute), By = Tool.Trimmer)]
        [ExpectedNoWarnings]
        [KeptPrivateImplementationDetails ("ThrowSwitchExpressionException")]
        [KeptAttributeAttribute (typeof (UnconditionalSuppressMessageAttribute))]
@@ -301,7 +299,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
 
                [Kept]
                // https://github.com/dotnet/linker/issues/2755
-               [ExpectedWarning ("IL2075", "GetFields", ProducedBy = Tool.Trimmer)]
+               [ExpectedWarning ("IL2075", "GetFields", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                static void MakeGenericTypeWithKnowAndUnknownArray (Type[] unknownTypes = null, int p = 0)
                {
                        Type[] types = p switch {
index 1d8509978f1b192cc3ffd6b5790d26bb9f57bdf3..1c3713e274b62b8b3ad38f38c7c1d7431cc67497 100644 (file)
@@ -9,7 +9,6 @@ using Mono.Linker.Tests.Cases.Expectations.Helpers;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
        // Note: this test's goal is to validate that the product correctly reports unrecognized patterns
        //   - so the main validation is done by the ExpectedWarning attributes.
        [SkipKeptItemsValidation]
@@ -273,7 +272,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        // Analyzer doesn't try to detect backing fields of properties: https://github.com/dotnet/linker/issues/2273
                        [ExpectedWarning ("IL2042",
                                "Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow.TestAutomaticPropagationType.PropertyWithDifferentBackingFields",
-                               ProducedBy = Tool.Trimmer)]
+                               ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        [ExpectedWarning ("IL2078",
                                nameof (TestAutomaticPropagationType) + "." + nameof (PropertyWithDifferentBackingFields) + ".get",
                                "Type",
@@ -282,7 +281,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        Type PropertyWithDifferentBackingFields {
                                [ExpectedWarning ("IL2078",
                                        nameof (TestAutomaticPropagationType) + "." + nameof (PropertyWithDifferentBackingFields) + ".get",
-                                       ProducedBy = Tool.Trimmer)]
+                                       ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                get {
                                        return PropertyWithDifferentBackingFields_GetterField;
                                }
@@ -300,7 +299,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
 
                        // Analyzer doesn't try to detect backing fields of properties: https://github.com/dotnet/linker/issues/2273
                        [ExpectedWarning ("IL2056", "PropertyWithExistingAttributes", "PropertyWithExistingAttributes_Field",
-                               ProducedBy = Tool.Trimmer)]
+                               ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
                        [CompilerGenerated]
                        Type PropertyWithExistingAttributes_Field;
@@ -311,13 +310,13 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        Type PropertyWithExistingAttributes {
                                // On property/accessor mismatch, ILLink warns on accessor and analyzer warns on property https://github.com/dotnet/linker/issues/2654
                                [ExpectedWarning ("IL2043", "PropertyWithExistingAttributes", "PropertyWithExistingAttributes.get",
-                                       ProducedBy = Tool.Trimmer)]
+                                       ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
                                get { return PropertyWithExistingAttributes_Field; }
 
                                // On property/accessor mismatch, ILLink warns on accessor and analyzer warns on property https://github.com/dotnet/linker/issues/2654
                                [ExpectedWarning ("IL2043", "PropertyWithExistingAttributes", "PropertyWithExistingAttributes.set",
-                                       ProducedBy = Tool.Trimmer)]
+                                       ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                [param: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
                                set { PropertyWithExistingAttributes_Field = value; }
                        }
@@ -338,7 +337,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
 
                        // Analyzer doesn't try to detect backing fields of properties: https://github.com/dotnet/linker/issues/2273
                        [ExpectedWarning ("IL2056", "PropertyWithConflictingAttributes", "PropertyWithConflictingAttributes_Field",
-                               ProducedBy = Tool.Trimmer)]
+                               ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicConstructors)]
                        [CompilerGenerated]
                        Type PropertyWithConflictingAttributes_Field;
@@ -349,13 +348,13 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        Type PropertyWithConflictingAttributes {
                                // On property/accessor mismatch, ILLink warns on accessor and analyzer warns on property https://github.com/dotnet/linker/issues/2654
                                [ExpectedWarning ("IL2043", "PropertyWithConflictingAttributes", "PropertyWithConflictingAttributes.get",
-                                       ProducedBy = Tool.Trimmer)]
+                                       ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicConstructors)]
                                get { return PropertyWithConflictingAttributes_Field; }
 
                                // On property/accessor mismatch, ILLink warns on accessor and analyzer warns on property https://github.com/dotnet/linker/issues/2654
                                [ExpectedWarning ("IL2043", "PropertyWithConflictingAttributes", "PropertyWithConflictingAttributes.set",
-                                       ProducedBy = Tool.Trimmer)]
+                                       ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                [param: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicConstructors)]
                                set { PropertyWithConflictingAttributes_Field = value; }
                        }
@@ -399,7 +398,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        // Trimmer and analyzer handle formatting of indexers differently.
-                       [ExpectedWarning ("IL2067", nameof (PropertyWithIndexer) + ".Item.set", ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2067", nameof (PropertyWithIndexer) + ".Item.set", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        [ExpectedWarning ("IL2067", nameof (PropertyWithIndexer) + ".this[Int32].set", ProducedBy = Tool.Analyzer)]
                        [ExpectedWarning ("IL2072", nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresNonPublicConstructors) + "(Type)")]
                        [LogDoesNotContain ("'Value passed to parameter 'index' of method 'Mono.Linker.Tests.Cases.DataFlow.PropertyDataFlow.TestAutomaticPropagationType.PropertyWithIndexer.Item.set'")]
@@ -418,7 +417,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                                [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)]
                                public Type this[int index] {
                                        // Trimmer and analyzer handle formatting of indexers differently.
-                                       [ExpectedWarning ("IL2063", nameof (PropertyWithIndexer) + ".Item.get", ProducedBy = Tool.Trimmer)]
+                                       [ExpectedWarning ("IL2063", nameof (PropertyWithIndexer) + ".Item.get", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                        [ExpectedWarning ("IL2063", nameof (PropertyWithIndexer) + ".this[Int32].get", ProducedBy = Tool.Analyzer)]
                                        get => Property_Field[index];
                                        set => Property_Field[index] = value;
@@ -483,7 +482,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
 
                        // Analyzer doesn't warn about compiler-generated backing field of property: https://github.com/dotnet/linker/issues/2731
                        [ExpectedWarning ("IL2074", nameof (WriteToGetOnlyProperty), nameof (GetUnknownType),
-                               ProducedBy = Tool.Trimmer)]
+                               ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        public WriteToGetOnlyProperty ()
                        {
                                GetOnlyProperty = GetUnknownType ();
@@ -551,9 +550,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow
 
                        // Analyzer doesn't warn about compiler-generated backing field of property: https://github.com/dotnet/linker/issues/2731
                        [ExpectedWarning ("IL2074", nameof (WriteCapturedGetOnlyProperty), nameof (GetUnknownType),
-                               ProducedBy = Tool.Trimmer)]
+                               ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        [ExpectedWarning ("IL2074", nameof (WriteCapturedGetOnlyProperty), nameof (GetTypeWithPublicConstructors),
-                               ProducedBy = Tool.Trimmer)]
+                               ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        public WriteCapturedGetOnlyProperty ()
                        {
                                GetOnlyProperty = GetUnknownType () ?? GetTypeWithPublicConstructors ();
@@ -666,14 +665,14 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        }
 
                        [ExpectedWarning ("IL2072", "this[Index].get", nameof (DataFlowTypeExtensions.RequiresAll), ProducedBy = Tool.Analyzer)]
-                       [ExpectedWarning ("IL2072", "Item.get", nameof (DataFlowTypeExtensions.RequiresAll), ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2072", "Item.get", nameof (DataFlowTypeExtensions.RequiresAll), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestRead (ExplicitIndexerAccess instance = null)
                        {
                                instance[new Index (1)].RequiresAll ();
                        }
 
                        [ExpectedWarning ("IL2072", nameof (GetTypeWithPublicConstructors), "this[Index].set", ProducedBy = Tool.Analyzer)]
-                       [ExpectedWarning ("IL2072", nameof (GetTypeWithPublicConstructors), "Item.set", ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2072", nameof (GetTypeWithPublicConstructors), "Item.set", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestWrite (ExplicitIndexerAccess instance = null)
                        {
                                instance[^1] = GetTypeWithPublicConstructors ();
@@ -697,21 +696,21 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        int Length => throw new NotImplementedException ();
 
                        [ExpectedWarning ("IL2072", "this[Int32].get", nameof (DataFlowTypeExtensions.RequiresAll), ProducedBy = Tool.Analyzer)]
-                       [ExpectedWarning ("IL2072", "Item.get", nameof (DataFlowTypeExtensions.RequiresAll), ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2072", "Item.get", nameof (DataFlowTypeExtensions.RequiresAll), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestRead (ImplicitIndexerAccess instance = null)
                        {
                                instance[new Index (1)].RequiresAll ();
                        }
 
                        [ExpectedWarning ("IL2072", nameof (GetTypeWithPublicConstructors), "this[Int32].set", ProducedBy = Tool.Analyzer)]
-                       [ExpectedWarning ("IL2072", nameof (GetTypeWithPublicConstructors), "Item.set", ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2072", nameof (GetTypeWithPublicConstructors), "Item.set", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestWrite (ImplicitIndexerAccess instance = null)
                        {
                                instance[^1] = GetTypeWithPublicConstructors ();
                        }
 
                        [ExpectedWarning ("IL2072", nameof (GetUnknownType), "this[Int32].set", ProducedBy = Tool.Analyzer)]
-                       [ExpectedWarning ("IL2072", nameof (GetUnknownType), "Item.set", ProducedBy = Tool.Trimmer)]
+                       [ExpectedWarning ("IL2072", nameof (GetUnknownType), "Item.set", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                        static void TestNullCoalescingAssignment (ImplicitIndexerAccess instance = null)
                        {
                                instance[new Index (1)] ??= GetUnknownType ();
@@ -736,7 +735,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                                        }
 
                                        [ExpectedWarning ("IL2067", "this[Type].get", nameof (ParamDoesNotMeetRequirements), ProducedBy = Tool.Analyzer)]
-                                       [ExpectedWarning ("IL2067", "Item.get", nameof (ParamDoesNotMeetRequirements), ProducedBy = Tool.Trimmer)]
+                                       [ExpectedWarning ("IL2067", "Item.get", nameof (ParamDoesNotMeetRequirements), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                        static void ParamDoesNotMeetRequirements (Type t)
                                        {
                                                var x = new IndexWithTypeWithDam ();
@@ -750,7 +749,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                                        }
 
                                        [ExpectedWarning ("IL2087", "this[Type].get", nameof (TypeParamDoesNotMeetRequirements), ProducedBy = Tool.Analyzer)]
-                                       [ExpectedWarning ("IL2087", "Item.get", nameof (TypeParamDoesNotMeetRequirements), ProducedBy = Tool.Trimmer)]
+                                       [ExpectedWarning ("IL2087", "Item.get", nameof (TypeParamDoesNotMeetRequirements), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                        static void TypeParamDoesNotMeetRequirements<T> ()
                                        {
                                                var x = new IndexWithTypeWithDam ();
@@ -791,7 +790,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                                static Type fieldWithMethods;
 
                                [ExpectedWarning ("IL2067", "this[Type].get", nameof (ParamDoesNotMeetRequirements), ProducedBy = Tool.Analyzer)]
-                               [ExpectedWarning ("IL2067", "Item.get", nameof (ParamDoesNotMeetRequirements), ProducedBy = Tool.Trimmer)]
+                               [ExpectedWarning ("IL2067", "Item.get", nameof (ParamDoesNotMeetRequirements), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                static void ParamDoesNotMeetRequirements (Type t)
                                {
                                        var x = new IndexWithTypeWithDam ();
@@ -805,7 +804,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                                }
 
                                [ExpectedWarning ("IL2087", "this[Type].get", nameof (TypeParamDoesNotMeetRequirements), ProducedBy = Tool.Analyzer)]
-                               [ExpectedWarning ("IL2087", "Item.get", nameof (TypeParamDoesNotMeetRequirements), ProducedBy = Tool.Trimmer)]
+                               [ExpectedWarning ("IL2087", "Item.get", nameof (TypeParamDoesNotMeetRequirements), ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                static void TypeParamDoesNotMeetRequirements<T> ()
                                {
                                        var x = new IndexWithTypeWithDam ();
@@ -828,7 +827,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                                }
 
                                [ExpectedWarning ("IL2067", "this[Type].set", nameof (t), "idx", ProducedBy = Tool.Analyzer)]
-                               [ExpectedWarning ("IL2067", "Item.set", nameof (t), "idx", ProducedBy = Tool.Trimmer)]
+                               [ExpectedWarning ("IL2067", "Item.set", nameof (t), "idx", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                static void ValueMeetsRequirementsIndexDoesNot (Type t)
                                {
                                        var x = new IndexWithTypeWithDam ();
@@ -836,7 +835,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                                }
 
                                [ExpectedWarning ("IL2067", "this[Type].set", nameof (tUnannotated), "value", ProducedBy = Tool.Analyzer)]
-                               [ExpectedWarning ("IL2067", "Item.set", nameof (tUnannotated), "value", ProducedBy = Tool.Trimmer)]
+                               [ExpectedWarning ("IL2067", "Item.set", nameof (tUnannotated), "value", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                                static void ValueDoesNotMeetRequirementsIndexDoes ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] Type t, Type tUnannotated)
                                {
                                        var x = new IndexWithTypeWithDam ();
index 9db1b0e571b8584981ac17594d757061b1d9d2f3..fdedee546baddada8468682cfdbf3f6fb0c2d043 100644 (file)
@@ -11,17 +11,16 @@ using DAMT = System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
        [SkipKeptItemsValidation]
        [ExpectedNoWarnings]
        class RefFieldDataFlow
        {
                [Kept]
-               // Bug for the IL2069's here: https://github.com/dotnet/linker/issues/2874
-               [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer)]
+               // Bug for the IL2069's here: https://github.com/dotnet/runtime/issues/85464
+               [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2069", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                public static void Main ()
                {
                        RefFieldWithMethods withMethods = new (ref fieldWithMethods);
@@ -100,11 +99,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                        tmf = typeof (TF); // This is a hole that doesn't warn but assigns a misannotated value to target.T
                }
 
-               [ExpectedWarning ("IL2089", "RefFieldWithMethods", "T", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2089", "RefFieldWithFields", "T", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2089", "RefFieldWithMethodsAndFields", "T", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2089", "RefFieldWithMethodsAndFields", "T", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2089", "RefFieldWithFields", "T", ProducedBy = Tool.Trimmer)]
+               [ExpectedWarning ("IL2089", "RefFieldWithMethods", "T", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2089", "RefFieldWithFields", "T", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2089", "RefFieldWithMethodsAndFields", "T", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2089", "RefFieldWithMethodsAndFields", "T", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2089", "RefFieldWithFields", "T", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                static void AssignRefLocals<
                        T,
                        [DAM (DAMT.PublicMethods)] TM,
@@ -178,13 +177,13 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                [ExpectedWarning ("IL2069", "RefFieldWithMethods.T", "paramWithFields")]
                [ExpectedWarning ("IL2077", "paramWithMethodsAndFields", "RefFieldWithMethods.T")]
                // ILLink doesn't recognize ldind.ref
-               // https://github.com/dotnet/linker/issues/2943
+               // https://github.com/dotnet/runtime/issues/85465
                // IL2064's are bugs - shouldn't be unknown values
-               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer)]
-               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer)]
+               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
+               [ExpectedWarning ("IL2064", ProducedBy = Tool.Trimmer | Tool.NativeAot)]
                [ExpectedWarning ("IL2069", "RefFieldWithMethods.T", "param", ProducedBy = Tool.Analyzer)]
                [ExpectedWarning ("IL2069", "RefFieldWithMethods.T", "paramWithFields", ProducedBy = Tool.Analyzer)]
                static void AssignRefParameters<
@@ -240,12 +239,12 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                [ExpectedWarning ("IL2079", "RefFieldWithMethods.T", "RefFieldUnannotated.T", ProducedBy = Tool.Analyzer)]
                [ExpectedWarning ("IL2079", "RefFieldWithMethods.T", "RefFieldWithFields.T", ProducedBy = Tool.Analyzer)]
                // IL2064's are bugs - shouldn't be unknown values
-               // https://github.com/dotnet/linker/issues/2943
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = unannotated.T;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = withMethods.T;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = withFields.T;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = withMethodsAndFields.T;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = withMethodsAndFields.T;
+               // https://github.com/dotnet/runtime/issues/85465
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = unannotated.T;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = withMethods.T;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = withFields.T;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = withMethodsAndFields.T;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = withMethodsAndFields.T;
                static void AssignRefFields (
                        RefFieldWithMethods target,
                        RefFieldUnannotated unannotated,
@@ -272,11 +271,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                [ExpectedWarning ("IL2074", "RefFieldWithMethods.T", "GetRefUnannotated", ProducedBy = Tool.Analyzer)]
                [ExpectedWarning ("IL2074", "RefFieldWithMethods.T", "GetRefWithFields", ProducedBy = Tool.Analyzer)]
                // IL2064's are bugs - shouldn't be unknown values
-               // https://github.com/dotnet/linker/issues/2943
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = t;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = t;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = t;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = t;
+               // https://github.com/dotnet/runtime/issues/85465
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = t;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = t;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = t;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = t;
                static void AssignRefReturns<
                        T,
                        [DAM (DAMT.PublicMethods)] TM,
@@ -362,16 +361,16 @@ namespace Mono.Linker.Tests.Cases.DataFlow
                [ExpectedWarning ("IL2074", "RefFieldWithMethods.T", "RefPropWithFields.T")]
                // ref Type t = ref x.T; target.T = t;
                // IL2064's are bugs - shouldn't be unknown values
-               // https://github.com/dotnet/linker/issues/2943
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = unannotated.T;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = withMethods.T;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = withFields.T;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = withMethodsAndFieldswithMtho.T;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = withMethods.T;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = t;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = t;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = t;
-               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer)] // target.T = t;
+               // https://github.com/dotnet/runtime/issues/85465
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = unannotated.T;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = withMethods.T;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = withFields.T;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = withMethodsAndFieldswithMtho.T;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = withMethods.T;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = t;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = t;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = t;
+               [ExpectedWarning ("IL2064", "RefFieldWithMethods.T", ProducedBy = Tool.Trimmer | Tool.NativeAot)] // target.T = t;
                static void AssignRefProperties (RefFieldWithMethods target,
                        RefPropUnannotated unannotated = null,
                        RefPropWithMethods withMethods = null,
index 5aa1aece4f3133d0d1bc47477a2c4f15b14ef932..2f922940a3d7395c11167b395191ef1075959918 100644 (file)
@@ -9,8 +9,7 @@ using Mono.Linker.Tests.Cases.Expectations.Assertions;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
-       [KeptAttributeAttribute (typeof (IgnoreTestCaseAttribute), By = Tool.Trimmer)]
+       [ExpectedNoWarnings]
        public class StaticInterfaceMethodDataflow
        {
                [Kept]
index 21a848df98b7c85b17a15bb0adb2e83610490918..6213816a58a4d9533aab68cbb6089e2e2699812e 100644 (file)
@@ -12,7 +12,6 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata;
 
 namespace Mono.Linker.Tests.Cases.DataFlow
 {
-       [IgnoreTestCase ("Ignore in NativeAOT, see https://github.com/dotnet/runtime/issues/82447", IgnoredBy = Tool.NativeAot)]
        // Note: this test's goal is to validate that the product correctly reports unrecognized patterns
        //   - so the main validation is done by the ExpectedWarning attributes.
        [SkipKeptItemsValidation]
index 75db763733993ec1ae083d5a9856339ff159a2ad..da049f3ab4968d07e4a4df0ea18b1c853fa4397b 100644 (file)
@@ -203,7 +203,7 @@ namespace Mono.Linker.Tests.Cases.DynamicDependencies
                [KeptMember (".ctor()")]
                private abstract class AbstractMethods
                {
-                       [Kept (By = Tool.Trimmer)] // NativeAOT test infra doesn't check reflection-only methods (without entry point) yet
+                       [Kept]
                        [DynamicDependency (nameof (TargetMethod))]
                        public abstract void SourceAbstractViaReflection ();
 
index bf6f717a0519f42c6abc98c3037a81262101cf21..9b9e7130e41a2974fa6e96d37ade8adbe633165f 100644 (file)
@@ -7,6 +7,9 @@ using Mono.Linker.Tests.Cases.Warnings.Dependencies;
 
 namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression
 {
+       // https://github.com/dotnet/runtime/issues/82447
+       [IgnoreTestCase ("NativeAOT doesn't support suppressing warnings via XML", IgnoredBy = Tool.NativeAot)]
+       [KeptAttributeAttribute(typeof(IgnoreTestCaseAttribute))]
        [TestCaseRequirements (TestRunCharacteristics.TargetingNetCore, "This test is specific to .NET Core")]
        // For netcoreapp we don't have to specify the assembly for the attribute, since the attribute comes from corelib
        // and will be found always.