Share via


How to: Create UML Class Diagrams from Code

This Visual Studio 2010 feature pack lets you add C# classes or namespaces from Architecture Explorer or a dependency graph to a UML class diagram in Visual Studio 2010 Ultimate. For more information, see Visual Studio Feature Packs.

The class or classes that you drag will appear on the diagram. Classes on which they are dependent will appear in UML Model Explorer. For more information, see How the Modes Represent Types.

Important

You must install a Visual Studio 2010 Feature Pack to use this feature.

To add classes from program code to a UML model

  1. Open a C# project.

  2. Create a UML modeling project.

    For more information, see How to: Create UML Modeling Projects and Diagrams.

  3. Add a UML class diagram to the modeling project:

    On the Architecture menu, click New Diagram. In the Add New Diagram dialog box, select UML Class Diagram.

  4. Open Architecture Explorer:

  5. Drag namespaces or types from Architecture Explorer to the UML class diagram surface.

You can also drag classes and namespaces from dependency graphs onto the class diagram. For more information, see How to: Generate Dependency Graphs for .NET Code.

Note

The code and the diagram are not updated automatically. You can update the diagram to discuss change proposals without affecting your code. Subsequent changes in the code will not automatically affect the diagram unless you again drag the classes onto the diagram.

This feature might run more quickly after you install Windows Automation API 3.0.

To open the C# code associated with a UML class

  • Double-click a class shape, attribute, or operation in the UML class diagram.

    The source code appears.

How the Model Represents Types

Types that you explicitly move onto the diagram are represented directly in the model and on the diagram.

Types on which these explicit types depend are represented as placeholders in the model. Their details are not represented, and nor are their dependencies.

However, if you subsequently drag a placeholder type from Architecture Explorer or a dependency graph onto the diagram, the placeholder will be replaced by a full type.

See Also

Concepts

UML Class Diagrams: Reference

How to: Create UML Modeling Projects and Diagrams

How to: Find Code Using Architecture Explorer