In my current project, using Visual Studio 2010 and C#, I often find myself having to update interfaces that I’ve defined to add new or remove old methods and members of the interface. As a result, I have to look back through my codebase, find all the classes that implement the interface, and manually remove all occurrences of those obsolete methods and members, or add new ones in by selecting “Implement Interface” for each class. This is highly tedious, and it’s slowing down my workflow.
Is there any way to automatically add placeholder implementations of new methods or members for interfaces to all the classes that implement the interface, without having to go through each class? Similarly, is there any way to remove a method or member from a class at the same time as I remove it from the interface the class implements?
If you are using ReSharper you can just add the method to the interface, click
Alt+Enterand choose ‘Add method to derived classes’:If you are removing a method, you can use
Refactor > Safe Delete ...functionality: