Browse and rearrange code maps

Rearrange items on code maps to make them easier to read and improve their performance.

You can customize code maps without affecting the underlying code in a solution. This is useful when you want to focus on key code elements or communicate ideas about the code. For example, to highlight interesting areas, you can select code elements on the map and filter them, change the style of code elements and links, hide or delete code elements, and organize code elements using properties, categories, or groups.

Requirements

  • To create code maps, you must have Visual Studio Enterprise.

  • You can view code maps and make limited edits to code maps in Visual Studio Professional.

Create a code map (see Map dependencies across your solutions for more details). If you don't want to wait for the map to finish generating, click the Cancel link at any time to stop the generation process. However, you will not see the details of all dependencies and links if you do this.

After you generate the map, get started with these tips for reviewing your code:

  • Look at the natural dependency clusters in the code. On the map toolbar, choose Layout, Quick Clusters LayoutQuick Clusters button on graph toolbar. See Change the map layout.

    Dependency graph - Quick Clusters layout

  • Organize the map into smaller areas by grouping related nodes. Collapse those groups to see only the intergroup dependencies, which appear automatically. See Group nodes.

  • Use filters to simplify the map and focus on the types of nodes or links you are interested in. See Filter nodes and links.

  • Maximize the performance of large maps. See Map dependencies across your solutions for more information.For example, turn on Skip Build on the map toolbar so that Visual Studio doesn't rebuild your solution when you update items on the map.

To

Perform these steps

Arrange the dependency flow for the entire map in a specific direction. This can help you see architectural layers in the code.

On the map toolbar, choose Layout, and then:

  • Top to Bottom Layout Top to Bottom graph button

  • Bottom to Top Layout Bottom to Top graph button

  • Left to Right Layout Left to Right layout button

  • Right to Left Layout Right to Left graph button

See natural dependency clusters in the code with the most dependent nodes at the center of the clusters and the least dependent nodes at the outside of those clusters.

On the map toolbar, choose Layout, and then Quick Clusters Layout Quick Clusters button on graph toolbar.

Move specific nodes around on the map.

Drag nodes to move them. To move other nodes and links out of the way as you drag nodes, press and hold the SHIFT key.

Change the layout inside a group independently of the map.

