Refactoring Support in Class Designer
The language teams added several refactoring features to the editor in the Whidbey release of visual studio. We attempted, as best we could, to expose these refactoring features through the class designer in ways users would expect them in a modeling tool. One of the most obvious and seamless of these features is simply rename. If you have constructors, parameters, members or even method body statements which are using an identifier which is exposed in the class designer, renaming that in the class designer will update all instances of that name in code. For example if we have the following code and class diagram:
And we then use in place editing to change the name of the Book class to DVD in the class diagram we instantly get the following class diagram and code where all the instances of the Book type have been updated to the new name DVD.
No more find and replace; the diagram and the code all stays in sync for you. You can even undo and redo this operation both from the code editor and the class designer. This works for all types, members and relationships displayed in the class designer w/out having to invoke any context menu items.
We also expose the C# and VB refactoring commands to extract interfaces from types, to encapsulate fields with properties, and to reorder or remove parameters to methods or properties. To invoke these refactoring commands right click on the class designer element you'd like to refactor and go to the refactoring sub-menu to invoke the command as illustrated in this image:
There are a lot of refactoring patterns which exist in practice beyond what we’ve supported in this upcoming release of Visual Studio. We’d be interested to hear what types of refactoring support in the class designer you users would like to see and get value from. For example I could personally see some value with in a mechanism to split a bloated class in to two classes via designer actions. What other ones to people use and would see value from being supported in the Class Designer.