diff options
author | Tlakaelel Axayakatl Ceja <tlakaelel.ceja@microsoft.com> | 2020-12-03 22:28:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 22:28:31 +0300 |
commit | b24d0e663d5bf4772b0896e2bc3dab3391fae744 (patch) | |
tree | 10a6ddd24aef9c081ca0f87de879908b0931b49b /test/Mono.Linker.Tests.Cases/DataFlow | |
parent | 4ddaa381cb8b374ce07598250197dcfc728455c2 (diff) |
Roslyn analyzer improvements (#1622)
* Add supported diagnostics for when we use Url named argument
* Add support for Expected Warning
* Use single format for Resource file
* Dont execute test that used another diagnostic id that is not 2026
* Change formats in the linker for setters and getters to match C# format
* Use GetSignature in method instead of ToString()
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/DataFlow')
3 files changed, 25 insertions, 25 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs index 3a8fbe1ef..a28975088 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs @@ -45,11 +45,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow GetWithNonPublicMethods ().RequireThisNonPublicMethods (); } - [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "get_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisPublicMethods), new Type[] { }, + [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.PropertyRequireThisPublicMethods) + ".get", new Type[] { }, messageCode: "IL2075", message: new string[] { "Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.GetWithNonPublicMethods()", - "System.MethodThisDataFlowTypeTest.get_PropertyRequireThisPublicMethods()" })] - [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "get_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisNonPublicMethods), new Type[] { }, messageCode: "IL2075")] + "System.MethodThisDataFlowTypeTest.PropertyRequireThisPublicMethods.get" })] + [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.PropertyRequireThisNonPublicMethods) + ".get", new Type[] { }, messageCode: "IL2075")] static void PropagateToThisWithGetters () { _ = GetWithPublicMethods ().PropertyRequireThisPublicMethods; @@ -59,11 +59,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow _ = GetWithNonPublicMethods ().PropertyRequireThisNonPublicMethods; } - [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "set_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisPublicMethods), new Type[] { typeof (Object) }, + [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.PropertyRequireThisPublicMethods) + ".set", new Type[] { typeof (Object) }, messageCode: "IL2075", message: new string[] { "Mono.Linker.Tests.Cases.DataFlow.MethodThisDataFlow.GetWithNonPublicMethods()", - "System.MethodThisDataFlowTypeTest.set_PropertyRequireThisPublicMethods(Object)" })] - [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), "set_" + nameof (MethodThisDataFlowTypeTest.PropertyRequireThisNonPublicMethods), new Type[] { typeof (Object) }, messageCode: "IL2075")] + "System.MethodThisDataFlowTypeTest.PropertyRequireThisPublicMethods.set" })] + [UnrecognizedReflectionAccessPattern (typeof (MethodThisDataFlowTypeTest), nameof (MethodThisDataFlowTypeTest.PropertyRequireThisNonPublicMethods) + ".set", new Type[] { typeof (Object) }, messageCode: "IL2075")] static void PropagateToThisWithSetters () { GetWithPublicMethods ().PropertyRequireThisPublicMethods = null; diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs index d6ee5cab7..9a7fe468a 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs @@ -62,9 +62,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow RequireNothing (StaticPropertyWithPublicConstructor); } - [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (PropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")] - [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (PropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")] - [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (PropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")] + [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (PropertyWithPublicConstructor) + ".set", new Type[] { typeof (Type) }, messageCode: "IL2072")] + [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (PropertyWithPublicConstructor) + ".set", new Type[] { typeof (Type) }, messageCode: "IL2072")] + [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (PropertyWithPublicConstructor) + ".set", new Type[] { typeof (Type) }, messageCode: "IL2072")] private void WriteToInstanceProperty () { PropertyWithPublicConstructor = GetTypeWithPublicParameterlessConstructor (); @@ -73,9 +73,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow PropertyWithPublicConstructor = GetUnkownType (); } - [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (StaticPropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")] - [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (StaticPropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")] - [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "set_" + nameof (StaticPropertyWithPublicConstructor), new Type[] { typeof (Type) }, messageCode: "IL2072")] + [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (StaticPropertyWithPublicConstructor) + ".set", new Type[] { typeof (Type) }, messageCode: "IL2072")] + [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (StaticPropertyWithPublicConstructor) + ".set", new Type[] { typeof (Type) }, messageCode: "IL2072")] + [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (StaticPropertyWithPublicConstructor) + ".set", new Type[] { typeof (Type) }, messageCode: "IL2072")] private void WriteToStaticProperty () { StaticPropertyWithPublicConstructor = GetTypeWithPublicParameterlessConstructor (); @@ -109,7 +109,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow } [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (_fieldWithPublicConstructors), - messageCode: "IL2069", message: new string[] { "value", "set_" + nameof (PropertyPublicParameterlessConstructorWithExplicitAccessors), nameof (_fieldWithPublicConstructors) })] + messageCode: "IL2069", message: new string[] { "value", nameof (PropertyPublicParameterlessConstructorWithExplicitAccessors) + ".set", nameof (_fieldWithPublicConstructors) })] [param: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] set { _fieldWithPublicConstructors = value; @@ -117,10 +117,10 @@ namespace Mono.Linker.Tests.Cases.DataFlow } Type PropertyNonPublicConstructorsWithExplicitAccessors { - [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), "get_" + nameof (PropertyNonPublicConstructorsWithExplicitAccessors), + [UnrecognizedReflectionAccessPattern (typeof (PropertyDataFlow), nameof (PropertyNonPublicConstructorsWithExplicitAccessors) + ".get", new Type[] { }, returnType: typeof (Type), messageCode: "IL2078", message: new string[] { nameof (_fieldWithPublicConstructors), - "get_" + nameof (PropertyNonPublicConstructorsWithExplicitAccessors) + nameof (PropertyNonPublicConstructorsWithExplicitAccessors) + ".get" })] [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicConstructors)] get { @@ -148,7 +148,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow class TestAutomaticPropagationType { // Fully implicit property should work - [UnrecognizedReflectionAccessPattern (typeof (TestAutomaticPropagationType), "set_" + nameof (ImplicitProperty), new Type[] { typeof (Type) }, messageCode: "IL2072")] + [UnrecognizedReflectionAccessPattern (typeof (TestAutomaticPropagationType), nameof (ImplicitProperty) + ".set", new Type[] { typeof (Type) }, messageCode: "IL2072")] public void TestImplicitProperty () { RequirePublicConstructors (ImplicitProperty); @@ -174,7 +174,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)] static Type PropertyWithSimpleGetter { - [UnrecognizedReflectionAccessPattern (typeof (TestAutomaticPropagationType), "get_" + nameof (PropertyWithSimpleGetter), new Type[] { }, returnType: typeof (Type), messageCode: "IL2078")] + [UnrecognizedReflectionAccessPattern (typeof (TestAutomaticPropagationType), nameof (PropertyWithSimpleGetter) + ".get", new Type[] { }, returnType: typeof (Type), messageCode: "IL2078")] get { return PropertyWithSimpleGetter_Field; } @@ -257,11 +257,11 @@ namespace Mono.Linker.Tests.Cases.DataFlow [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)] Type PropertyWithExistingAttributes { - [ExpectedWarning ("IL2043", "PropertyWithExistingAttributes", "get_PropertyWithExistingAttributes")] + [ExpectedWarning ("IL2043", "PropertyWithExistingAttributes", "PropertyWithExistingAttributes.get")] [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)] get { return PropertyWithExistingAttributes_Field; } - [ExpectedWarning ("IL2043", "PropertyWithExistingAttributes", "set_PropertyWithExistingAttributes")] + [ExpectedWarning ("IL2043", "PropertyWithExistingAttributes", "PropertyWithExistingAttributes.set")] [param: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)] set { PropertyWithExistingAttributes_Field = value; } } diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs b/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs index 46801b241..6386f07d2 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/VirtualMethodHierarchyDataflowAnnotationValidation.cs @@ -251,13 +251,13 @@ namespace Mono.Linker.Tests.Cases.DataFlow // The warning is reported on the getter (or setter), which is not ideal, but it's probably good enough for now (we don't internally track annotations // on properties themselves, only on methods). [LogContains ( - "'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.get_PropertyBaseWithDerivedWithout()' " + - "don't match overridden return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.get_PropertyBaseWithDerivedWithout()'. " + + "'DynamicallyAccessedMemberTypes' in 'DynamicallyAccessedMembersAttribute' on the return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.DerivedClass.PropertyBaseWithDerivedWithout.get' " + + "don't match overridden return value of method 'Mono.Linker.Tests.Cases.DataFlow.VirtualMethodHierarchyDataflowAnnotationValidation.BaseClass.PropertyBaseWithDerivedWithout.get'. " + "All overridden members must have the same 'DynamicallyAccessedMembersAttribute' usage.")] public override Type PropertyBaseWithDerivedWithout { get; } - [LogDoesNotContain ("DerivedClass.get_PropertyBaseWithDerivedWith_")] - [LogDoesNotContain ("DerivedClass.set_PropertyBaseWithDerivedWith_")] + [LogDoesNotContain ("DerivedClass.PropertyBaseWithDerivedWith_.get")] + [LogDoesNotContain ("DerivedClass.PropertyBaseWithDerivedWith_.set")] [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] public override Type PropertyBaseWithDerivedWith_ { get; set; } @@ -536,8 +536,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow public void GenericInterfaceBaseWithImplementationWithout<T> () { } // === Properties === - [LogContains ("ImplementationClass.get_PropertyInterfaceBaseWithoutImplementationWith")] - [LogContains ("ImplementationClass.set_PropertyInterfaceBaseWithoutImplementationWith")] + [LogContains ("ImplementationClass.PropertyInterfaceBaseWithoutImplementationWith.get")] + [LogContains ("ImplementationClass.PropertyInterfaceBaseWithoutImplementationWith.set")] [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] public Type PropertyInterfaceBaseWithoutImplementationWith { get; set; } |