diff --git a/Il2CppDumper/Il2CppCSharpDumper.cs b/Il2CppDumper/Il2CppCSharpDumper.cs index 93f1bfa..182b8c1 100644 --- a/Il2CppDumper/Il2CppCSharpDumper.cs +++ b/Il2CppDumper/Il2CppCSharpDumper.cs @@ -294,12 +294,18 @@ namespace Il2CppInspector .ToString(scope, prefix + "\t", emitPointer: !SuppressMetadata, mustCompile: MustCompile)); string modifiers = evt.AddMethod?.GetModifierString(scope); - sb.Append($"{prefix}\t{modifiers}event {evt.EventHandlerType.GetScopedCSharpName(scope)} {evt.Name} {{\n"); - var m = new Dictionary(); - if (evt.AddMethod != null) m.Add("add", evt.AddMethod.VirtualAddress); - if (evt.RemoveMethod != null) m.Add("remove", evt.RemoveMethod.VirtualAddress); - if (evt.RaiseMethod != null) m.Add("raise", evt.RaiseMethod.VirtualAddress); - sb.Append(string.Join("\n", m.Select(x => $"{prefix}\t\t{x.Key};{(SuppressMetadata? "" : " // " + x.Value.ToAddressString())}")) + "\n" + prefix + "\t}\n"); + sb.Append($"{prefix}\t{modifiers}event {evt.EventHandlerType.GetScopedCSharpName(scope)} {evt.Name}"); + + if (!MustCompile) { + sb.Append(" {{\n"); + var m = new Dictionary(); + if (evt.AddMethod != null) m.Add("add", evt.AddMethod.VirtualAddress); + if (evt.RemoveMethod != null) m.Add("remove", evt.RemoveMethod.VirtualAddress); + if (evt.RaiseMethod != null) m.Add("raise", evt.RaiseMethod.VirtualAddress); + sb.Append(string.Join("\n", m.Select(x => $"{prefix}\t\t{x.Key};{(SuppressMetadata? "" : " // " + x.Value.ToAddressString())}")) + "\n" + prefix + "\t}\n"); + } else + sb.Append(";\n"); + usedMethods.Add(evt.AddMethod); usedMethods.Add(evt.RemoveMethod); usedMethods.Add(evt.RaiseMethod); diff --git a/Il2CppDumper/Program.cs b/Il2CppDumper/Program.cs index a36fdda..0704ed6 100644 --- a/Il2CppDumper/Program.cs +++ b/Il2CppDumper/Program.cs @@ -43,13 +43,13 @@ namespace Il2CppInspector [Option('s', "sort", Required = false, HelpText = "Sort order of type definitions in C# output ('index' = by type definition index, 'name' = by type name). No effect when using file-per-class layout", Default = "index")] public string SortOrder { get; set; } - [Option('f', "flatten", Required = false, HelpText = "Flatten the namespace hierarchy into a single folder rather than using per-namespace subfolders. Only used when layout is per-namespace or per-class", Default = false)] + [Option('f', "flatten", Required = false, HelpText = "Flatten the namespace hierarchy into a single folder rather than using per-namespace subfolders. Only used when layout is per-namespace or per-class")] public bool FlattenHierarchy { get; set; } - [Option('n', "suppress-metadata", Required = false, HelpText = "Diff tidying: suppress method pointers, field offsets and type indices from C# output. Useful for comparing two versions of a binary for changes with a diff tool", Default = false)] + [Option('n', "suppress-metadata", Required = false, HelpText = "Diff tidying: suppress method pointers, field offsets and type indices from C# output. Useful for comparing two versions of a binary for changes with a diff tool")] public bool SuppressMetadata { get; set; } - [Option('k', "must-compile", Required = false, HelpText = "Compilation tidying: try really hard to make code that compiles. Suppress generation of code for items with CompilerGenerated attribute. Comment out attributes without parameterless constructors or all-optional constructor arguments")] + [Option('k', "must-compile", Required = false, HelpText = "Compilation tidying: try really hard to make code that compiles. Suppress generation of code for items with CompilerGenerated attribute. Comment out attributes without parameterless constructors or all-optional constructor arguments. Don't emit add/remove/raise on events.")] public bool MustCompile { get; set; } }