Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override IsByRefLike on S.R.E.*Builder classes #34846

Merged
merged 5 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public FieldBuilder DefineLiteral(string literalName, object? literalValue)

public override Type? BaseType => m_typeBuilder.BaseType;

public override bool IsByRefLike => false;
marcusturewicz marked this conversation as resolved.
Show resolved Hide resolved

protected override ConstructorInfo? GetConstructorImpl(BindingFlags bindingAttr, Binder? binder,
CallingConventions callConvention, Type[] types, ParameterModifier[]? modifiers)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<Compile Include="FieldBuilder\FieldBuilderSetOffset.cs" />
<Compile Include="GenericTypeParameterBuilder\GenericTyepParameterBuilderSetBaseTypeConstraint.cs" />
<Compile Include="GenericTypeParameterBuilder\GenericTypeParameterBuilderGUID.cs" />
<Compile Include="GenericTypeParameterBuilder\GenericTypeParameterBuilderIsByRefLike.cs" />
<Compile Include="GenericTypeParameterBuilder\GenericTypeParameterBuilderMakeArrayType.cs" />
<Compile Include="GenericTypeParameterBuilder\GenericTypeParameterBuilderMakeByRefType.cs" />
<Compile Include="GenericTypeParameterBuilder\GenericTypeParameterBuilderMakeGenericType.cs" />
Expand Down Expand Up @@ -95,6 +96,7 @@
<Compile Include="TypeBuilder\TypeBuilderGetGenericTypeDefinition.cs" />
<Compile Include="TypeBuilder\TypeBuilderGetMethod.cs" />
<Compile Include="TypeBuilder\TypeBuilderGUID.cs" />
<Compile Include="TypeBuilder\TypeBuilderIsByRefLike.cs" />
<Compile Include="TypeBuilder\TypeBuilderIsGenericParameter.cs" />
<Compile Include="TypeBuilder\TypeBuilderIsGenericType.cs" />
<Compile Include="TypeBuilder\TypeBuilderIsGenericTypeDefinition.cs" />
Expand All @@ -111,4 +113,4 @@
<Compile Include="TypeBuilder\TypeBuilderToString.cs" />
<Compile Include="Utilities.cs" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -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);
}
}
}