How to: Generate Dependency Graphs for C and C++ Code

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

This Visual Studio 2010 feature pack lets you visualize the organization and relationships in C and C++ code by generating dependency graphs in Visual Studio 2010 Ultimate. Use these graphs to help you explore, understand, and manage dependencies in source code, between binary files, and between source files and header files. For example, you can visualize dependencies between binary files, namespaces, and classes. A graph represents code elements and their relationships as a set of nodes that are connected by links, or edges. For more information, see Visual Studio Feature Packs.

Important

To perform this task with Visual C or Visual C++ projects, Visual C# installed must be installed with Visual Studio.

Note the following items when you generate graphs for C and C++ code:

When you open a solution that contains C and C++ projects, it might take some time to update the IntelliSense browsing database. During this time, the commands to generate dependency graphs for source files and header files will be unavailable.

Note

Before you generate a dependency graph for these files, please wait until the IntelliSense database finishes its updates. You can monitor the progress of these updates in the Visual Studio status bar. For more information about messages that appear because certain IntelliSense settings are disabled, see Troubleshooting.

The term "assembly" is used to refer to "binary" in the user interface. For example, to see dependencies between all binary files in the solution, on the Architecture menu, point to Generate Dependency Graph, and then click By Assembly.

Note

For binary files, graphs show dependencies at the binary level only. For example, dependencies within the same binary, such as method calls and reference types, are not shown.

The default name of the generated graph document for C and C++ code is "AssemblyDependenciesN.dgml" where N is the version number of the document. You can rename this document at any time.

You can generate a dependency graph for an entire Visual Studio solution or for specific items.

Note

If you have a very large solution, generating a dependency graph might take some time to analyze all the files or cause an out of memory exception. If this occurs, reduce the scope of your solution or use Architecture Explorer to select specific elements and relationships before you generate the graph.

You can visualize dependencies between C and C++ source files and header files. You can choose the following scope of dependencies to visualize:

Dependency graph for included files in a C++ project

All source files and header files in the solution

The currently open file and all first-level source files and header files

To see dependencies between

Follow these steps

All source files and header files in the solution

On the Architecture menu, point to Generate Dependency Graph, and then click By Included File.

Note

When you run this command for the first time, Visual Studio must analyze the C or C++ project files. This might take some time. To cancel graph generation, click Cancel in the message box that appears.

The currently open file and all first-level source files and header files

Tip

To view dependencies at additional levels, use Neighborhood Browse Mode on the graph toolbar to select the level of dependencies that you want to see. For more information, see How to: Browse and Navigate Graph Documents.

Open either a source file or header file.

The file opens in the code editor window.

Right-click anywhere in the file, and then click Generate Graph for Included Files.

Dependency graph for a header file with first-level source files and header files