Output: Move getParametersString into MethodBase/ParameterInfo
This commit is contained in:
@@ -224,7 +224,7 @@ namespace Il2CppInspector
|
||||
|
||||
foreach (var method in type.DeclaredConstructors) {
|
||||
writer.Write($"{prefix}\t{method.GetModifierString()}{method.DeclaringType.Name}(");
|
||||
writer.Write(getParametersString(method.DeclaredParameters));
|
||||
writer.Write(method.GetParametersString());
|
||||
writer.Write(");" + (method.VirtualAddress != 0 ? $" // {formatAddress(method.VirtualAddress)}" : "") + "\n");
|
||||
}
|
||||
if (type.DeclaredConstructors.Any())
|
||||
@@ -241,28 +241,10 @@ namespace Il2CppInspector
|
||||
writer.Write($"{method.ReturnType.CSharpName} {method.CSharpName}");
|
||||
else
|
||||
writer.Write($"{method.CSharpName}{method.ReturnType.CSharpName}");
|
||||
writer.Write("(" + getParametersString(method.DeclaredParameters));
|
||||
writer.Write("(" + method.GetParametersString());
|
||||
writer.Write(");" + (method.VirtualAddress != 0 ? $" // {formatAddress(method.VirtualAddress)}" : "") + "\n");
|
||||
}
|
||||
writer.Write(prefix + "}\n");
|
||||
}
|
||||
|
||||
// TODO: Move this info ParameterInfo
|
||||
private string getParametersString(List<ParameterInfo> @params) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
bool first = true;
|
||||
foreach (var param in @params) {
|
||||
if (!first)
|
||||
sb.Append(", ");
|
||||
first = false;
|
||||
if (param.IsOptional)
|
||||
sb.Append("optional ");
|
||||
if (param.IsOut)
|
||||
sb.Append("out ");
|
||||
sb.Append($"{param.ParameterType.CSharpName} {param.Name}");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
@@ -137,6 +138,10 @@ namespace Il2CppInspector.Reflection
|
||||
return modifiers.ToString();
|
||||
}
|
||||
|
||||
// Get C# syntax-friendly list of parameters
|
||||
public string GetParametersString() =>
|
||||
string.Join(", ", DeclaredParameters.Select(p => $"{p.GetModifierString()}{p.ParameterType.CSharpName} {p.Name}"));
|
||||
|
||||
// List of operator overload metadata names
|
||||
// https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/operator-overloads
|
||||
public static Dictionary<string, string> OperatorMethodNames = new Dictionary<string, string> {
|
||||
|
||||
@@ -69,5 +69,9 @@ namespace Il2CppInspector.Reflection
|
||||
|
||||
// TODO: DefaultValue/HasDefaultValue
|
||||
}
|
||||
|
||||
public string GetModifierString() =>
|
||||
(IsOptional? "optional " : "") +
|
||||
(IsOut? "out " : "");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user