mirror of
https://github.com/LukeFZ/Il2CppInspectorRedux.git
synced 2026-01-04 01:29:39 +05:00
Model: Handle C# method hiding ('new' keyword in method declarations)
This commit is contained in:
@@ -21,5 +21,8 @@ namespace Il2CppInspector.Reflection
|
|||||||
public ConstructorInfo(Il2CppInspector pkg, int methodIndex, TypeInfo declaringType) : base(pkg, methodIndex, declaringType) { }
|
public ConstructorInfo(Il2CppInspector pkg, int methodIndex, TypeInfo declaringType) : base(pkg, methodIndex, declaringType) { }
|
||||||
|
|
||||||
public override string ToString() => DeclaringType.Name + "(" + string.Join(", ", DeclaredParameters.Select(x => x.ParameterType.Name)) + ")";
|
public override string ToString() => DeclaringType.Name + "(" + string.Join(", ", DeclaredParameters.Select(x => x.ParameterType.Name)) + ")";
|
||||||
|
|
||||||
|
public override string GetSignatureString() => Name + GetTypeParametersString()
|
||||||
|
+ "(" + string.Join(",", DeclaredParameters.Select(x => x.GetSignatureString())) + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,6 +149,12 @@ namespace Il2CppInspector.Reflection
|
|||||||
if ((Attributes & MethodAttributes.PinvokeImpl) != 0)
|
if ((Attributes & MethodAttributes.PinvokeImpl) != 0)
|
||||||
modifiers.Append("extern ");
|
modifiers.Append("extern ");
|
||||||
|
|
||||||
|
// Method hiding
|
||||||
|
if ((DeclaringType.BaseType?.GetAllMethods().Any(m => m.GetSignatureString() == GetSignatureString() && m.IsHideBySig) ?? false)
|
||||||
|
&& (((Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.ReuseSlot && !IsVirtual)
|
||||||
|
|| (Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot))
|
||||||
|
modifiers.Append($"new ");
|
||||||
|
|
||||||
if (Name == "op_Implicit")
|
if (Name == "op_Implicit")
|
||||||
modifiers.Append("implicit ");
|
modifiers.Append("implicit ");
|
||||||
if (Name == "op_Explicit")
|
if (Name == "op_Explicit")
|
||||||
@@ -164,6 +170,8 @@ namespace Il2CppInspector.Reflection
|
|||||||
public string GetTypeParametersString() => GenericTypeParameters == null? "" :
|
public string GetTypeParametersString() => GenericTypeParameters == null? "" :
|
||||||
"<" + string.Join(", ", GenericTypeParameters.Select(p => p.CSharpName)) + ">";
|
"<" + string.Join(", ", GenericTypeParameters.Select(p => p.CSharpName)) + ">";
|
||||||
|
|
||||||
|
public abstract string GetSignatureString();
|
||||||
|
|
||||||
// List of operator overload metadata names
|
// List of operator overload metadata names
|
||||||
// https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/operator-overloads
|
// https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/operator-overloads
|
||||||
public static Dictionary<string, string> OperatorMethodNames = new Dictionary<string, string> {
|
public static Dictionary<string, string> OperatorMethodNames = new Dictionary<string, string> {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace Il2CppInspector.Reflection
|
|||||||
// TODO: Generic arguments (and on ConstructorInfo)
|
// TODO: Generic arguments (and on ConstructorInfo)
|
||||||
public override string ToString() => ReturnType.Name + " " + Name + "(" + string.Join(", ", DeclaredParameters.Select(x => x.ParameterType.Name)) + ")";
|
public override string ToString() => ReturnType.Name + " " + Name + "(" + string.Join(", ", DeclaredParameters.Select(x => x.ParameterType.Name)) + ")";
|
||||||
|
|
||||||
public string GetSignatureString() => ReturnParameter.GetSignatureString() + " " + Name + GetTypeParametersString()
|
public override string GetSignatureString() => ReturnParameter.GetSignatureString() + " " + Name + GetTypeParametersString()
|
||||||
+ "(" + string.Join(",", DeclaredParameters.Select(x => x.GetSignatureString())) + ")";
|
+ "(" + string.Join(",", DeclaredParameters.Select(x => x.GetSignatureString())) + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user