Skip to content
New issue

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

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

Already on GitHub? # to your account

Make Instruction.GetArgumentType consistent with ParameterList #521

Merged
merged 1 commit into from
Aug 5, 2023

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
2 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants