Output: extern methods should not declare a body (CS0179)

This commit is contained in:
Katy Coe
2019-11-18 05:53:00 +01:00
parent e1752febbb
commit 7ca78175e0

View File

@@ -431,11 +431,21 @@ namespace Il2CppInspector
writer.Append($"\n{prefix}\t\t{constraint}"); writer.Append($"\n{prefix}\t\t{constraint}");
} }
var methodBody = method.ReturnType switch { var methodBody = method switch {
{ FullName: "System.Void" } => @"{}", // Abstract method
_ => "=> default;" { IsAbstract: true } => ";",
// Extern method
{ Attributes: var a } when (a & MethodAttributes.PinvokeImpl) == MethodAttributes.PinvokeImpl => ";",
// No return type
{ ReturnType: var retType } when retType.FullName == "System.Void" => @" {}",
// Return type
_ => " => default;"
}; };
writer.Append((method.IsAbstract? ";" : " " + 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();
} }