diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/DependencyInjectionPattern.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/DependencyInjectionPattern.cs index d2e4dc87075404..d483bdebd3393c 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/DependencyInjectionPattern.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/DependencyInjectionPattern.cs @@ -3,8 +3,8 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using Mono.Linker.Tests.Cases.Expectations.Assertions; diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ExtensionMembersDataFlow.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ExtensionMembersDataFlow.cs index 9687375716d2db..f58f3d4036e290 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ExtensionMembersDataFlow.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/ExtensionMembersDataFlow.cs @@ -272,8 +272,8 @@ public Type ExtensionMembersPropertyConflict return ExtensionMembersDataFlow.GetWithFields(); } - [ExpectedWarning("IL2067", "left", nameof(DataFlowTypeExtensions.RequiresPublicMethods))] - [ExpectedWarning("IL2067", "right", nameof(DataFlowTypeExtensions.RequiresPublicMethods))] + [ExpectedWarning("IL2067", "left", nameof(DataFlowTypeExtensions.RequiresPublicMethods))] + [ExpectedWarning("IL2067", "right", nameof(DataFlowTypeExtensions.RequiresPublicMethods))] [ExpectedWarning("IL2073", nameof(ExtensionMembersDataFlow.GetWithMethods))] [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] public static Type operator -( diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs index c27537d9eeb6ac..5e43a8ad5c0997 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs @@ -874,7 +874,7 @@ public override void Param(Type t) { } public override Type Return() => typeof(int); } - public static void Test () + public static void Test() { // https://github.com/dotnet/linker/issues/3133 // Access the interfaces as well - otherwise NativeAOT can decide @@ -883,17 +883,17 @@ public static void Test () // which leads to some warnings not being generated. // The goal of this test is to validate the generated diagnostics // so we're forcing the checks to happen with this. - typeof (Library.IAnnotatedMethods).RequiresAll (); - typeof (Library.IUnannotatedMethods).RequiresAll (); - - typeof (ImplIUnannotatedMethodsMismatch).RequiresPublicMethods (); - typeof (ImplIAnnotatedMethodsMismatch).RequiresPublicMethods (); - typeof (DerivedFromAnnotatedMismatch).RequiresPublicMethods (); - typeof (DerivedFromUnannotatedMismatch).RequiresPublicMethods (); - typeof (ImplIUnannotatedMethodsMatch).RequiresPublicMethods (); - typeof (ImplIAnnotatedMethodsMatch).RequiresPublicMethods (); - typeof (DerivedFromAnnotatedMatch).RequiresPublicMethods (); - typeof (DerivedFromUnannotatedMatch).RequiresPublicMethods (); + typeof(Library.IAnnotatedMethods).RequiresAll(); + typeof(Library.IUnannotatedMethods).RequiresAll(); + + typeof(ImplIUnannotatedMethodsMismatch).RequiresPublicMethods(); + typeof(ImplIAnnotatedMethodsMismatch).RequiresPublicMethods(); + typeof(DerivedFromAnnotatedMismatch).RequiresPublicMethods(); + typeof(DerivedFromUnannotatedMismatch).RequiresPublicMethods(); + typeof(ImplIUnannotatedMethodsMatch).RequiresPublicMethods(); + typeof(ImplIAnnotatedMethodsMatch).RequiresPublicMethods(); + typeof(DerivedFromAnnotatedMatch).RequiresPublicMethods(); + typeof(DerivedFromUnannotatedMatch).RequiresPublicMethods(); } } @@ -904,57 +904,57 @@ class DirectCall { abstract class Base { - [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - public abstract Type NonGenericAbstract ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type); + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + public abstract Type NonGenericAbstract([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type type); - [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - public virtual Type NonGenericVirtual ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type) => type; + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + public virtual Type NonGenericVirtual([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type type) => type; - public abstract void GenericAbstract<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] T> (); + public abstract void GenericAbstract<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(); - public virtual void GenericVirtual<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] T> () { } + public virtual void GenericVirtual<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>() { } - public abstract Type UnannotatedAbstract (Type type); + public abstract Type UnannotatedAbstract(Type type); - public abstract void UnannotatedGenericAbstract (); + public abstract void UnannotatedGenericAbstract(); } class Derived : Base { - [ExpectedWarning ("IL2092")] - [ExpectedWarning ("IL2093")] - public override Type NonGenericAbstract ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] Type type) => null; + [ExpectedWarning("IL2092")] + [ExpectedWarning("IL2093")] + public override Type NonGenericAbstract([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type) => null; - [ExpectedWarning ("IL2092")] - [ExpectedWarning ("IL2093")] - [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] - public override Type NonGenericVirtual (Type type) => null; + [ExpectedWarning("IL2092")] + [ExpectedWarning("IL2093")] + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] + public override Type NonGenericVirtual(Type type) => null; - [ExpectedWarning ("IL2095")] - public override void GenericAbstract () { } + [ExpectedWarning("IL2095")] + public override void GenericAbstract() { } - [ExpectedWarning ("IL2095")] - public override void GenericVirtual<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] T> () { } + [ExpectedWarning("IL2095")] + public override void GenericVirtual<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>() { } - [ExpectedWarning ("IL2092")] - [ExpectedWarning ("IL2093")] - [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - public override Type UnannotatedAbstract ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] Type type) => null; + [ExpectedWarning("IL2092")] + [ExpectedWarning("IL2093")] + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + public override Type UnannotatedAbstract([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type) => null; - [ExpectedWarning ("IL2095")] - public override void UnannotatedGenericAbstract<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] T> () { } + [ExpectedWarning("IL2095")] + public override void UnannotatedGenericAbstract<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>() { } } interface IBaseWithDefault { - void DefaultMethod (Type type); + void DefaultMethod(Type type); } interface IDerivedWithDefault : IBaseWithDefault { - [ExpectedWarning ("IL2092")] - [UnexpectedWarning ("IL2092", Tool.Analyzer, "https://github.com/dotnet/linker/issues/3121")] - void IBaseWithDefault.DefaultMethod ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type) { } + [ExpectedWarning("IL2092")] + [UnexpectedWarning("IL2092", Tool.Analyzer, "https://github.com/dotnet/linker/issues/3121")] + void IBaseWithDefault.DefaultMethod([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type type) { } } class ImplDerivedWithDefault : IDerivedWithDefault @@ -963,67 +963,67 @@ class ImplDerivedWithDefault : IDerivedWithDefault interface IGvmBase { - Type UnannotatedGvm (Type type); - Type UnannotatedGvmCalledThroughBase (Type type); + Type UnannotatedGvm(Type type); + Type UnannotatedGvmCalledThroughBase(Type type); - [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - static abstract Type AnnotatedStaticGvm<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] T> ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] Type type); + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + static abstract Type AnnotatedStaticGvm<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type); - static virtual Type UnannotatedStaticGvm (Type type) => null; + static virtual Type UnannotatedStaticGvm(Type type) => null; } class ImplIGvmBase : IGvmBase { // NativeAOT doesn't validate overrides when it can resolve them as direct calls - [ExpectedWarning ("IL2092", Tool.Trimmer | Tool.Analyzer, "")] - [ExpectedWarning ("IL2093", Tool.Trimmer | Tool.Analyzer, "")] - [ExpectedWarning ("IL2095", Tool.Trimmer | Tool.Analyzer, "")] - [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - public Type UnannotatedGvm<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] T> ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type) => null; - - [ExpectedWarning ("IL2092")] - [ExpectedWarning ("IL2093")] - [ExpectedWarning ("IL2095")] - [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - public Type UnannotatedGvmCalledThroughBase<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] T> ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type) => null; - - [ExpectedWarning ("IL2092")] - [ExpectedWarning ("IL2093")] - [ExpectedWarning ("IL2095")] - public static Type AnnotatedStaticGvm (Type type) => null; - - [ExpectedWarning ("IL2092")] - [ExpectedWarning ("IL2093")] - [ExpectedWarning ("IL2095")] - [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - public static Type UnannotatedStaticGvm<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] T> ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicProperties)] Type type) => null; + [ExpectedWarning("IL2092", Tool.Trimmer | Tool.Analyzer, "")] + [ExpectedWarning("IL2093", Tool.Trimmer | Tool.Analyzer, "")] + [ExpectedWarning("IL2095", Tool.Trimmer | Tool.Analyzer, "")] + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + public Type UnannotatedGvm<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type type) => null; + + [ExpectedWarning("IL2092")] + [ExpectedWarning("IL2093")] + [ExpectedWarning("IL2095")] + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + public Type UnannotatedGvmCalledThroughBase<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] Type type) => null; + + [ExpectedWarning("IL2092")] + [ExpectedWarning("IL2093")] + [ExpectedWarning("IL2095")] + public static Type AnnotatedStaticGvm(Type type) => null; + + [ExpectedWarning("IL2092")] + [ExpectedWarning("IL2093")] + [ExpectedWarning("IL2095")] + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + public static Type UnannotatedStaticGvm<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type) => null; } - static void CallStaticGvm () where TGvmBase : IGvmBase + static void CallStaticGvm() where TGvmBase : IGvmBase { - TGvmBase.AnnotatedStaticGvm (typeof (string)); - TGvmBase.UnannotatedStaticGvm (typeof (string)); + TGvmBase.AnnotatedStaticGvm(typeof(string)); + TGvmBase.UnannotatedStaticGvm(typeof(string)); } - public static void Test () + public static void Test() { - Base instance = new Derived (); - instance.NonGenericAbstract (typeof (string)); - instance.NonGenericVirtual (typeof (string)); - instance.GenericAbstract (); - instance.GenericVirtual (); - instance.UnannotatedAbstract (typeof (string)); - instance.UnannotatedGenericAbstract (); + Base instance = new Derived(); + instance.NonGenericAbstract(typeof(string)); + instance.NonGenericVirtual(typeof(string)); + instance.GenericAbstract(); + instance.GenericVirtual(); + instance.UnannotatedAbstract(typeof(string)); + instance.UnannotatedGenericAbstract(); - ((IBaseWithDefault) (new ImplDerivedWithDefault ())).DefaultMethod (typeof (string)); + ((IBaseWithDefault)(new ImplDerivedWithDefault())).DefaultMethod(typeof(string)); - ImplIGvmBase impl = new ImplIGvmBase (); - impl.UnannotatedGvm (typeof (string)); + ImplIGvmBase impl = new ImplIGvmBase(); + impl.UnannotatedGvm(typeof(string)); - IGvmBase ibase = (IGvmBase) impl; - ibase.UnannotatedGvmCalledThroughBase (typeof (string)); + IGvmBase ibase = (IGvmBase)impl; + ibase.UnannotatedGvmCalledThroughBase(typeof(string)); - CallStaticGvm (); + CallStaticGvm(); } } @@ -1037,86 +1037,90 @@ class RequiresAndDynamicallyAccessedMembersValidation class BaseMethodWithRequires { - [RequiresUnreferencedCode (nameof (MethodWithRequires))] - [RequiresDynamicCode (nameof (MethodWithRequires))] - public virtual void MethodWithRequires ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] Type t) {} + [RequiresUnreferencedCode(nameof(MethodWithRequires))] + [RequiresDynamicCode(nameof(MethodWithRequires))] + public virtual void MethodWithRequires([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type t) { } } - [RequiresUnreferencedCode (nameof (DerivedTypeWithRequires_BaseMethodWithRequires))] - [RequiresDynamicCode (nameof (DerivedTypeWithRequires_BaseMethodWithRequires))] + [RequiresUnreferencedCode(nameof(DerivedTypeWithRequires_BaseMethodWithRequires))] + [RequiresDynamicCode(nameof(DerivedTypeWithRequires_BaseMethodWithRequires))] class DerivedTypeWithRequires_BaseMethodWithRequires : BaseMethodWithRequires { - public override void MethodWithRequires ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] Type t) {} + public override void MethodWithRequires([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type t) { } } - [ExpectedWarning ("IL2026", nameof (DerivedTypeWithRequires_BaseMethodWithRequires))] - [ExpectedWarning ("IL2026", nameof (DerivedTypeWithRequires_BaseMethodWithRequires.MethodWithRequires))] - [ExpectedWarning ("IL3050", nameof (DerivedTypeWithRequires_BaseMethodWithRequires), Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", nameof (DerivedTypeWithRequires_BaseMethodWithRequires.MethodWithRequires), Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - static void Test_DerivedTypeWithRequires_BaseMethodWithRequires () + [ExpectedWarning("IL2026", nameof(DerivedTypeWithRequires_BaseMethodWithRequires))] + [ExpectedWarning("IL2026", nameof(DerivedTypeWithRequires_BaseMethodWithRequires.MethodWithRequires))] + [ExpectedWarning("IL3050", nameof(DerivedTypeWithRequires_BaseMethodWithRequires), Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", nameof(DerivedTypeWithRequires_BaseMethodWithRequires.MethodWithRequires), Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + static void Test_DerivedTypeWithRequires_BaseMethodWithRequires() { - new DerivedTypeWithRequires_BaseMethodWithRequires ().MethodWithRequires (typeof (int)); + new DerivedTypeWithRequires_BaseMethodWithRequires().MethodWithRequires(typeof(int)); } class BaseMethodWithoutRequires { - public virtual void MethodWithoutRequires ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] Type t) {} + public virtual void MethodWithoutRequires([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type t) { } } - [RequiresUnreferencedCode (nameof (DerivedTypeWithRequires_BaseMethodWithoutRequires))] + [RequiresUnreferencedCode(nameof(DerivedTypeWithRequires_BaseMethodWithoutRequires))] class DerivedTypeWithRequires_BaseMethodWithoutRequires : BaseMethodWithoutRequires { - public override void MethodWithoutRequires ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] Type t) {} + public override void MethodWithoutRequires([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type t) { } } - [ExpectedWarning ("IL2026", nameof (DerivedTypeWithRequires_BaseMethodWithoutRequires))] - static void Test_DerivedTypeWithRequires_BaseMethodWithoutRequires () + [ExpectedWarning("IL2026", nameof(DerivedTypeWithRequires_BaseMethodWithoutRequires))] + static void Test_DerivedTypeWithRequires_BaseMethodWithoutRequires() { - new DerivedTypeWithRequires_BaseMethodWithoutRequires ().MethodWithoutRequires (typeof (int)); + new DerivedTypeWithRequires_BaseMethodWithoutRequires().MethodWithoutRequires(typeof(int)); } - public static void Test () + public static void Test() { - Test_DerivedTypeWithRequires_BaseMethodWithRequires (); - Test_DerivedTypeWithRequires_BaseMethodWithoutRequires (); + Test_DerivedTypeWithRequires_BaseMethodWithRequires(); + Test_DerivedTypeWithRequires_BaseMethodWithoutRequires(); } } class InstantiatedGeneric { - class GenericBase { - [ExpectedWarning ("IL2106")] - [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - public virtual T ReturnValue () => default; + class GenericBase + { + [ExpectedWarning("IL2106")] + [return: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + public virtual T ReturnValue() => default; } - class InstantiatedDerived : GenericBase { - public override Type ReturnValue () => null; + class InstantiatedDerived : GenericBase + { + public override Type ReturnValue() => null; } - public static void Test () + public static void Test() { - new InstantiatedDerived ().ReturnValue (); + new InstantiatedDerived().ReturnValue(); } } class AnnotationOnUnsupportedType { - class UnsupportedType { - [ExpectedWarning ("IL2041")] - [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] - public virtual void UnsupportedAnnotationMismatch () { } + class UnsupportedType + { + [ExpectedWarning("IL2041")] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] + public virtual void UnsupportedAnnotationMismatch() { } } - class DerivedUnsupportedType : UnsupportedType { - [ExpectedWarning ("IL2041")] - [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] - public override void UnsupportedAnnotationMismatch () { } + class DerivedUnsupportedType : UnsupportedType + { + [ExpectedWarning("IL2041")] + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] + public override void UnsupportedAnnotationMismatch() { } } - public static void Test () + public static void Test() { - new DerivedUnsupportedType ().UnsupportedAnnotationMismatch (); + new DerivedUnsupportedType().UnsupportedAnnotationMismatch(); } } } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeMap.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeMap.cs index 76ce4b0468abad..31f2a130202818 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeMap.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/Reflection/TypeMap.cs @@ -180,7 +180,7 @@ private static void CheckTrimTarget(object o) [Kept] private static UnboxedOnly Unbox(object o) { - return (UnboxedOnly) o; + return (UnboxedOnly)o; } [Kept] diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresExcludeStatics.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresExcludeStatics.cs index 513f0b01f3f448..da1008f16f5804 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresExcludeStatics.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresExcludeStatics.cs @@ -162,7 +162,7 @@ public static void Test() StaticMethod(); DerivedStaticMethod(); - // Instantiate for linker test consistency + // Instantiate for linker test consistency new DerivedWithoutRequires(); } } diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnAttribute.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnAttribute.cs index 6403bf09aa6957..b22b50370af4fd 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnAttribute.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnAttribute.cs @@ -64,18 +64,18 @@ public bool PropertyWhichRequires } } - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] class GenericTypeWithAttributedParameter<[AttributeWhichRequires] T> { - public static void TestMethod () { } + public static void TestMethod() { } } - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - static void GenericMethodWithAttributedParameter<[AttributeWhichRequires] T> () { } + [ExpectedWarning("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + static void GenericMethodWithAttributedParameter<[AttributeWhichRequires] T>() { } static void TestRequiresOnAttributeOnGenericParameter() { @@ -83,52 +83,52 @@ static void TestRequiresOnAttributeOnGenericParameter() GenericMethodWithAttributedParameter(); } - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] [AttributeWhichRequires] - [AttributeWhichRequiresOnProperty (PropertyWhichRequires = true)] + [AttributeWhichRequiresOnProperty(PropertyWhichRequires = true)] class TypeWithAttributeWhichRequires { } - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] [AttributeWhichRequires] - [AttributeWhichRequiresOnProperty (PropertyWhichRequires = true)] - static void MethodWithAttributeWhichRequires () { } - - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [AttributeWhichRequiresOnProperty(PropertyWhichRequires = true)] + static void MethodWithAttributeWhichRequires() { } + + [ExpectedWarning("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] [AttributeWhichRequires] - [AttributeWhichRequiresOnProperty (PropertyWhichRequires = true)] + [AttributeWhichRequiresOnProperty(PropertyWhichRequires = true)] static int _fieldWithAttributeWhichRequires; - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] - [UnexpectedWarning ("IL2026", "--AttributeWhichRequiresAttribute.ctor--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [UnexpectedWarning ("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [UnexpectedWarning ("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] - [ExpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")] - [UnexpectedWarning ("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] - [ExpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [UnexpectedWarning ("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] - [ExpectedWarning ("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [UnexpectedWarning ("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] + [ExpectedWarning("IL2026", "--AttributeWhichRequiresAttribute.ctor--")] + [UnexpectedWarning("IL2026", "--AttributeWhichRequiresAttribute.ctor--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [UnexpectedWarning("IL3002", "--AttributeWhichRequiresAttribute.ctor--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [UnexpectedWarning("IL3050", "--AttributeWhichRequiresAttribute.ctor--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] + [ExpectedWarning("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--")] + [UnexpectedWarning("IL2026", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] + [ExpectedWarning("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [UnexpectedWarning("IL3002", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] + [ExpectedWarning("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [UnexpectedWarning("IL3050", "--AttributeWhichRequiresOnPropertyAttribute.PropertyWhichRequires--", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/120004")] [AttributeWhichRequires] - [AttributeWhichRequiresOnProperty (PropertyWhichRequires = true)] + [AttributeWhichRequiresOnProperty(PropertyWhichRequires = true)] static bool PropertyWithAttributeWhichRequires { get; set; } [AttributeWhichRequires] @@ -138,12 +138,12 @@ static void MethodWithAttributeWhichRequires () { } [RequiresDynamicCode("--MethodWhichRequiresWithAttributeWhichRequires--")] static void MethodWhichRequiresWithAttributeWhichRequires() { } - [ExpectedWarning ("IL2026", "--MethodWhichRequiresWithAttributeWhichRequires--")] - [ExpectedWarning ("IL3002", "--MethodWhichRequiresWithAttributeWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - [ExpectedWarning ("IL3050", "--MethodWhichRequiresWithAttributeWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] - static void TestMethodWhichRequiresWithAttributeWhichRequires () + [ExpectedWarning("IL2026", "--MethodWhichRequiresWithAttributeWhichRequires--")] + [ExpectedWarning("IL3002", "--MethodWhichRequiresWithAttributeWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + [ExpectedWarning("IL3050", "--MethodWhichRequiresWithAttributeWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT-specific warning")] + static void TestMethodWhichRequiresWithAttributeWhichRequires() { - MethodWhichRequiresWithAttributeWhichRequires (); + MethodWhichRequiresWithAttributeWhichRequires(); } class RequiresTriggeredByAttributeUsage diff --git a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnBaseClass.cs b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnBaseClass.cs index 3c35f02e8c60de..942ece5d368828 100644 --- a/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnBaseClass.cs +++ b/src/tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresOnBaseClass.cs @@ -41,7 +41,7 @@ class DerivedFromBaseWithRDC : BaseWithRDC [ExpectedWarning("IL3050", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")] public DerivedFromBaseWithRDC() { } - + public static void StaticMethod() { } } diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs index e924f613003a72..383764e0aba9de 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/AssemblyChecker.cs @@ -265,7 +265,7 @@ protected virtual IEnumerable VerifyTypeDefinitionKept(TypeDefinition or foreach (var err in VerifyInterfaces(original, linked)) yield return err; - foreach (var err in VerifyPseudoAttributes(original, linked)) + foreach (var err in VerifyPseudoAttributes(original, linked)) yield return err; foreach (var err in VerifyGenericParameters(original, linked, skipKeptItemsValidation: false)) yield return err; diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs index 21abc94c9b4492..c185f0654e9b15 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/ResultChecker.cs @@ -4,12 +4,14 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; +using System.Data.Common; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; +using ILLink.Shared.TrimAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Linker; @@ -18,9 +20,7 @@ using Mono.Linker.Tests.Cases.Expectations.Metadata; using Mono.Linker.Tests.Extensions; using Mono.Linker.Tests.TestCasesRunner.ILVerification; -using ILLink.Shared.TrimAnalysis; using NUnit.Framework; -using System.Data.Common; namespace Mono.Linker.Tests.TestCasesRunner { diff --git a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs index c49ff27f38fc40..2d2c3fb74ec981 100644 --- a/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs +++ b/src/tools/illink/test/Mono.Linker.Tests/TestCasesRunner/TestRunner.cs @@ -5,8 +5,8 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using NUnit.Framework; using Mono.Linker.Tests.Extensions; +using NUnit.Framework; namespace Mono.Linker.Tests.TestCasesRunner { diff --git a/src/tools/illink/test/Trimming.Tests.Shared/AssemblyChecker.cs b/src/tools/illink/test/Trimming.Tests.Shared/AssemblyChecker.cs index 7f4ccb879b5559..3fff5a21a6ac5a 100644 --- a/src/tools/illink/test/Trimming.Tests.Shared/AssemblyChecker.cs +++ b/src/tools/illink/test/Trimming.Tests.Shared/AssemblyChecker.cs @@ -2,8 +2,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Mono.Cecil; -using Mono.Linker.Tests.Extensions; using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Extensions; namespace Mono.Linker.Tests.TestCasesRunner {