Method overrides should not change parameter defaults
using System; namespace ConsoleApp1 { public class Base { public virtual void Write(int i = 42) { Console.WriteLine(i); } } public class Derived : Base { public override void Write(int i = 5) // Noncompliant { Console.WriteLine(i); } } public class Program { public static void Main() { var derived = new Derived(); derived.Write(); // writes 42 Print(derived); // writes 42 } private static void Print(Base item) { item.Write(); } } }
Add the default parameter value defined in the overridden method.
Remove the default parameter value from this explicit interface implementation.