Output: Render finalizers as C# destructors (CS0249)

This commit is contained in:
Katy Coe
2019-11-18 06:24:18 +01:00
parent b141e57598
commit 8f7b461310
2 changed files with 13 additions and 2 deletions

View File

@@ -135,6 +135,9 @@ namespace Il2CppInspector.Reflection
// Static constructors can not have an access level modifier
{ IsConstructor: true, IsStatic: true } => "",
// Finalizers can not have an access level modifier
{ Name: "Finalize", IsVirtual: true, IsFamily: true } => "",
// Explicit interface implementations do not have an access level modifier
{ IsVirtual: true, IsFinal: true, Attributes: var a } when (a & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot && Name.IndexOf('.') != -1 => "",
@@ -162,7 +165,7 @@ namespace Il2CppInspector.Reflection
if (IsFinal && (Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.ReuseSlot)
modifiers.Append("sealed override ");
// All abstract, override and sealed methods are also virtual by nature
if (IsVirtual && !IsAbstract && !IsFinal)
if (IsVirtual && !IsAbstract && !IsFinal && Name != "Finalize")
modifiers.Append((Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot ? "virtual " : "override ");
if (IsStatic)
modifiers.Append("static ");