From 19dd46241c8271bfca970801450c2a86ac2b24f3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 29 Aug 2021 19:13:20 +0200 Subject: [PATCH] [release/6.0] [mono] Allow RuntimeType arguments in CustomAttributeBuilder (#58317) Co-authored-by: Ulrich Weigand --- .../tests/CustomAttributeBuilderTests.cs | 1 - .../src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs b/src/libraries/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs index 9c2df4249b3..0b536e51a94 100644 --- a/src/libraries/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs +++ b/src/libraries/System.Reflection.Emit.ILGeneration/tests/CustomAttributeBuilderTests.cs @@ -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]; diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs index 7f26920c5e5..a34ea706470 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.Mono.cs @@ -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!) { -- 2.34.1