Output: Generate method bodies to populate out parameters (CS0117)
This commit is contained in:
@@ -430,8 +430,11 @@ namespace Il2CppInspector
|
|||||||
// User-defined conversion operator
|
// User-defined conversion operator
|
||||||
else
|
else
|
||||||
writer.Append($"{method.CSharpName}{method.ReturnType.GetScopedCSharpName(scope)}");
|
writer.Append($"{method.CSharpName}{method.ReturnType.GetScopedCSharpName(scope)}");
|
||||||
|
|
||||||
|
// Parameters
|
||||||
writer.Append("(" + method.GetParametersString(scope, !SuppressMetadata) + ")");
|
writer.Append("(" + method.GetParametersString(scope, !SuppressMetadata) + ")");
|
||||||
|
|
||||||
|
// Generic type constraints
|
||||||
if (method.GenericTypeParameters != null)
|
if (method.GenericTypeParameters != null)
|
||||||
foreach (var gp in method.GenericTypeParameters) {
|
foreach (var gp in method.GenericTypeParameters) {
|
||||||
var constraint = gp.GetTypeConstraintsString(scope);
|
var constraint = gp.GetTypeConstraintsString(scope);
|
||||||
@@ -439,6 +442,7 @@ namespace Il2CppInspector
|
|||||||
writer.Append($"\n{prefix}\t\t{constraint}");
|
writer.Append($"\n{prefix}\t\t{constraint}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Body
|
||||||
var methodBody = method switch {
|
var methodBody = method switch {
|
||||||
// Abstract method
|
// Abstract method
|
||||||
{ IsAbstract: true } => ";",
|
{ IsAbstract: true } => ";",
|
||||||
@@ -446,15 +450,20 @@ namespace Il2CppInspector
|
|||||||
// Extern method
|
// Extern method
|
||||||
{ Attributes: var a } when (a & MethodAttributes.PinvokeImpl) == MethodAttributes.PinvokeImpl => ";",
|
{ Attributes: var a } when (a & MethodAttributes.PinvokeImpl) == MethodAttributes.PinvokeImpl => ";",
|
||||||
|
|
||||||
|
// Method with out parameters
|
||||||
|
{ DeclaredParameters: var d } when d.Any(p => p.IsOut) =>
|
||||||
|
" {\n" + string.Join("\n", d.Where(p => p.IsOut).Select(p => $"{prefix}\t\t{p.Name} = default;"))
|
||||||
|
+ (method.ReturnType.FullName != "System.Void"? $"\n{prefix}\t\treturn default;" : "")
|
||||||
|
+ $"\n{prefix}\t}}",
|
||||||
|
|
||||||
// No return type
|
// No return type
|
||||||
{ ReturnType: var retType } when retType.FullName == "System.Void" => @" {}",
|
{ ReturnType: var retType } when retType.FullName == "System.Void" => " {}",
|
||||||
|
|
||||||
// Return type
|
// Return type
|
||||||
_ => " => default;"
|
_ => " => default;"
|
||||||
};
|
};
|
||||||
|
|
||||||
writer.Append(methodBody + (!SuppressMetadata && method.VirtualAddress != null ? $" // {method.VirtualAddress.ToAddressString()}" : "") + "\n");
|
writer.Append(methodBody + (!SuppressMetadata && method.VirtualAddress != null ? $" // {method.VirtualAddress.ToAddressString()}" : "") + "\n");
|
||||||
|
|
||||||
return writer.ToString();
|
return writer.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user