diff options
author | Sven Boemer <sbomer@gmail.com> | 2022-02-16 16:56:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 16:56:37 +0300 |
commit | 663a3b7138d206cb9cb327c1f517131a0a2f3fba (patch) | |
tree | 7cabcec25eed28bc0fa8a5aa5cb2a5a46846ea24 /test/Mono.Linker.Tests.Cases | |
parent | f7e921c3e4394ac02f1edc89b89d6b28022b084c (diff) |
Produce unknown value for array access (#2600)
And fix invocations of GetValueUsageInfo
Diffstat (limited to 'test/Mono.Linker.Tests.Cases')
6 files changed, 17 insertions, 18 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs index 0a9cf094a..924cd2391 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/AssemblyQualifiedNameDataflow.cs @@ -20,6 +20,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow TestUnqualifiedTypeNameWarns (); TestNull (); TestMultipleValues (); + TestUnknownValue (); } [ExpectedWarning ("IL2072", nameof (RequirePublicConstructors))] @@ -70,8 +71,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow } [ExpectedWarning ("IL2072", nameof (RequirePublicConstructors), nameof (GetTypeWithNonPublicConstructors))] - // https://github.com/dotnet/linker/issues/2273 - [ExpectedWarning ("IL2062", nameof (RequirePublicConstructors), ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2062", nameof (RequirePublicConstructors))] static void TestMultipleValues (int p = 0, object[] o = null) { Type type = p switch { @@ -84,6 +84,14 @@ namespace Mono.Linker.Tests.Cases.DataFlow RequirePublicConstructors (type.AssemblyQualifiedName); } + [ExpectedWarning ("IL2062", nameof (RequirePublicConstructors))] + static void TestUnknownValue (object[] o = null) + { + string unknown = ((Type) o[0]).AssemblyQualifiedName; + RequirePublicConstructors (unknown); + RequireNothing (unknown); // shouldn't warn + } + private static void RequirePublicParameterlessConstructor ( [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string type) @@ -124,6 +132,5 @@ namespace Mono.Linker.Tests.Cases.DataFlow { return null; } - } } diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/FieldDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/FieldDataFlow.cs index 6b43547ff..4ce86b55a 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/FieldDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/FieldDataFlow.cs @@ -135,9 +135,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow TypeStore._staticTypeWithPublicParameterlessConstructor = GetUnknownType (); } - // TODO: warn about unknown types in analyzer: https://github.com/dotnet/linker/issues/2273 - [ExpectedWarning ("IL2064", nameof (TypeStore) + "." + nameof (TypeStore._staticTypeWithPublicParameterlessConstructor), - ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2064", nameof (TypeStore) + "." + nameof (TypeStore._staticTypeWithPublicParameterlessConstructor))] private void WriteUnknownValue () { var array = new object[1]; diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs index 489afbd82..405c66c4d 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodParametersDataFlow.cs @@ -165,8 +165,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow // Validate error message when untracable value is passed to an annotated parameter. [ExpectedWarning ("IL2062", nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresPublicParameterlessConstructor) + "(Type)", - "'type'", - ProducedBy = ProducedBy.Trimmer)] + "'type'")] private void UnknownValue () { var array = new object[1]; diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs index 362462ab3..c32206192 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodReturnParameterDataFlow.cs @@ -116,10 +116,8 @@ namespace Mono.Linker.Tests.Cases.DataFlow return publicConstructorsType; } - // TODO: https://github.com/dotnet/linker/issues/2273 [ExpectedWarning ("IL2063", - nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnUnknownValue) + "()", - ProducedBy = ProducedBy.Trimmer)] + nameof (MethodReturnParameterDataFlow) + "." + nameof (ReturnUnknownValue) + "()")] [return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)] Type ReturnUnknownValue () { diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs index cdb2e0a03..762d2c7c6 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/MethodThisDataFlow.cs @@ -90,10 +90,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow NonTypeType.StaticMethod (); } - // Analyer doesn't warn about unknown values flowing into annotated locations - // https://github.com/dotnet/linker/issues/2273 - [ExpectedWarning ("IL2065", nameof (MethodThisDataFlowTypeTest) + "." + nameof (MethodThisDataFlowTypeTest.RequireThisNonPublicMethods), "'this'", - ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2065", nameof (MethodThisDataFlowTypeTest) + "." + nameof (MethodThisDataFlowTypeTest.RequireThisNonPublicMethods), "'this'")] static void TestUnknownThis () { var array = new object[1]; diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs index bbc53a774..d15df0179 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs @@ -392,9 +392,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)] public Type this[int index] { - // TODO: warn about unknown types in analyzer: https://github.com/dotnet/linker/issues/2273 - [ExpectedWarning ("IL2063", "PropertyWithIndexer.Item.get", - ProducedBy = ProducedBy.Trimmer)] + // Trimmer and analyzer handle formatting of indexers differently. + [ExpectedWarning ("IL2063", nameof (PropertyWithIndexer) + ".Item.get", ProducedBy = ProducedBy.Trimmer)] + [ExpectedWarning ("IL2063", nameof (PropertyWithIndexer) + ".this[Int32].get", ProducedBy = ProducedBy.Analyzer)] get => Property_Field[index]; set => Property_Field[index] = value; } |