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:
authorJackson Schuster <36744439+jtschuster@users.noreply.github.com>2022-08-15 21:21:45 +0300
committerGitHub <noreply@github.com>2022-08-15 21:21:45 +0300
commit33c3b2c60d0a2006162a6326db853fe5415439bd (patch)
tree59315456ef4af467ca3a86deeda95ead21ed3b70
parentfda7b09fc005acb865deaf526c7adbb1be27a5f9 (diff)
Add MakeGenericMethod tests for static interface methods (#2962)
-rw-r--r--test/Mono.Linker.Tests.Cases/DataFlow/MakeGenericDataFlow.cs32
1 files changed, 31 insertions, 1 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/MakeGenericDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/MakeGenericDataFlow.cs
index 262e9b3f7..9e4df4cbc 100644
--- a/test/Mono.Linker.Tests.Cases/DataFlow/MakeGenericDataFlow.cs
+++ b/test/Mono.Linker.Tests.Cases/DataFlow/MakeGenericDataFlow.cs
@@ -351,6 +351,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow
TestWithMultipleArgumentsWithRequirements ();
+ StaticInterfaceMethods.Test ();
NewConstraint.Test ();
StructConstraint.Test ();
UnmanagedConstraint.Test ();
@@ -631,7 +632,6 @@ namespace Mono.Linker.Tests.Cases.DataFlow
.MakeGenericMethod (typeof (T));
}
-
static void TestWithRequirementsViaRuntimeMethod ()
{
typeof (MakeGenericMethod).GetRuntimeMethod (nameof (GenericWithRequirements), Type.EmptyTypes)
@@ -750,6 +750,36 @@ namespace Mono.Linker.Tests.Cases.DataFlow
{
}
+ class StaticInterfaceMethods
+ {
+ public static void Test ()
+ {
+ KnownType ();
+ UnannotatedGenericParam<int> ();
+ AnnotatedGenericParam<int> ();
+ }
+
+ static MethodInfo KnownType ()
+ => typeof (IFoo).GetMethod ("Method")
+ .MakeGenericMethod (new Type[] { typeof (int) });
+
+ [ExpectedWarning ("IL2090", "T", "PublicMethods")]
+ static MethodInfo UnannotatedGenericParam<T> ()
+ => typeof (IFoo).GetMethod ("Method")
+ .MakeGenericMethod (new Type[] { typeof (T) });
+
+ static MethodInfo AnnotatedGenericParam<
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] T> ()
+ => typeof (IFoo).GetMethod ("Method")
+ .MakeGenericMethod (new Type[] { typeof (T) });
+
+ interface IFoo
+ {
+ static abstract T Method<
+ [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] T> ();
+ }
+ }
+
class NewConstraint
{
static void GenericWithNewConstraint<T> () where T : new()