Skip to content

Commit

Permalink
Unify type instantiations in reflection emit (dotnet#81518)
Browse files Browse the repository at this point in the history
  • Loading branch information
buyaa-n authored Feb 20, 2023
1 parent 06dd126 commit f4ad730
Show file tree
Hide file tree
Showing 36 changed files with 999 additions and 2,666 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\DynamicMethod.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\ILGenerator.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\LocalBuilder.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\MethodBuilderInstantiation.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\ParameterBuilder.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\RuntimeAssemblyBuilder.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\RuntimeConstructorBuilder.cs" />
Expand All @@ -177,9 +176,6 @@
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\RuntimeTypeBuilder.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\SignatureHelper.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\SymbolMethod.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\SymbolType.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\TypeBuilderInstantiation.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\Emit\XXXOnTypeBuilderInstantiation.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\FieldInfo.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\LoaderAllocator.cs" />
<Compile Include="$(BclSourcesRoot)\System\Reflection\MdConstant.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,11 @@ private static MethodBase GetGenericMethodBaseDefinition(MethodBase methodBase)

if (methodBase is MethodOnTypeBuilderInstantiation motbi)
{
methDef = motbi.m_method;
methDef = motbi._method;
}
else if (methodBase is ConstructorOnTypeBuilderInstantiation cotbi)
{
methDef = cotbi.m_ctor;
methDef = cotbi._ctor;
}
else if (methodBase is MethodBuilder || methodBase is ConstructorBuilder)
{
Expand Down Expand Up @@ -445,15 +445,15 @@ internal SignatureHelper GetMemberRefSignature(MethodBase? method, int cGenericP
return methodBuilder.GetMethodSignature();
case RuntimeConstructorBuilder constructorBuilder:
return constructorBuilder.GetMethodSignature();
case MethodOnTypeBuilderInstantiation motbi when motbi.m_method is RuntimeMethodBuilder methodBuilder:
case MethodOnTypeBuilderInstantiation motbi when motbi._method is RuntimeMethodBuilder methodBuilder:
return methodBuilder.GetMethodSignature();
case MethodOnTypeBuilderInstantiation motbi:
method = motbi.m_method;
method = motbi._method;
break;
case ConstructorOnTypeBuilderInstantiation cotbi when cotbi.m_ctor is RuntimeConstructorBuilder constructorBuilder:
case ConstructorOnTypeBuilderInstantiation cotbi when cotbi._ctor is RuntimeConstructorBuilder constructorBuilder:
return constructorBuilder.GetMethodSignature();
case ConstructorOnTypeBuilderInstantiation cotbi:
method = cotbi.m_ctor;
method = cotbi._ctor;
break;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,5 @@ public abstract partial class MethodBase : MemberInfo

internal virtual ParameterInfo[] GetParametersNoCopy() { return GetParameters(); }
#endregion

#region Internal Methods
// helper method to construct the string representation of the parameter list

internal virtual Type[] GetParameterTypes()
{
ParameterInfo[] paramInfo = GetParametersNoCopy();
if (paramInfo.Length == 0)
{
return Type.EmptyTypes;
}

Type[] parameterTypes = new Type[paramInfo.Length];
for (int i = 0; i < paramInfo.Length; i++)
parameterTypes[i] = paramInfo[i].ParameterType;

return parameterTypes;
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -638,15 +638,19 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\AssemblyBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\AssemblyBuilderAccess.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\ConstructorBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\ConstructorOnTypeBuilderInstantiation.cs" Condition="'$(FeatureNativeAot)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\DynamicMethod.cs" Condition="'$(FeatureNativeAot)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\EmptyCAHolder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\EnumBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\EventBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\FieldBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\FieldOnTypeBuilderInstantiation.cs" Condition="'$(FeatureNativeAot)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\FlowControl.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\GenericTypeParameterBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\Label.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\MethodBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\MethodBuilderInstantiation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\MethodOnTypeBuilderInstantiation.cs" Condition="'$(FeatureNativeAot)' != 'true'" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\ModuleBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\Opcode.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\OpCodes.cs" />
Expand All @@ -656,7 +660,9 @@
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\PEFileKinds.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\PropertyBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\StackBehaviour.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\SymbolType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\TypeBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\TypeBuilderInstantiation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\Emit\TypeNameBuilder.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\EventAttributes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Reflection\EventInfo.cs" />
Expand Down
Loading

0 comments on commit f4ad730

Please sign in to comment.