Skip to content

Commit

Permalink
Override IsByRefLike on S.R.E.*Builder classes (#34846)
Browse files Browse the repository at this point in the history
* Override IsByRefLike on S.R.E.*Builder classes

Fixes #8828

* Adds tests

* Update System.Reflection.Emit.Tests.csproj

* Bumping CI

* Update mono as well
  • Loading branch information
marcusturewicz authored Apr 20, 2020
1 parent a637d3e commit cfb1335
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 1 deletion.
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;

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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ public override bool IsAssignableFrom([NotNullWhen(true)] TypeInfo? typeInfo)
}

public override bool IsTypeDefinition => true;

public override bool IsByRefLike => false;
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ internal override bool IsUserType
return false;
}
}

public override bool IsByRefLike => false;
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,8 @@ private static void throw_argument_ConstantDoesntMatch()
}

public override bool IsTypeDefinition => true;

public override bool IsByRefLike => false;
}
}
#endif

0 comments on commit cfb1335

Please sign in to comment.