[release/6.0] [mono] Allow RuntimeType arguments in CustomAttributeBuilder (#58317)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sun, 29 Aug 2021 17:13:20 +0000 (19:13 +0200)
committerGitHub <noreply@github.com>
Sun, 29 Aug 2021 17:13:20 +0000 (19:13 +0200)
Co-authored-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
src/libraries/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs

index 9c2df42..0b536e5 100644 (file)
@@ -255,7 +255,6 @@ namespace System.Reflection.Emit.Tests
         }
 
         [Fact]
-        [ActiveIssue("https://github.com/dotnet/runtime/issues/2383", TestRuntimes.Mono)]
         public static void Ctor_AllPrimitives()
         {
             ConstructorInfo con = typeof(Primitives).GetConstructors()[0];
index 7f26920..a34ea70 100644 (file)
@@ -123,7 +123,7 @@ namespace System.Reflection.Emit
                 // depends on this
                 Enum.GetUnderlyingType(t);
             }
-            if (t.IsClass && !(t.IsArray || t == typeof(object) || t == typeof(Type) || t == typeof(string) || t.Assembly.GetName().Name == "mscorlib"))
+            if (t.IsClass && !(t.IsArray || t == typeof(object) || typeof(Type).IsAssignableFrom(t) || t == typeof(string) || t.Assembly.GetName().Name == "mscorlib"))
                 return false;
             if (t.IsValueType && !(t.IsPrimitive || t.IsEnum || ((t.Assembly is AssemblyBuilder) && t.Assembly.GetName().Name == "mscorlib")))
                 return false;
@@ -149,7 +149,7 @@ namespace System.Reflection.Emit
         {
             if (type.IsValueType && value == null)
                 return false;
-            if (type.IsArray && type.GetElementType()!.IsValueType)
+            if (type.IsArray && type.GetElementType()!.IsValueType && value != null)
             {
                 foreach (object? v in (Array)value!)
                 {