From 44df54b63914d948a40f1223fa8e76630fb05391 Mon Sep 17 00:00:00 2001 From: Robert Xiao Date: Fri, 19 Jun 2020 00:53:00 -0700 Subject: [PATCH] Suppress new on operator methods. Per the C# language reference (https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/basic-concepts#hiding-through-inheritance): > The rules governing operator declarations (Operators) make it > impossible for a derived class to declare an operator with the same > signature as an operator in a base class. Thus, operators never hide > one another. Therefore, new is not necessary or permitted on operators, even if the method signatures are identical. This situation can arise if, for example, an explicit conversion operator from the same target class exists in both a base class and a derived class. --- Il2CppInspector.Common/Reflection/MethodBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector.Common/Reflection/MethodBase.cs b/Il2CppInspector.Common/Reflection/MethodBase.cs index ec37bb6..3896a27 100644 --- a/Il2CppInspector.Common/Reflection/MethodBase.cs +++ b/Il2CppInspector.Common/Reflection/MethodBase.cs @@ -267,7 +267,8 @@ namespace Il2CppInspector.Reflection // Method hiding if ((DeclaringType.BaseType?.GetAllMethods().Any(m => SignatureEquals(m) && m.IsHideBySig) ?? false) && (((Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.ReuseSlot && !IsVirtual) - || (Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot)) + || (Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot) + && !OperatorMethodNames.ContainsKey(Name)) modifiers.Append("new "); if (Name == "op_Implicit")