diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs index 4f58098617fdb..3b0e0350bf9df 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs @@ -91,6 +91,8 @@ public FieldBuilder DefineLiteral(string literalName, object? literalValue) public override Type? BaseType => m_typeBuilder.BaseType; + public override bool IsByRefLike => false; + protected override ConstructorInfo? GetConstructorImpl(BindingFlags bindingAttr, Binder? binder, CallingConventions callConvention, Type[] types, ParameterModifier[]? modifiers) { diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs index 547d160a66426..d0f930e4c763e 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs @@ -52,6 +52,8 @@ public override bool Equals(object? o) public override Module Module => m_type.Module; + public override bool IsByRefLike => false; + internal int MetadataTokenInternal => m_type.MetadataTokenInternal; #endregion diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs index f69d99e02a9ec..a78fd852c9799 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs @@ -721,6 +721,8 @@ public override string ToString() public override Module Module => GetModuleBuilder(); + public override bool IsByRefLike => false; + internal int MetadataTokenInternal => m_tdType.Token; #endregion diff --git a/src/libraries/System.Reflection.Emit/tests/EnumBuilder/EnumBuilder.Properties.Tests.cs b/src/libraries/System.Reflection.Emit/tests/EnumBuilder/EnumBuilder.Properties.Tests.cs index e13310eae5265..2e349c9c3184b 100644 --- a/src/libraries/System.Reflection.Emit/tests/EnumBuilder/EnumBuilder.Properties.Tests.cs +++ b/src/libraries/System.Reflection.Emit/tests/EnumBuilder/EnumBuilder.Properties.Tests.cs @@ -55,5 +55,12 @@ public void IsArray() Assert.True(arrType.IsArray); Assert.False(arrType.IsSZArray); } + + [Fact] + public void IsByRefLikeReturnsFalse() + { + EnumBuilder enumBuilder = Helpers.DynamicEnum(TypeAttributes.Public, typeof(int)); + Assert.False(enumBuilder.IsByRefLike); + } } } diff --git a/src/libraries/System.Reflection.Emit/tests/GenericTypeParameterBuilder/GenericTypeParameterBuilderIsByRefLike.cs b/src/libraries/System.Reflection.Emit/tests/GenericTypeParameterBuilder/GenericTypeParameterBuilderIsByRefLike.cs new file mode 100644 index 0000000000000..5274332d0c3eb --- /dev/null +++ b/src/libraries/System.Reflection.Emit/tests/GenericTypeParameterBuilder/GenericTypeParameterBuilderIsByRefLike.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Xunit; + +namespace System.Reflection.Emit.Tests +{ + public class GenericTypeParameterBuilderIsByRefLike + { + [Fact] + public void IsByRefLikeReturnsFalse() + { + TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public); + var typeParamNames = new string[] { "TFirst" }; + GenericTypeParameterBuilder[] typeParams = type.DefineGenericParameters(typeParamNames); + Assert.False(typeParams[0].IsByRefLike); + } + } +} diff --git a/src/libraries/System.Reflection.Emit/tests/System.Reflection.Emit.Tests.csproj b/src/libraries/System.Reflection.Emit/tests/System.Reflection.Emit.Tests.csproj index 651e9b6959c89..e5d46e991da82 100644 --- a/src/libraries/System.Reflection.Emit/tests/System.Reflection.Emit.Tests.csproj +++ b/src/libraries/System.Reflection.Emit/tests/System.Reflection.Emit.Tests.csproj @@ -25,6 +25,7 @@ + @@ -95,6 +96,7 @@ + @@ -111,4 +113,4 @@ - \ No newline at end of file + diff --git a/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderIsByRefLike.cs b/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderIsByRefLike.cs new file mode 100644 index 0000000000000..ab69a26c0bbd4 --- /dev/null +++ b/src/libraries/System.Reflection.Emit/tests/TypeBuilder/TypeBuilderIsByRefLike.cs @@ -0,0 +1,18 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Xunit; + +namespace System.Reflection.Emit.Tests +{ + public class TypeBuilderIsByRefLike + { + [Fact] + public void IsByRefLikeReturnsFalse() + { + TypeBuilder type = Helpers.DynamicType(TypeAttributes.Public); + Assert.False(type.IsByRefLike); + } + } +} diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.Mono.cs index ca53d05ed0e62..e1ae8c2983eb8 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.Mono.cs @@ -452,6 +452,8 @@ public override bool IsAssignableFrom([NotNullWhen(true)] TypeInfo? typeInfo) } public override bool IsTypeDefinition => true; + + public override bool IsByRefLike => false; } } #endif diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs index d9cb98d453e0a..04490cad975af 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs @@ -493,6 +493,8 @@ internal override bool IsUserType return false; } } + + public override bool IsByRefLike => false; } } #endif diff --git a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs index bccfb62b5d72e..ef8559975481f 100644 --- a/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs +++ b/src/mono/netcore/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs @@ -2042,6 +2042,8 @@ private static void throw_argument_ConstantDoesntMatch() } public override bool IsTypeDefinition => true; + + public override bool IsByRefLike => false; } } #endif