When you Rename a member that either implements/overrides or is implemented/overridden by members in other types, Visual Studio displays a dialog box that says the rename operation will result in cascading updates. If you click continue, the refactoring engine recursively finds and renames all members in base and derived types that have implements/overrides relationship with the member being renamed.
The following code example contains members with implements/overrides relationship.
interface IBase
{
void Method();
}
public class Base
{
public void Method()
{ }
public virtual void Method(int i)
{ }
}
public class Derived : Base, IBase
{
public new void Method()
{ }
public override void Method(int i)
{ }
}
public class C : IBase
{
public void Method()
{ }
}
In the example above, renaming C.Method() also renames Ibase.Method() because C.Method() implements Ibase.Method(). Next, the refactor engine recursively sees that Ibase.Method() is implemented by Derived.Method() and renames Derived.Method(). The refactor engine does not rename Base.Method(), because Derived.Method() does not override Base.Method(). The refactoring engine stops here unless you have Rename overloads checked in the Rename dialog box.
If Rename overloads is checked, the refactor engine renames Derived.Method(int i) because it overloads Derived.Method(), Base.Method(int i) because it is overridden by Derived.Method(int i), and Base.Method() because it is an overload of Base.Method(int i).
Note |
|---|
| When you rename a member that was defined in a referenced assembly, a dialog box explains that renaming will result in build errors. |