32

I just got a heaping pile of (mostly undocumented) C# code and I'd like to visualize it's structure before I dive in and start refactoring. I've done this in the past (in other languages) with tools that generate call graphs.

Can you recommend a good tool for facilitating the discovery of structure in C#?

UPDATE

In addition to the tools mentioned here I've seen (through the tubes) people say that .NET Reflector and CLR Profiler have this functionality. Any experience with these?

ire_and_curses
  • 68,372
  • 23
  • 116
  • 141
Waylon Flinn
  • 19,969
  • 15
  • 70
  • 72

8 Answers8

21

NDepend is pretty good at this. Additionally Visual Studio 2008 Team System has a bunch of features that allow you to keep track of cyclomatic complexity but its much more basic than NDepend. (Run code analysis)

Sam Saffron
  • 128,308
  • 78
  • 326
  • 506
10

Concerning NDepend, it can produce some usable call graph like for example: NDepend Method Call Graph

The call graph can be made clearer by grouping its method by parent classes, namespaces or projects:

NDepend Method Call Graph grouped by parent class

Find more explanations about NDepend call graph here.

Patrick from NDepend team
  • 13,237
  • 6
  • 61
  • 92
8

It's bit late, but http://sequenceviz.codeplex.com/ is an awesome tool that shows the caller graph/Sequence diagram. The diagrams are generated by reverse engineering .NET Assemblies.

Dhile
  • 81
  • 1
  • 1
6

As of today (June 2017), the best tool in class is Resharper's Inspect feature. It allows you to find all incoming calls, outgoing calls, value origin/destination, etc.

The best part of ReSharper, compared to other tools mentioned above: it's less buggy.

Bill Yang
  • 1,413
  • 17
  • 28
6

I've used doxygen to some success. It's a little confusing, but free and it works.

albert
  • 8,285
  • 3
  • 19
  • 32
C. Ross
  • 31,137
  • 42
  • 147
  • 238
  • 1
    The latest windows binary of Doxygen includes a GUI tool known as Doxywizard. You point this to the installation path of Graphviz which you install separately, and watch it build you graphs. – Robin Rodricks Sep 13 '09 at 12:44
  • I was using the Doxywizard. The part I found confusing is that it wouldn't use the C# settings (though it works fine with the Java settings). It's been several months since I tried to use it. – C. Ross Sep 13 '09 at 14:14
5

Visual Studio 2010.

Plus, on a method-by-method basis - Reflector (Analyzer (Ctrl+R); "Depends On" and "Used By")

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Or outside reflector.. right click .. find all refrences, go to definition – Sam Saffron Apr 27 '09 at 14:24
  • will I have to convert my project to a new Visual Studio format? If so, how painless is this process? – Waylon Flinn Apr 27 '09 at 14:46
  • @Waylon Flinn: who knows... the product isn't released yet, or even in beta. However: with VS2005 to VS2008, project files were upgraded automatically and were (largely) backwards compatible; solution files were upgraded automatically, but were *not* backwards compatible. – Marc Gravell Apr 27 '09 at 14:55
  • Those things in .NET Reflector certainly are useful. I just wish there was a graphical version (or even an adjacency matrix). The add-in ' DependencyStructureMatrix' appears to come close but doesn't quite go all they way. – Waylon Flinn Apr 27 '09 at 21:54
  • Well thanks for the downvote, whoever that was. Care to qualify what you found so incorrect? Fact: VS2010 can generate call graphs... – Marc Gravell May 01 '09 at 08:48
  • 1
    It wasn't me. However - I have VS2010 Premium and I don't have a "Visualize Call Dependency" option in my Analyze menu. Maybe that's only in VS2010 Ultimate? – Mike Blandford Jan 13 '12 at 18:15
  • The same here — no anything about a call graph. Under the «Analyze» option is only a few of options like code analyzing, profiler, and «performance ». There is also obscure «Calculate code metrics …», but since that exist for both project and solution, it seems too just a statical analyzer. – Hi-Angel Jun 03 '15 at 14:34
4

SequenceViz and DependencyStructureMatrix for Reflector might help you out: http://www.codeplex.com/reflectoraddins

codekaizen
  • 26,990
  • 7
  • 84
  • 140
  • SequenceViz looks interesting but I can't get it to work with the newest version of .NET Reflector – Waylon Flinn Apr 27 '09 at 18:24
  • Finally got both of them to work. SequenceViz looks like it doesn't present present information in a way that's useful at the method level. DependencyStructureMatrix was useful but only appeared to give information at the Assembly and Class level. I'm looking for things on the Method level. Thanks for recommending these, they might be useful for something else. – Waylon Flinn Apr 27 '09 at 21:52
2

I'm not sure if it will do it over just source code, but ANTS Profiler will produce a call graph for a running application (may be more useful anyway).

Adam Robinson
  • 182,639
  • 35
  • 285
  • 343