Dependency Graphs in Visual Studio allows us to explore and understand the code in a better and visual way. In this tip you will learn how you can search some components from the Visual Studio generated dependency diagram very effectively. First of all, lets have a look how to generate the dependency diagram. If you want to manage and explore your code, understand the dependency between layers, check out the application flow, you can generate the dependency graph from the Visual Studio menu items “Architecture –> Generate Dependency Graph” then select either “For Solution” or “For Include File”.
For now, let’s consider that you are going to generate a dependency diagram for the following solution structure.
On the selection of “For Solution” option, Visual Studio will generate the dependency diagram that looks similar to the below image. From this diagram, you can find out, what are the different projects are used in your application, what are the different assembly are referred and how they are dependent to each other. This is an excellent and easy way to understand your code when you are very new to this code base.
This diagram looks really easy. Complexity of the dependency diagram will depends on your solution structure, numbers of projects and external reference used for the project . Now you can go through the each and individual block items to see the elements inside in your solution.
At this point of time, you may interested to look for some specific components, code block or even a method with in the solution which you can not by navigating it manually. This time, you can take help of the “Search” option, by just pressing “CTRL+F”. This search works exactly as similar way we search in Visual Studio. The only difference is, it will search with in the context of current dependency diagram. Provide the specific thing you are looking for, then Visual Studio search the components automatically and highlight the block where matches found.( Refer to the diagram below).
One more trick here, and this is the really interesting ! In the search option control, you can see a small icon, for “Auto-Expanded” search with in the diagram. What does it mean ? How does it useful ?
Consider, this option is disabled (though it is enabled by default) , and you want to search for a methods related to “Action” . While searching, you found a red highlight in search control which indicates there is no match founds. But you still believe, there must be something code related with term Actions.
Now try to enable the “Auto-Expanded” option, and search for the same item again. You will find, Visual Studio expands the dependency diagram automatically and highlight the match components. On click on “Next” search, it will also move to the different location of the diagram and highlight the components by expanding automatically if matches founds.
Hope this helps you!
Pingback: Windows Store App Developer Links – 2013-10-08 | Dan Rigby