Навигация

Итоги года

Другие ссылки


Реклама

Счётчики


Visualize project dependencies in Visual Studio

23.03.2009 Понедельник 16:30

Sometimes it is nice to see project dependencies in Visual Studio in a visual form, so as to assess complexity of a new project you get involved with. Here's a way to do it:

  • Start Visual Studio

  • Open your solution

  • Start the data collecting macro (its code is at the bottom of the post)

  • The macro will generate a text file with name [your solution name].dot

  • Download and install open source program called Graphviz. It is a graph vizualization software. It takes a text file of a simple format as input.

  • Start Graphviz and open the .dot file in it. Graphviz will create an image visualizing dependencies of your application for you. You will get something like this:




Now for the macro.

Imports System

Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Imports VSLangProj
Imports System.IO

Public Module Diagram

Sub ProjectDependency()
Dim writer As New StreamWriter(DTE.Solution.FileName & ".dot")
writer.WriteLine("digraph """ & DTE.Solution.FullName & """ {")
writer.WriteLine(" rankdir=LR")
writer.WriteLine(" size=""10,10""")
writer.WriteLine(" node [color=lightblue2, style=filled]")

For Each project As Project In DTE.Solution.Projects
NavProj(project, writer)
Next

writer.WriteLine("}")
writer.Dispose()
End Sub

Sub NavProj(ByVal proj As Project, ByRef writer As StreamWriter)
For Each projectItem As ProjectItem In proj.ProjectItems
If Not projectItem Is Nothing Then
If Not projectItem.SubProject Is Nothing Then
writer.WriteLine(" """ & proj.Name & """->""" & projectItem.Name & """")
NavProj(projectItem.SubProject, writer)
End If
End If
Next
End Sub

End Module

This macro works in Visual Studio 2008.

#1 Escaper
23.03.2009 Понедельник 16:37

Ошибся блогом. Потом перенсу в ProgBlog.

#2 Escaper
23.03.2009 Понедельник 17:06

Кстати, Graphviz создали в AT&T Research, подразделении AT&T, отвечающем за разнообразные научные инновации в бизнесе компании. В свою бытность программистом в AT&T мне довелось плотно общаться с некоторыми людьми из AT&T Research. Хотя конкретно с теми, кто написал Graphviz, я не знаком.