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:
@@ -267,7 +267,8 @@ namespace Il2CppInspector.Reflection
|
|||||||
// Method hiding
|
// Method hiding
|
||||||
if ((DeclaringType.BaseType?.GetAllMethods().Any(m => SignatureEquals(m) && m.IsHideBySig) ?? false)
|
if ((DeclaringType.BaseType?.GetAllMethods().Any(m => SignatureEquals(m) && m.IsHideBySig) ?? false)
|
||||||
&& (((Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.ReuseSlot && !IsVirtual)
|
&& (((Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.ReuseSlot && !IsVirtual)
|
||||||
|| (Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot))
|
|| (Attributes & MethodAttributes.VtableLayoutMask) == MethodAttributes.NewSlot)
|
||||||
|
&& !OperatorMethodNames.ContainsKey(Name))
|
||||||
modifiers.Append("new ");
|
modifiers.Append("new ");
|
||||||
|
|
||||||
if (Name == "op_Implicit")
|
if (Name == "op_Implicit")
|
||||||
|
|||||||
Reference in New Issue
Block a user