Implement proper generic parameter substitution

With this patch, generic parameters in BaseType and method param/return
types are substituted correctly and deeply. Next up will be to apply the
same substitution rules to fields, properties, events, ...
This commit is contained in:
Robert Xiao
2020-04-11 22:20:21 -07:00
committed by Katy
parent 202a802274
commit 1970879e52
3 changed files with 44 additions and 11 deletions

View File

@@ -110,14 +110,11 @@ namespace Il2CppInspector.Reflection
DefaultValueMetadataAddress = generic.DefaultValueMetadataAddress;
}
public ParameterInfo SubstituteGenericArguments(TypeInfo[] typeArguments, TypeInfo[] methodArguments) {
/* TODO: Deep substitution */
if (ParameterType.IsGenericTypeParameter)
return new ParameterInfo(this, typeArguments[ParameterType.GenericParameterPosition]);
else if (ParameterType.IsGenericMethodParameter)
return new ParameterInfo(this, methodArguments[ParameterType.GenericParameterPosition]);
else
public ParameterInfo SubstituteGenericArguments(TypeInfo[] typeArguments, TypeInfo[] methodArguments = null) {
TypeInfo t = ParameterType.SubstituteGenericArguments(typeArguments, methodArguments);
if (t == ParameterType)
return this;
return new ParameterInfo(this, t);
}
// ref will be handled as part of the type name