Model: Substitute concrete parameter types into generic methods from MethodSpecs
This commit is contained in:
@@ -152,7 +152,14 @@ namespace Il2CppInspector.Reflection
|
|||||||
IsGenericMethod = true;
|
IsGenericMethod = true;
|
||||||
genericArguments = model.ResolveGenericArguments(spec.methodIndexIndex);
|
genericArguments = model.ResolveGenericArguments(spec.methodIndexIndex);
|
||||||
|
|
||||||
// TODO: Substitute generic type arguments for concrete type arguments
|
// Substitute matching generic type parameters with concrete type arguments
|
||||||
|
foreach (var p in methodDef.DeclaredParameters) {
|
||||||
|
if (!p.ParameterType.IsGenericMethodParameter)
|
||||||
|
DeclaredParameters.Add(p);
|
||||||
|
else
|
||||||
|
DeclaredParameters.Add(new ParameterInfo(model, p, genericArguments[p.ParameterType.GenericParameterPosition]));
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Populate VirtualAddress via Il2CppGenericMethodFunctionsDefinitions
|
// TODO: Populate VirtualAddress via Il2CppGenericMethodFunctionsDefinitions
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +226,7 @@ namespace Il2CppInspector.Reflection
|
|||||||
public string GetTypeParametersString(Scope usingScope) => !GetGenericArguments().Any()? "" :
|
public string GetTypeParametersString(Scope usingScope) => !GetGenericArguments().Any()? "" :
|
||||||
"<" + string.Join(", ", GetGenericArguments().Select(p => p.GetScopedCSharpName(usingScope))) + ">";
|
"<" + string.Join(", ", GetGenericArguments().Select(p => p.GetScopedCSharpName(usingScope))) + ">";
|
||||||
|
|
||||||
|
// TODO: The scope output for some System types does not match the real .NET output here
|
||||||
public string GetFullTypeParametersString() => !GetGenericArguments().Any()? "" :
|
public string GetFullTypeParametersString() => !GetGenericArguments().Any()? "" :
|
||||||
"[" + string.Join(",", GetGenericArguments().Select(p => p.FullName ?? p.Name)) + "]";
|
"[" + string.Join(",", GetGenericArguments().Select(p => p.FullName ?? p.Name)) + "]";
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,17 @@ namespace Il2CppInspector.Reflection
|
|||||||
|
|
||||||
// Create a concrete type parameter from a generic type parameter
|
// Create a concrete type parameter from a generic type parameter
|
||||||
public ParameterInfo(Il2CppModel model, ParameterInfo generic, TypeInfo concrete) {
|
public ParameterInfo(Il2CppModel model, ParameterInfo generic, TypeInfo concrete) {
|
||||||
// TODO: Implement generic parameter substitution
|
|
||||||
|
DeclaringMethod = generic.DeclaringMethod;
|
||||||
|
Name = generic.Name;
|
||||||
|
Position = generic.Position;
|
||||||
|
Attributes = generic.Attributes;
|
||||||
|
|
||||||
|
// TODO: Duplicate instances of 'concrete' may cause this search to fail. Replace with a straight lookup after eliminating GetTypeFromVirtualAddress
|
||||||
|
paramTypeReference = Array.IndexOf(model.TypesByReferenceIndex, concrete);
|
||||||
|
|
||||||
|
DefaultValue = generic.DefaultValue;
|
||||||
|
DefaultValueMetadataAddress = generic.DefaultValueMetadataAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ref will be handled as part of the type name
|
// ref will be handled as part of the type name
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Il2CppInspector;
|
|
||||||
|
|
||||||
namespace Il2CppTests.TestSources
|
namespace Il2CppTests.TestSources
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user