Select a node and open the Change the layout style of the group list Dependency graph - group toolbar - layout in the group pop-up toolbar that appears. Select one of the tree layouts, Quick Clusters, or List View (which arranges the group's contents into a list). See Group nodes for more details.

To

Perform these steps

Scan the map.

Drag the map in any direction.

Zoom in or out of the map.

Rotate the mouse wheel.

- or -

Use the Zoom list on the code map toolbar.

- or -

To zoom in on a specific area, use the right mouse button to draw a rectangle around that area.

Resize and fit the map in its window.

Choose Zoom to Fit from the Zoom list on the code map toolbar.

- or -

Click the Zoom to fit icon Zoom icon on map toolbar on the code map toolbar (Keyboard: press CTRL + O).

- or -

Double-click an empty area of the map.

Resize and center the map on a specific node.

Expand the node. Double-click inside an empty area of the node.

Visual Studio resizes the map so the entire group fits inside the map window.

If you double-click a collapsed namespace, class, or its members, Visual Studio shows you the code definition.

Change focus independently of the currently selected node.

Press TAB.

A dotted line appears around the node that is currently in focus.

Find a node on the map by its name.

Tip Tip

This works only for items on the map. To find items in your solution but not on the map, find them in Solution Explorer, and then drag them to the map. (Drag your selection, or on the Solution Explorer toolbar, click Show on Code Map).

  1. Click the Find icon Find icon on map toolbar on the code map toolbar (Keyboard: press CTRL + F) to show the search box in the upper right corner of the map.

  2. Type the item name and press Return or click the “magnifier” icon. The first item that matches your search appears selected on the map.

  3. To customize your search, open the drop-down list and choose a search option. The options are Find Next, Find Previous, and Select All. Then click the corresponding button next to the search textbox.

    Search options drop-down list

    Alternatively, use the keyboard: press F3 to select the next matching node or SHIFT + F3 to select the previous matching node.

  4. Select any one of the options that specify how search terms are handled by clicking the icons below the search textbox.

    Search match options

    The options are, from left to right, case sensitive matching, match whole words only, use .NET regular expression syntax, automatically expand groups to show matches to enclosed items.

Important note Important

You can use the search box to find matches in collapsed groups only if those groups were expanded previously. To find these matches and expand their parent groups automatically, choose this option under the search box.

Select all unselected nodes.

Open the shortcut menu for the selected nodes. Choose Advanced, Select, Invert Selection.

Select additional nodes that link to the selected ones.

Open the shortcut menu for the selected nodes. Choose Advanced, Select and one of these:

  • To select additional nodes that link directly to the selected node, choose Incoming Dependencies.

  • To select additional nodes that link directly from the selected node, choose Outgoing Dependencies.

  • To select additional nodes that link directly to and from the selected node, choose Both.

  • To select all nodes that link to and from the selected node, choose Connected Subgraph.

  • To select all children of the selected node, choose Children.

To

Perform these steps

Show or hide the Filter pane.

Click the Filter button on the code map toolbar. The Filter pane is displayed as a tab page of the Solution Explorer window by default.

Filter the types of nodes that are shown on the map.

Set or clear the checkboxes in the Code Elements list in the Filter pane.

Filter the types of links that are shown on the map.

Set or clear the checkboxes in the Relationships list in the Filter pane.

Show or hide Test project nodes on the map.

Set or clear the Test Assets checkbox in the Miscellaneous list in the Filter pane.

The icons shown in the Legend panel of the map reflect the settings you make in the list. To show or hide the Legend panel, click the Legend button on the code map toolbar.

Code maps show these kinds of links:

  • An individual link represents a single relationship between two nodes.

  • A cross-group link represents a relationship between two nodes in different groups.

  • An aggregate link represents all the relationships that point in the same direction between two groups.

Tip Tip

By default, the map shows cross-group links only for selected nodes. To change this behavior to show or hide aggregated links between groups, click Layout on the code map toolbar and choose Advanced, then Show All Cross-Group Links or Hide All Cross-Group Links. See Hide or show nodes and links for more details.

To

Perform these steps

See more information about a node or a link

Move the mouse pointer on top of the node or link until a tooltip appears.

The tooltip for an aggregated link lists the individual dependencies that it represents.

- or -

Open the shortcut menu for the node or the link. Choose Properties.

Show or hide the contents of a group

  • To expand a group, open the shortcut menu for the node. Choose Advanced, Group, Expand.

    - or -

    Move the mouse pointer on top of the node until the chevron (down arrow) button appears. Click this button to expand the group. Keyboard: To expand or collapse a selected group, choose the PLUS key (+) or the MINUS key (-).

    If you have a separate numeric keys section you can expand or collapse everything in a selected group by pressing and holding the SHIFT key while you choose the PLUS key (+) or the MINUS key (-) in the numeric keys section.

  • To expand all groups, open the shortcut menu for the map. Choose Advanced, Group, Expand All.

    Note Note

    This command is not available if expanding all groups generates an unusable map or memory issues. It is recommended that you expand the map only to the level of detail that you care about.

  • To collapse a single group, open the shortcut menu for the node. Choose Advanced, Group, Collapse.

    - or -

    Move the mouse pointer on top of a group until the chevron (up arrow) button appears. Click this button to collapse the group.

  • To collapse all groups, open the shortcut menu for the map. Choose Advanced, Group, Collapse All.

See the code definition for a namespace, type, or member

Open the shortcut menu for the node. Choose Go To Definition.

-or-

Double-click the node. For expanded groups, double-click the header on the group.

-or-

Select the node. Press F12.

For example:

  • For a namespace, the code file for the first alphabetical class in that namespace opens to show the definition of that class.

    Note Note

    When you perform this task on a Visual Basic .NET namespace, the code file behind the namespace does not open. This issue also occurs when you perform this task on a group of selected nodes that include a Visual Basic .NET namespace. To work around this issue, browse manually to the code file behind the namespace, or omit the node for the namespace from your selection.

  • For a class or a partial class, the code file for that class opens to show the class definition.

  • For a method, the code file for the parent class opens to show the method definition.

Examine dependencies and items that participate in an aggregate link

  1. Select the links.

  2. Open the shortcut menu for your selection.

  3. Choose Show Contributing Links on New Code Map or Advanced, Show Contributing Links.

Visual Studio expands the groups at both ends of the link and shows only those items and dependencies that participate in the link.

Note Note

When you examine dependencies between items in partial groups, you might see this behavior:

  • Links to items that don’t participate in your examination disappear from the map, even though those links still exist.

  • Suppose you examine a link to an item in a partial group, and then later examine a different link to the same item. During your second examination, the target partial group shows only items from your first examination. Links and target items that didn’t participate in your first examination but participate in your second examination don’t appear.

To see missing items from a group, choose Refetch Children Refetch Children Icon, which indicates that not all members of a group appear on the map. You can also try undoing your actions (Keyboard: choose CTRL+Z) and examine the dependencies on a new map.

Examine dependencies across multiple nodes in different groups

  1. Expand the groups so you can see all their children.

  2. Select all the nodes that interest you, including their children.

    To select all nodes in a group, press and hold the left mouse button while you draw a rectangle around that group. To select all nodes on a map, press CTRL+A.

    The map shows the cross-group links between the selected nodes.

    Tip Tip

    To show cross-group links at all times, on the map toolbar, choose Layout, Advanced, Show All Cross-Group Links.

See the items that a node or link references

Note Note

This applies only when the Reference attribute is set for the node or link in the map's .dgml file.

To add references to items from nodes or links, see Customize code maps by editing the DGML files.

Open the shortcut menu for the node. Choose Go To Reference and the item.

Hiding nodes keeps them from participating in layout algorithms. By default, cross-group links are hidden. Cross-group links are individual links that connect nodes across groups. When groups are collapsed, the map aggregates all cross-group links into single links between groups. When you expand a group and select nodes inside the group, cross-group links appear and show the dependencies in that group.

Caution note Caution

Before you share a map that was created in Visual Studio Enterprise with those who use Visual Studio Professional, make sure to unhide any nodes or cross-group links that you want others to see. Otherwise, those users won't be able to unhide those items.

To hide or show nodes

To

Perform these steps

Hide selected nodes

  1. Select nodes you want to hide.

  2. Open the shortcut menu for the selected nodes or for the map. Choose Advanced, Select, Hide Selected.

Hide unselected nodes

  1. Select nodes you want to remain visible.

  2. Open the shortcut menu for the selected nodes or for the map. Choose Advanced, Select, Hide Unselected.

Show hidden nodes

  • To show all hidden nodes inside a group, make sure the group is expanded first. Choose Unhide Children Unhide Children Icon in the upper left corner of the group.

  • To show all hidden nodes, open the shortcut menu for the map. Choose Advanced, Select, Unhide All.

To hide or show links

To

On the map toolbar, choose Layout, Advanced, and then choose

Show cross-group links at all times.

Show All Cross-Group Links. This hides aggregated links between groups.

Hide cross-group links at all times.

Hide All Cross-Group Links

Show only cross-group links for selected nodes.

Show Cross-Group Links On Selected Nodes

Hide all links (or show all links).

Hide All Links. To show all links, choose Hide All Links again to turn off this mode.

To

Perform these steps

Show container nodes as group nodes or leaf nodes

To show container nodes as leaf nodes, select the nodes. Open the shortcut menu for your selection. Choose Advanced, Group, Convert To Leaf.

To show container nodes as group nodes, select the nodes. Open the shortcut menu for your selection. Choose Advanced, Group, Convert To Group.

Change the layout inside a group

  1. Select the group. The group toolbar appears.

    Dependency graph - group toolbar
  2. Open the Change the layout style of the group list Dependency graph - group toolbar - layout and choose the layout you want.

    List View rearranges the group's members into list. Graph Default resets the group layout to the map default layout. For other options, see Change the map layout.

Add a node to a group

Drag the node onto the group.

While you drag the node, Visual Studio displays an indicator to show that you are moving the node.

You can also drag nodes out of a group.

Add a node to a non-group node

You can convert any node into a group. Drag the node onto the target node.

Group selected nodes

  1. Select the nodes that you want to group. A toolbar appears above the last selected node.

    Dependency graph toolbar
  2. On the toolbar, choose the fourth icon Group the selected nodes.

    - or -

    Open the shortcut menu for your selection. Choose Advanced, Group, Add Parent Group.

  3. Open the shortcut menu for the new group. Choose Properties. In the Label property, rename the group.

Group nodes that have specific categories or properties

  1. Select the nodes that have the specific category or property.

  2. Open the shortcut menu for your selection. Choose Advanced, Group, Add Parent Group.

  3. Open the shortcut menu for the new group. Choose Properties. In the Label property, rename the group.

Remove groups

Select the group or groups that you want to remove. Open the shortcut menu for your selection. Choose Advanced, Group, Remove Group.

Remove nodes from their parent group up to their grandparent, or outside a group, if they have no grandparent group

Select the nodes that you want to move. Open the shortcut menu for your selection. Choose Advanced, Group, Remove From Parent.

You can display more or fewer items on a map in order to drill down or to simplify the map. You can also rename items, and add comments to items.

Caution note Caution

Before you share a map that was created using Visual Studio Enterprise with those who use Visual Professional, make sure any code elements you want others to see are visible on the map. Otherwise, those users won't be able to retrieve deleted code elements.

To add a new undefined code element

Perform these steps

At the current pointer location

Select a place on the map where to put the new code element. Press Insert.

That links to the selected code element

  1. Select the source code element. A toolbar appears above the code element.

    Dependency graph toolbar
  2. On the toolbar, choose the second icon Create a node with the same category as this node and add a new link to it.

  3. Choose a place on the map to put the new code element. (Keyboard: Press Tab until the code element from which you want to link has focus, and then press Alt+Insert.)

That links to an existing code element with current focus

Press Tab until the code element that you want link has focus. Press Alt+Shift+Insert.

To add code elements for

Perform these steps

Code elements in the solution

  1. Find the code element in Solution Explorer. Use the Solution Explorer search box or browse the solution.

    Tip Tip

    To find code elements that have dependencies on a type or a member, open the shortcut menu for the type or the member in Solution Explorer. Choose the relationship that interests you. Solution Explorer shows only those code elements with the specified dependencies.

  2. Drag the code elements that interest you to the map surface. You can also drag code elements from Class View or Object Browser.

    - or -

    In Solution Explorer, select the code elements that you want to map. Then, on the Solution Explorer toolbar, click Show on Code Map.

By default, the parent container hierarchy for the new code elements is shown on the map. Use the Include Parents button on the code map toolbar to change this behavior. When turned off, only the code element itself is added to the map. To reverse this behavior for just one drag and drop action, press and hold the CTRL key while you drag the code elements to the map.

Visual Studio adds code elements for the top-level code elements in your selection. To see if a code element contains other code elements, move the mouse pointer on top of the code element so that the chevron (down arrow) appears. Choose the chevron to expand the code element. To expand all code elements, open the shortcut menu for the map. Choose Group, Expand All. This command is not available when expanding all groups will produce an unusable map or incur memory issues.

Code elements related to code elements on the map

Click the Show Related button on the code map toolbar and choose the type of related items you are interested in.

- or -

Open the shortcut menu for the code element. Choose one of the Show … items on the menu depending on the kind of relationship that interests you. For example, you can see items that the current item references, items that reference the current item, base and derived types for classes, method callers, and the containing classes, namespaces, and assemblies.

For more details, see this topic.

Compiled .NET assemblies (.dll or .exe) or binaries

Drag the assemblies or binaries from outside Visual Studio to a map.

You can drag from Windows Explorer only if you are running Windows Explorer and Visual Studio at the same User Access Control (UAC) permissions level.

For example, if UAC is turned on, and you are running Visual Studio as Administrator, then Windows Explorer will block the dragging operation. To work around this, make sure that Visual Studio is running as Administrator, or turn UAC off. Note that in Windows 8, Windows Explorer is File Explorer.

Add a link between existing code elements

  1. Select the source code element. A toolbar appears above the code element.

    Dependency graph toolbar
  2. On the toolbar, choose the first icon, Create new link from this node to which ever node that you click on next.

  3. Select the target code element. A link appears between the two code elements.

Add a comment to the map

  1. Select the code element where you want to add a linked comment. A toolbar appears above the code element.

    Dependency graph toolbar
  2. On the toolbar, choose the third icon, Create a new comment node with a new link to the selected node.

  3. Type your comments. To type on a new line, press SHIFT+Enter.

Rename a code element or link

  1. Select the code element or the link and press F2, or right-click the code element to open the shortcut menu and click Rename.

  2. When the edit box appears in the map, rename the code element or the link.

    - or -

  3. Right-click the code element to open the shortcut menu and click Properties.

  4. Edit the Label property in the Properties window.

Delete a code element

  1. Select the code element, and then press the Delete key.

  2. If the element is part of a group, the Refetch Children button Refetch Children Icon appears inside the group. Click this to retrieve missing code elements.

  • You can delete code elements from a map without affecting the underlying code. When you delete code elements, their definitions are removed from the DGML (.dgml) file.

  • Maps created by editing the DGML, by adding undefined code elements, or by using some earlier versions of Visual Studio, do not support this capability.

You can change the icons on code elements and the colors of code elements and links using predefined icons and colors. For example, you can choose a color to highlight code elements and links that have a certain category or property. This lets you identify and focus on specific areas of the map. You can specify custom icons and colors by editing the map's .dgml file; see Customize code maps by editing the DGML files.

To apply a predefined color or icon to code elements with a certain category or property

  1. On the map toolbar, click Legend.

  2. In the Legend box, see if the code element category or property appears in the list.

  3. If the list does not include the category or property, choose + in the Legend box, Node Category or Node Property, and the category or property.

    The category or property now appears in the Legend box.

    Note Note

    To create and assign a category or a property to a code element, you can edit the map's .dgml file; see Customize code maps by editing the DGML files.

  4. In the Legend box, click the ellipses () next to the category or property you added.

  5. Use the following table to select the style that you want to change:

    To change the

    Choose

    Background color

    Background

    Outline color

    Stroke

    Text color

    Foreground

    Icon

    Icons

    The Color Set Picker or Icon Set Picker dialog box appears for you to select a color or icon.

  6. In the Color Set Picker or Icon Set Picker dialog box, do one of the following:

    To apply a

    Perform these steps

    Set of colors or icons

    Open the Select color (or icon) set list. Select a set of colors (or icons).

    To revert to the default color or icon, in the Select color (or icon) set list, choose None.

    Specific color or icon

    Open the category or property value list. Select a color or icon.

    Note Note

    You can rearrange, delete, or temporarily inactivate styles in the Legend box. See Edit the Legend box.

To apply a predefined color to links with a certain category or property

  1. On the map toolbar, click Legend.

  2. In the Legend box, see if the category or property appears in the list.

  3. If the list does not include the category or property, choose + in the Legend box, Link Category or Link Property, and the category or property. The category or property appears in the Legend box.

    Note Note

    To create and assign a category or a property to a link, you can edit the map's .dgml file; see Customize code maps by editing the DGML files.

  4. In the Legend box, open the list next to the category or property.

  5. Select Stroke to change the link's outline and arrowhead color. The Color Set Picker box appears for you to select a color.

  6. In the Color Set Picker box, do one of the following:

    To apply a

    Perform these steps

    Set of colors

    Open the Select color set list and select a set of colors.

    To revert to the default color, in the Select color set list, choose None.

    Specific color

    Open the type or property value list to select a color.

    Note Note

    You can rearrange, delete, or temporarily inactivate styles in the Legend box. See Edit the Legend box.

You can rearrange, delete, or temporarily inactivate styles in the Legend box:

  1. Open the shortcut menu for a style in the Legend box.

  2. Perform one of the following tasks:

    To

    Choose

    Deactivate the code element

    Disable

    Delete the code element

    Delete

    Move the style up

    Move Up

    Move the code element down

    Move Down

  1. Make sure the Legend box appears on the source map. If it is not visible, on the map toolbar, click Legend.

  2. Open the shortcut menu for the Legend box. Choose Copy Legend.

  3. Paste the legend onto the target map.

You can merge maps by copying and pasting code elements between maps. If the code element identifiers match, then pasting code elements functions like a merge operation. To make this task easier, put all the assemblies or binaries that you want to visualize in the same folder so that the full path of each assembly or binary is the same for each map that you want to merge.

Alternatively, you can drag those assemblies or binaries to the same map from that folder.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft