From 6a787f26be8c95a6c742d628acf0c0678d8122e3 Mon Sep 17 00:00:00 2001 From: Vitek Karas <10670590+vitek-karas@users.noreply.github.com> Date: Wed, 8 Dec 2021 15:19:15 +0100 Subject: Add test for wrong warning in MakeGenericType annotation mismatch (#2429) Test for #2428 --- .../DataFlow/GenericParameterDataFlow.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/Mono.Linker.Tests.Cases/DataFlow') diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs index a765e85aa..1e2313f2a 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/GenericParameterDataFlow.cs @@ -764,7 +764,9 @@ namespace Mono.Linker.Tests.Cases.DataFlow TestWithRequirements (); TestWithRequirementsFromParam (null); + TestWithRequirementsFromParamWithMismatch (null); TestWithRequirementsFromGenericParam (); + TestWithRequirementsFromGenericParamWithMismatch (); TestWithNoRequirements (); TestWithNoRequirementsFromParam (null); @@ -843,6 +845,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow typeof (GenericWithPublicFieldsArgument<>).MakeGenericType (type); } + // https://github.com/dotnet/linker/issues/2428 + // [ExpectedWarning ("IL2071", "'T'")] + [ExpectedWarning ("IL2070", "'this'")] + static void TestWithRequirementsFromParamWithMismatch ( + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type) + { + typeof (GenericWithPublicFieldsArgument<>).MakeGenericType (type); + } + [RecognizedReflectionAccessPattern] static void TestWithRequirementsFromGenericParam< [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T> () @@ -850,6 +861,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow typeof (GenericWithPublicFieldsArgument<>).MakeGenericType (typeof (T)); } + // https://github.com/dotnet/linker/issues/2428 + // [ExpectedWarning ("IL2091", "'T'")] + [ExpectedWarning ("IL2090", "'this'")] // Note that this actually produces a warning which should not be possible to produce right now + static void TestWithRequirementsFromGenericParamWithMismatch< + [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] TInput> () + { + typeof (GenericWithPublicFieldsArgument<>).MakeGenericType (typeof (TInput)); + } + class GenericWithPublicFieldsArgument<[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicFields)] T> { } -- cgit v1.2.3