Skip to content

Conversation

ElektroKill
Copy link
Contributor

ParameterList created a GenericInstSig if declaring type is generic, while Instruction.GetArgumentType did not.

bool isValueType = methodDeclaringType.IsValueType;
ClassOrValueTypeSig instSig;
if (isValueType)
instSig = new ValueTypeSig(methodDeclaringType);
else
instSig = new ClassSig(methodDeclaringType);
TypeSig thisTypeSig;
if (methodDeclaringType.HasGenericParameters) {
int gpCount = methodDeclaringType.GenericParameters.Count;
var genArgs = new List<TypeSig>(gpCount);
for (int i = 0; i < gpCount; i++)
genArgs.Add(new GenericVar(i, methodDeclaringType));
thisTypeSig = new GenericInstSig(instSig, genArgs);
}
else
thisTypeSig = instSig;
hiddenThisParameter.Type = isValueType ? new ByRefSig(thisTypeSig) : thisTypeSig;

if (index == 0 && methodSig.ImplicitThis)
return declaringType?.IsValueType == true ? new ByRefSig(declaringType.ToTypeSig()) : declaringType.ToTypeSig();

if declaringType is TypeSpec we trust the user to provide the proper instantiated type!

@wtfsck wtfsck merged commit 6ab868a into 0xd4d:master Aug 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants