Output: Don't emit add/remove/raise on events when using --must-compile
This commit is contained in:
@@ -294,12 +294,18 @@ namespace Il2CppInspector
|
|||||||
.ToString(scope, prefix + "\t", emitPointer: !SuppressMetadata, mustCompile: MustCompile));
|
.ToString(scope, prefix + "\t", emitPointer: !SuppressMetadata, mustCompile: MustCompile));
|
||||||
|
|
||||||
string modifiers = evt.AddMethod?.GetModifierString(scope);
|
string modifiers = evt.AddMethod?.GetModifierString(scope);
|
||||||
sb.Append($"{prefix}\t{modifiers}event {evt.EventHandlerType.GetScopedCSharpName(scope)} {evt.Name} {{\n");
|
sb.Append($"{prefix}\t{modifiers}event {evt.EventHandlerType.GetScopedCSharpName(scope)} {evt.Name}");
|
||||||
var m = new Dictionary<string, (ulong, ulong)?>();
|
|
||||||
if (evt.AddMethod != null) m.Add("add", evt.AddMethod.VirtualAddress);
|
if (!MustCompile) {
|
||||||
if (evt.RemoveMethod != null) m.Add("remove", evt.RemoveMethod.VirtualAddress);
|
sb.Append(" {{\n");
|
||||||
if (evt.RaiseMethod != null) m.Add("raise", evt.RaiseMethod.VirtualAddress);
|
var m = new Dictionary<string, (ulong, ulong)?>();
|
||||||
sb.Append(string.Join("\n", m.Select(x => $"{prefix}\t\t{x.Key};{(SuppressMetadata? "" : " // " + x.Value.ToAddressString())}")) + "\n" + prefix + "\t}\n");
|
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.AddMethod);
|
||||||
usedMethods.Add(evt.RemoveMethod);
|
usedMethods.Add(evt.RemoveMethod);
|
||||||
usedMethods.Add(evt.RaiseMethod);
|
usedMethods.Add(evt.RaiseMethod);
|
||||||
|
|||||||
@@ -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")]
|
[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; }
|
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; }
|
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; }
|
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; }
|
public bool MustCompile { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user