Skip to content

Commit

Permalink
Don't use unbound generic type for virtual hidden this parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Feb 28, 2023
1 parent ca113e4 commit e27b6e8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/AsmResolver.DotNet/Collections/ParameterCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,24 @@ private void UpdateParameterTypes()

private TypeSignature? GetThisParameterType()
{
if (_owner.DeclaringType is null)
var declaringType = _owner.DeclaringType;
if (declaringType is null)
return null;

var result = _owner.DeclaringType.ToTypeSignature();
if (_owner.DeclaringType.IsValueType)
TypeSignature result;
if (declaringType.GenericParameters.Count > 0)
{
var genArgs = new TypeSignature[declaringType.GenericParameters.Count];
for (int i = 0; i < genArgs.Length; i++)
genArgs[i] = new GenericParameterSignature(_owner.Module, GenericParameterType.Type, i);
result = declaringType.MakeGenericInstanceType(genArgs);
}
else
{
result = declaringType.ToTypeSignature();
}

if (declaringType.IsValueType)
result = result.MakeByReferenceType();

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public GenericParameterSignature(GenericParameterType parameterType, int index)
/// <param name="module">The module in which this generic parameter signature resides.</param>
/// <param name="parameterType">Indicates the parameter signature is declared by a type or a method.</param>
/// <param name="index">The index of the referenced parameter.</param>
public GenericParameterSignature(ModuleDefinition module, GenericParameterType parameterType, int index)
public GenericParameterSignature(ModuleDefinition? module, GenericParameterType parameterType, int index)
{
Scope = module;
ParameterType = parameterType;
Expand Down

0 comments on commit e27b6e8

Please sign in to comment.