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:

Class Diagram before refactoring.


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.

Class Diagram after refactoring.

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:

Invoking refactoring command in class designer.



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.


Comments (12)
  1. Anonymous says:


    Nuff said. I want it.

  2. Anonymous says:

    Cool stuff, but I’m a bit shocked to see "ISBN" and "DVD" instead of Isbn and Dvd after all these years… or have the guidelines changed for 2.0 ?

  3. Anonymous says:

    It will be fantastic if it will have all the features (and more 🙂 ) in ReSharper( or the java counterpart in IntelliJ

  4. Anonymous says:

    RE, ISBN/Isbn DVD/Dvd. Its just a quick example I whipped up to illustrate refactoring the case used, if incorrect, is just to to my lack of knowledge on this. BTW, what 2.0 guidlines are you referring to?

  5. Anonymous says:

    Now all it needs is the ability to change Hashtable to Dictionary<,>.

    Perhaps it already has this? I’m pretty excited about this. I’ve been wanting a c# specific class modeler for quite some time!

  6. Anonymous says:

    Hi m-unit, If I understand your comment, you want to have the ability to refactoring Hashtable into Dictionary<T,V>. AFAIK, we’re not supporting this in Whidbey release. I think the reason is that it’s not clear what the key/value is unless the API is guided with user input.



Comments are closed.

Skip to main content