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.
This commit is contained in:
Robert Xiao
2020-06-19 00:53:00 -07:00
committed by Katy
parent 6fff363c29
commit 44df54b639

View File

@@ -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")