Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitek Karas <vitek.karas@microsoft.com>2021-06-01 23:47:47 +0300
committerGitHub <noreply@github.com>2021-06-01 23:47:47 +0300
commit54f4827313384e43bfd15c7ec6a45b6fa76090c3 (patch)
tree9cc3732f2f437268b0aab86adb7e10f49ef649c5 /test/Mono.Linker.Tests.Cases
parentbff5d8b55adb71afd0f132b9e15646787b07b879 (diff)
Type get type generic annotation test (#2071)
Add a test that if a gener parameter has annotation and the type with that parameter is referenced via `Type.GetType`, the annotation gets applied. There is already a test for `string` data flow handling in `ApplyTypeAnnotations.TestFromConstantWithGeneric`, but there was no test for `Type.GetType` (which uses slightly different codepath in the product).
Diffstat (limited to 'test/Mono.Linker.Tests.Cases')
-rw-r--r--test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs b/test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs
index be5ab3118..1907cd653 100644
--- a/test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs
+++ b/test/Mono.Linker.Tests.Cases/Reflection/TypeUsedViaReflection.cs
@@ -41,6 +41,7 @@ namespace Mono.Linker.Tests.Cases.Reflection
TestInvalidTypeName ();
TestUnkownIgnoreCase3Params (1);
TestUnkownIgnoreCase5Params (1);
+ TestGenericTypeWithAnnotations ();
}
[Kept]
@@ -382,5 +383,31 @@ namespace Mono.Linker.Tests.Cases.Reflection
bool unknownValue = num + 1 == 1;
var typeKept = Type.GetType (reflectionTypeKeptString, AssemblyResolver, GetTypeFromAssembly, false, unknownValue);
}
+
+ [Kept]
+ public class GenericTypeWithAnnotations_OuterType<
+ [KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.NonPublicProperties)] T>
+ {
+ }
+
+ [Kept]
+ public class GenericTypeWithAnnotations_InnerType
+ {
+ [Kept]
+ [KeptBackingField]
+ private static bool PrivateProperty { [Kept] get; [Kept] set; }
+
+ private static void PrivateMethod () { }
+ }
+
+ [Kept]
+ static void TestGenericTypeWithAnnotations ()
+ {
+ const string reflectionTypeKeptString = "Mono.Linker.Tests.Cases.Reflection.TypeUsedViaReflection+GenericTypeWithAnnotations_OuterType`1" +
+ "[[Mono.Linker.Tests.Cases.Reflection.TypeUsedViaReflection+GenericTypeWithAnnotations_InnerType, test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]," +
+ " test, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null";
+ Type.GetType (reflectionTypeKeptString);
+ }
}
}