Class Designer: What's new in Visual Studio 2005 Beta 2?

There are some really cool features coming online in Class Designer Beta 2 - automatic layout of the diagram, ability to export diagram as an image, display collection associations, display member types, ability to auto adjust the width of the shapes, etc.

I will go over the auto layout feature in this post.

When I create a diagram to visualize an existing code base (source code or assembly), I expect to quickly create a default diagram of all the types. Then I usually go over the high level class structure of the project. Then I will go ahead and start removing the types that I am not interested in and drill into the details of the rest. In order to do this efficiently, I would like to have the shapes in the auto created diagram organized in some manner that I can understand.

In Beta 2, selecting the “View Class Diagram” context menu on a project node in the solution explorer or a namespace node in class view will create a class diagram with shapes for all the types in the project/namespace. Types participating in inheritance relationships will be placed on the left hand side and types not participating in an inheritance relationship will be grouped according to the type (classes, interfaces, enums etc.) and placed on the right hand side. This provides me with a quick understanding of the inheritance hierarchy of the classes in the project. If I want to remove all the types not participating in inheritance, it is very easy for me to select them and remove them from the diagram. The layout algorithm is smart about the white spaces in the diagram and tries to utilize them as much as possible.

The shapes are initially collapsed. I can then go and expand the types I am interested in, look at the member details. Now, this may screw up my layout. But not to worry. There will also be a "Layout Diagram" command available to layout the diagram which can be invoked on the entire diagram or on a selection. I can use that command to re-auto layout the diagram.

Here is a link to a couple of diagrams (System.Xml and System.IO namespaces) auto laidout by the tool (this is before doing any manual editing).

Of course, auto layout will not be able to solve all your layout issues. We have to pick and choose between providing an optimal layout versus performance and other issues. It is intended to give you a running start. You will probably end up manually placing the shapes and rerouting the lines when you are ready to publish the diagram. Yes, you can publish your diagram as images - more on that soon.

Cheers,

Ramesh.