diff options
Diffstat (limited to 'test/Mono.Linker.Tests.Cases/DataFlow')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs | 20 | ||||
-rw-r--r-- | test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs | 60 |
2 files changed, 64 insertions, 16 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs index bb7a69ce9..51e71b970 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs @@ -98,7 +98,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow type = ReturnThingsWithPublicParameterlessConstructor (); } - [ExpectedWarning ("IL2072", "'type'", "argument", nameof (LongWriteToParameterOnInstanceMethod) + "(Int32,Int32,Int32,Int32,Type)", nameof (ReturnThingsWithPublicParameterlessConstructor))] + [ExpectedWarning ("IL2072", "'type'", "argument", nameof (LongWriteToParameterOnInstanceMethod) + "(Int32, Int32, Int32, Int32, Type)", nameof (ReturnThingsWithPublicParameterlessConstructor))] private void LongWriteToParameterOnInstanceMethod ( int a, int b, int c, int d, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)] @@ -107,7 +107,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow type = ReturnThingsWithPublicParameterlessConstructor (); } - [ExpectedWarning ("IL2072", "'type'", "argument", nameof (LongWriteToParameterOnStaticMethod) + "(Int32,Int32,Int32,Int32,Type)", nameof (ReturnThingsWithPublicParameterlessConstructor))] + [ExpectedWarning ("IL2072", "'type'", "argument", nameof (LongWriteToParameterOnStaticMethod) + "(Int32, Int32, Int32, Int32, Type)", nameof (ReturnThingsWithPublicParameterlessConstructor))] private static void LongWriteToParameterOnStaticMethod ( int a, int b, int c, int d, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicConstructors)] @@ -135,7 +135,12 @@ namespace Mono.Linker.Tests.Cases.DataFlow RequirePublicConstructors (type2); } - [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2067")] + // TODO: https://github.com/dotnet/linker/issues/2273 + // (Dataflow analysis is not supported by the analyzer yet) + [ExpectedWarning ("IL2067", + nameof (MethodParametersDataFlow) + "." + nameof (RequirePublicConstructors) + "(Type)", + "type", + ProducedBy = ProducedBy.Trimmer)] private void TwoAnnotatedParametersIntoOneValue ( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type type, @@ -156,8 +161,10 @@ namespace Mono.Linker.Tests.Cases.DataFlow } // Validate error message when untracable value is passed to an annotated parameter. - [UnrecognizedReflectionAccessPattern (typeof (MethodParametersDataFlow), nameof (RequirePublicParameterlessConstructor), new Type[] { typeof (Type) }, - messageCode: "IL2062", message: new string[] { "type", "RequirePublicParameterlessConstructor" })] + [ExpectedWarning ("IL2062", + nameof (MethodParametersDataFlow) + "." + nameof (RequirePublicParameterlessConstructor) + "(Type)", + "type", + ProducedBy = ProducedBy.Trimmer)] private void UnknownValue () { var array = new object[1]; @@ -190,7 +197,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow RequirePublicParameterlessConstructorAndNothing (typeof (TestType), this.GetType ()); } - [ExpectedWarning ("IL2098", "p1", nameof (UnsupportedParameterType))] + // TODO: https://github.com/dotnet/linker/issues/2273 + [ExpectedWarning ("IL2098", "p1", nameof (UnsupportedParameterType), ProducedBy = ProducedBy.Trimmer)] private void UnsupportedParameterType ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] object p1) { } diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs index 8dfe13492..65395c997 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs @@ -49,6 +49,12 @@ namespace Mono.Linker.Tests.Cases.DataFlow [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (ReturnPublicParameterlessConstructor), new Type[] { typeof (Type), typeof (Type), typeof (Type) }, returnType: typeof (Type), messageCode: "IL2068")] + // TODO: https://github.com/dotnet/linker/issues/2308 + // This warning should not be produced. + [ExpectedWarning ("IL2083", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnPublicParameterlessConstructor) + "(Type, Type, Type)", + "'this'", + ProducedBy = ProducedBy.Analyzer)] [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] Type ReturnPublicParameterlessConstructor ( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] @@ -125,9 +131,10 @@ namespace Mono.Linker.Tests.Cases.DataFlow return publicConstructorsType; } - [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (ReturnUnknownValue), - new Type[] { }, returnType: typeof (Type), - messageCode: "IL2063", message: new string[] { nameof (ReturnUnknownValue) })] + // TODO: https://github.com/dotnet/linker/issues/2273 + [ExpectedWarning ("IL2063", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnUnknownValue) + "()", + ProducedBy = ProducedBy.Trimmer)] [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)] Type ReturnUnknownValue () { @@ -141,8 +148,32 @@ namespace Mono.Linker.Tests.Cases.DataFlow } } - [UnrecognizedReflectionAccessPattern (typeof (DataFlowTypeExtensions), nameof (DataFlowTypeExtensions.RequiresPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")] - [UnrecognizedReflectionAccessPattern (typeof (DataFlowTypeExtensions), nameof (DataFlowTypeExtensions.RequiresNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")] + // These warnings require dataflow analysis which the analyzer doesn't have yet: https://github.com/dotnet/linker/issues/2273 + [ExpectedWarning ("IL2072", + nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresPublicConstructors) + "(Type)", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnPublicParameterlessConstructor) + "(Type, Type, Type)", + ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2072", + nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresNonPublicConstructors) + "(Type)", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnPublicParameterlessConstructor) + "(Type, Type, Type)", + ProducedBy = ProducedBy.Trimmer)] + // TODO: https://github.com/dotnet/linker/issues/2308 + // These warnings should not be produced. + [ExpectedWarning ("IL2082", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnPublicParameterlessConstructor) + "(Type, Type, Type)", + "'this'", + nameof (MethodReturnParameterDataFlow) + "." + nameof (PropagateReturnPublicParameterlessConstructor), + ProducedBy = ProducedBy.Analyzer)] + [ExpectedWarning ("IL2082", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnPublicParameterlessConstructor) + "(Type, Type, Type)", + "'this'", + nameof (MethodReturnParameterDataFlow) + "." + nameof (PropagateReturnPublicParameterlessConstructor), + ProducedBy = ProducedBy.Analyzer)] + [ExpectedWarning ("IL2082", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnPublicParameterlessConstructor) + "(Type, Type, Type)", + "'this'", + nameof (MethodReturnParameterDataFlow) + "." + nameof (PropagateReturnPublicParameterlessConstructor), + ProducedBy = ProducedBy.Analyzer)] void PropagateReturnPublicParameterlessConstructor () { Type t = ReturnPublicParameterlessConstructor (typeof (TestType), typeof (TestType), typeof (TestType)); @@ -152,8 +183,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow t.RequiresNone (); } - [UnrecognizedReflectionAccessPattern (typeof (DataFlowTypeExtensions), nameof (DataFlowTypeExtensions.RequiresPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")] - [UnrecognizedReflectionAccessPattern (typeof (DataFlowTypeExtensions), nameof (DataFlowTypeExtensions.RequiresNonPublicConstructors), new Type[] { typeof (Type) }, messageCode: "IL2072")] + // These warnings require dataflow analysis which the analyzer doesn't have yet: https://github.com/dotnet/linker/issues/2273 + [ExpectedWarning ("IL2072", + nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresPublicConstructors) + "(Type)", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnPublicParameterlessConstructorFromConstant) + "()", + ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2072", + nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresNonPublicConstructors) + "(Type)", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnPublicParameterlessConstructorFromConstant) + "()", + ProducedBy = ProducedBy.Trimmer)] void PropagateReturnPublicParameterlessConstructorFromConstant () { Type t = ReturnPublicParameterlessConstructorFromConstant (); @@ -183,15 +221,17 @@ namespace Mono.Linker.Tests.Cases.DataFlow // https://github.com/dotnet/linker/issues/2025 // Ideally this should not warn - [UnrecognizedReflectionAccessPattern (typeof (MethodReturnParameterDataFlow), nameof (ReturnWithRequirementsAlwaysThrows), new Type[] { }, returnType: typeof (Type), - messageCode: "IL2063")] + [ExpectedWarning ("IL2063", + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnWithRequirementsAlwaysThrows) + "()", + ProducedBy = ProducedBy.Trimmer)] [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type ReturnWithRequirementsAlwaysThrows () { throw new NotImplementedException (); } - [ExpectedWarning ("IL2106", nameof (UnsupportedReturnType))] + // TODO: https://github.com/dotnet/linker/issues/2273 + [ExpectedWarning ("IL2106", nameof (UnsupportedReturnType), ProducedBy = ProducedBy.Trimmer)] [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] static object UnsupportedReturnType () => null; |