Use syntactic sugar for multicast delegates
This commit is contained in:
@@ -46,6 +46,27 @@ namespace Il2CppInspector
|
||||
writer.Write("protected internal ");
|
||||
if (type.IsNestedFamANDAssem)
|
||||
writer.Write("[family and assembly] ");
|
||||
|
||||
// Roll-up multicast delegates to use the 'delegate' syntactic sugar
|
||||
if (type.IsClass && type.IsSealed && type.BaseType?.FullName == "System.MulticastDelegate") {
|
||||
var del = type.DeclaredMethods.First(x => x.Name == "Invoke");
|
||||
writer.Write($"delegate {del.ReturnType.CSharpName} {type.Name}(");
|
||||
|
||||
bool first = true;
|
||||
foreach (var param in del.DeclaredParameters) {
|
||||
if (!first)
|
||||
writer.Write(", ");
|
||||
first = false;
|
||||
if (param.IsOptional)
|
||||
writer.Write("optional ");
|
||||
if (param.IsOut)
|
||||
writer.Write("out ");
|
||||
writer.Write($"{param.ParameterType.CSharpName} {param.Name}");
|
||||
}
|
||||
writer.Write($"); // TypeDefIndex: {type.Index}; 0x{del.VirtualAddress:X8}\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// An abstract sealed class is a static class
|
||||
if (type.IsAbstract && type.IsSealed)
|
||||
writer.Write("static ");
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace Il2CppInspector
|
||||
"IntPtr",
|
||||
"UIntPtr",
|
||||
"None",
|
||||
"delegate",
|
||||
"Delegate",
|
||||
"object",
|
||||
"SZARRAY", // Processed separately
|
||||
"T",
|
||||
|
||||
@@ -5,7 +5,7 @@ Extract types, methods, properties and fields from Unity IL2CPP binaries.
|
||||
* Supports ARMv7, ARMv7 Thumb T1 and x86 architectures regardless of file format
|
||||
* Supports metadata versions 21, 22, 23 and 24
|
||||
* No manual reverse-engineering required; all data is calculated automatically
|
||||
* Special language construct/syntax support for enumerations and events
|
||||
* Syntax support for enumerations, events and delegates
|
||||
* **Il2CppInspector** re-usable class library for low-level access to IL2CPP binaries and metadata
|
||||
* **Il2CppReflector** re-usable class library for high-level .NET Reflection-style access to IL2CPP types and data as a tree model
|
||||
|
||||
|
||||
Reference in New Issue
Block a user