From 7ca78175e01f152075966332cb58da786f427f2c Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Mon, 18 Nov 2019 05:53:00 +0100 Subject: [PATCH] Output: extern methods should not declare a body (CS0179) --- Il2CppDumper/Il2CppCSharpDumper.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Il2CppDumper/Il2CppCSharpDumper.cs b/Il2CppDumper/Il2CppCSharpDumper.cs index 45867be..415a2d9 100644 --- a/Il2CppDumper/Il2CppCSharpDumper.cs +++ b/Il2CppDumper/Il2CppCSharpDumper.cs @@ -431,11 +431,21 @@ namespace Il2CppInspector writer.Append($"\n{prefix}\t\t{constraint}"); } - var methodBody = method.ReturnType switch { - { FullName: "System.Void" } => @"{}", - _ => "=> default;" + var methodBody = method switch { + // Abstract method + { 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(); }