[release/6.0] [mono] Support RuntimeType.MakeGenericType with non-RuntimeType element...
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sat, 28 Aug 2021 08:08:08 +0000 (10:08 +0200)
committerGitHub <noreply@github.com>
Sat, 28 Aug 2021 08:08:08 +0000 (10:08 +0200)
Co-authored-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
src/libraries/System.Runtime/tests/System/Type/TypeTests.cs
src/mono/System.Private.CoreLib/src/System/RuntimeType.Mono.cs

index f8816f1..a749e93 100644 (file)
@@ -923,6 +923,16 @@ namespace System.Tests
             Assert.True(!typeof(ContextBoundClass).IsContextful);
         }
 
+        [Fact]
+        public void MakeGenericType_NonRuntimeType()
+        {
+            foreach (Type nonRuntimeType in Helpers.NonRuntimeTypes)
+            {
+                Type t = typeof(List<>).MakeGenericType(nonRuntimeType);
+                Assert.NotNull(t);
+            }
+        }
+
 #region GetInterfaceMap tests
         public static IEnumerable<object[]> GetInterfaceMap_TestData()
         {
index 2d0a4b9..f6d349d 100644 (file)
@@ -1336,8 +1336,9 @@ namespace System
                     for (int iCopy = 0; iCopy < instantiation.Length; iCopy++)
                         instantiationCopy[iCopy] = instantiation[iCopy];
                     instantiation = instantiationCopy;
-
-                    throw new NotImplementedException();
+                    if (!RuntimeFeature.IsDynamicCodeSupported)
+                        throw new PlatformNotSupportedException();
+                    return System.Reflection.Emit.TypeBuilderInstantiation.MakeGenericType(this, instantiation);
                 }
 
                 instantiationRuntimeType[i] = rtInstantiationElem;