From c812c2d52f0ffdfb41c11c62d1cd1ef777078599 Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Thu, 23 Feb 2023 17:02:51 -0800 Subject: [PATCH 1/3] Fix missing changes in from ProducedBy enum change --- .../Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs | 6 +++--- .../aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs | 2 +- .../TestCasesRunner/TestCaseCompilationMetadataProvider.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs index bfc580234b2ef6..08ebc461a201c0 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs @@ -1195,7 +1195,7 @@ private static IEnumerable GetActiveKeptAttributes (ICustomAttr } object? keptBy = ca.GetPropertyValue (nameof (KeptAttribute.By)); - return keptBy is null ? true : ((ProducedBy) keptBy).HasFlag (ProducedBy.NativeAot); + return keptBy is null ? true : ((Tool) keptBy).HasFlag (Tool.NativeAot); }); } @@ -1210,9 +1210,9 @@ private static IEnumerable GetActiveKeptDerivedAttributes (ICus if (!ca.AttributeType.Resolve ().DerivesFrom (nameof (KeptAttribute))) { return false; } - + object? keptBy = ca.GetPropertyValue (nameof (KeptAttribute.By)); - return keptBy is null ? true : ((ProducedBy) keptBy).HasFlag (ProducedBy.NativeAot); + return keptBy is null ? true : ((Tool) keptBy).HasFlag (Tool.NativeAot); }); } diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs index f7db7fcf288cd7..c62ecb479b06e8 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs @@ -168,7 +168,7 @@ protected virtual void AdditionalChecking (ILCompilerTestCaseResult linkResult, private static bool IsProducedByNativeAOT (CustomAttribute attr) { var producedBy = attr.GetPropertyValue ("ProducedBy"); - return producedBy is null ? true : ((ProducedBy) producedBy).HasFlag (ProducedBy.NativeAot); + return producedBy is null ? true : ((Tool) producedBy).HasFlag (Tool.NativeAot); } private static IEnumerable GetAttributeProviders (AssemblyDefinition assembly) diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs index b1246cf12f2a72..d3e9fbc047b94d 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs @@ -29,7 +29,7 @@ public TestCaseCompilationMetadataProvider (TestCase testCase, AssemblyDefinitio private static bool IsIgnoredByNativeAOT (CustomAttribute attr) { var ignoredBy = attr.GetPropertyValue ("IgnoredBy"); - return ignoredBy is null ? true : ((ProducedBy) ignoredBy).HasFlag (ProducedBy.NativeAot); + return ignoredBy is null ? true : ((Tool) ignoredBy).HasFlag (Tool.NativeAot); } public virtual bool IsIgnored ([NotNullWhen(true)] out string? reason) From 813c46054452aa4fca36f37ef6e5c7b64f3ac33b Mon Sep 17 00:00:00 2001 From: Tlakollo Date: Thu, 23 Feb 2023 17:34:16 -0800 Subject: [PATCH 2/3] Run lint in modified files --- .../Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs | 6 +++--- .../aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs | 2 +- .../TestCasesRunner/TestCaseCompilationMetadataProvider.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs index 08ebc461a201c0..b2ef8520914794 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs @@ -175,8 +175,8 @@ void AddType (TypeDesc type) if (typeDef.IsDelegate) { // AOT's handling of delegates is very different from the IL/metadata picture // So to simplify this, we're going to automatically "mark" all of the delegate's methods - foreach (MethodDesc m in typeDef.GetMethods()) { - if (ShouldIncludeEntityByDisplayName(m)) { + foreach (MethodDesc m in typeDef.GetMethods ()) { + if (ShouldIncludeEntityByDisplayName (m)) { AddMember (m); } } @@ -1210,7 +1210,7 @@ private static IEnumerable GetActiveKeptDerivedAttributes (ICus if (!ca.AttributeType.Resolve ().DerivesFrom (nameof (KeptAttribute))) { return false; } - + object? keptBy = ca.GetPropertyValue (nameof (KeptAttribute.By)); return keptBy is null ? true : ((Tool) keptBy).HasFlag (Tool.NativeAot); }); diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs index c62ecb479b06e8..4d694b7ae0061c 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs @@ -405,7 +405,7 @@ static bool LogMessageHasSameOriginMember (MessageContainer mc, ICustomAttribute var actualOriginToken = new AssemblyQualifiedToken (origin.Value.MemberDefinition); var expectedOriginToken = new AssemblyQualifiedToken (expectedOriginMember); - if (actualOriginToken.Equals(expectedOriginToken)) + if (actualOriginToken.Equals (expectedOriginToken)) return true; var actualMember = origin.Value.MemberDefinition; diff --git a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs index d3e9fbc047b94d..e97a51a5c2c737 100644 --- a/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs +++ b/src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/TestCaseCompilationMetadataProvider.cs @@ -32,10 +32,10 @@ private static bool IsIgnoredByNativeAOT (CustomAttribute attr) return ignoredBy is null ? true : ((Tool) ignoredBy).HasFlag (Tool.NativeAot); } - public virtual bool IsIgnored ([NotNullWhen(true)] out string? reason) + public virtual bool IsIgnored ([NotNullWhen (true)] out string? reason) { var ignoreAttribute = _testCaseTypeDefinition.CustomAttributes.FirstOrDefault (attr => attr.AttributeType.Name == nameof (IgnoreTestCaseAttribute)); - if (ignoreAttribute != null && IsIgnoredByNativeAOT(ignoreAttribute)) { + if (ignoreAttribute != null && IsIgnoredByNativeAOT (ignoreAttribute)) { if (ignoreAttribute.ConstructorArguments.Count == 1) { reason = (string) ignoreAttribute.ConstructorArguments.First ().Value; return true; From 0cb5ee89b9120e560048c5c5742c2d539d5f897b Mon Sep 17 00:00:00 2001 From: tlakollo Date: Thu, 23 Feb 2023 22:02:36 -0800 Subject: [PATCH 3/3] Modify test that was part of a ifdef statement --- .../DynamicDependencies/DynamicDependencyMethod.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMethod.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMethod.cs index 5a935bd55b980e..75db763733993e 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMethod.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DynamicDependencies/DynamicDependencyMethod.cs @@ -203,7 +203,7 @@ public static void Test () [KeptMember (".ctor()")] private abstract class AbstractMethods { - [Kept (By = ProducedBy.Trimmer)] // NativeAOT test infra doesn't check reflection-only methods (without entry point) yet + [Kept (By = Tool.Trimmer)] // NativeAOT test infra doesn't check reflection-only methods (without entry point) yet [DynamicDependency (nameof (TargetMethod))] public abstract void SourceAbstractViaReflection ();