Reverse Engineering Code into a UML Class Diagram

2019-03-22 16:16发布

问题:

Reverse engineering source code into a VS 2010 UML class model?

I have a bad feeling that this is not supported in VS 2010 (I'm using the RC from Feb 2010). I've tried dragging classes from the "Architecture Explorer" to the "UML Model Explorer" but that doesn't work (won't let me drop on the UML Model).

I've tried generating an old style class diagram (*.cd) and dragging the resulting diagram object to a blank UML Class diagram. No luck.

Binging does show up anything other than some MS marketing blurbs about "top-down modelling" and, as expected, forward engineering code from the UML model. This makes me suspect that the VS team didn't tackle reverse engineering code into models.

I was able to generate UML Activity diagrams from code. Nice. But other diagrams (and resulting generation of VS UML Model Repository Objects) is elusive.

If my suspicions are correct, this is a big disappointment. A lot of my work - and I would venture to guess that this is the case for most developers - is adding features to existing software and not doing green-field work. Without the ability to reverse engineer existing code into the VS UML Model repository or import models from other tools, I don't see how adoption of VS UML modelling will get very far. I'll just have to stick with my current favorite tool - Enterprise Architect by Sparks Systems.

I think this missing feature is a major shortcoming. What do others think?

What are others planning to do? Continue using their current, favorite UML modelling solution and ignoring VS 2010's offering?

回答1:

This question was answered on the VS 2010 Architecture & Modeling forum.

Basically, this functionality will appear in a power tool release around VS 2010 RTM. I encourage you to post in the forum if you have more questions.

UPDATE

You can now do this by getting the Visual Studio 2010 Feature Pack 2.



回答2:

You can now do this by getting the Visual Studio 2010 Feature Pack 2.



回答3:

Have you tried NDepend tool for .NET developers? It comes with both a dependency graph and a dependency matrix and integrates in VS, and it is objectively 100x faster than VS2010 at generating reverse-engineered code graph.

You can download and use the free trial edition for a while and make your own opinion.

More on NDepend Dependency Graph

More on NDepend Dependency Matrix:

Disclaimer: I am part of the tool team



回答4:

For creating UML class diagrams in Visual Studio 2013 Ultimate:

In Visual Studio 2013 Ultimate you can do this without any external tools.

  • In the menu, click on Architecture, New Diagram Select UML Class Diagram
  • This will ask you to create a new Modeling Project of you don't have one already.

You will have a empty UMLClassDiagram.classdiagram.

  • Again, go to Architecture, Windows, Architecture Explorer.
  • A window will pop up with your namespaces, Choose Class View.
  • Then a list of sub-namespaces will appear, if any. Choose one, select the classes and drag them to the empty UMLClassDiagram1.classdiagram window.

Reference: Create UML Class Diagrams from Code