From 4e3a8f25cccda444dbe501753b20873fb6988472 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Mon, 18 Nov 2019 01:59:49 +0100 Subject: [PATCH] Output: Correctly handle slicing of explicit interface implementations with built-in types --- Il2CppInspector/Reflection/MethodBase.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Il2CppInspector/Reflection/MethodBase.cs b/Il2CppInspector/Reflection/MethodBase.cs index 15cdbe6..885f309 100644 --- a/Il2CppInspector/Reflection/MethodBase.cs +++ b/Il2CppInspector/Reflection/MethodBase.cs @@ -57,12 +57,10 @@ namespace Il2CppInspector.Reflection OperatorMethodNames.ContainsKey(Name)? "operator " + OperatorMethodNames[Name] // Explicit interface implementation - : (IsVirtual && IsFinal && (Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot)? + : (IsVirtual && IsFinal && (Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot && Name.IndexOf('.') != -1)? ((Func)(() => { - var implementingInterface = DeclaringType.ImplementedInterfaces.FirstOrDefault(i => Name.StartsWith(Regex.Replace(i.FullName, @"`\d", "").Replace('[', '<').Replace(']', '>') + ".")); - // Regular interface implementation - if (implementingInterface == null) - return Name; + var implementingInterface = DeclaringType.ImplementedInterfaces.FirstOrDefault(i => Name.StartsWith(i.Namespace + "." + i.CSharpName + ".")) + ?? DeclaringType.ImplementedInterfaces.FirstOrDefault(i => Name.StartsWith(Regex.Replace(i.FullName, @"`\d", "").Replace('[', '<').Replace(']', '>') + ".")); var sliceLength = Regex.Replace(implementingInterface.FullName, @"`\d", "").Length + 1; return implementingInterface.CSharpName + "." + Name.Substring(sliceLength); }))() @@ -135,7 +133,7 @@ namespace Il2CppInspector.Reflection { IsConstructor: true, IsStatic: true } => "", // Explicit interface implementations do not have an access level modifier - { IsVirtual: true, IsFinal: true, Attributes: var a } when (a & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot => "", + { IsVirtual: true, IsFinal: true, Attributes: var a } when (a & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot && Name.IndexOf('.') != -1 => "", { IsPrivate: true } => "private ", { IsPublic: true } => "public ",