8

What tool I can use for .Net/C# project to capture run-time dependencies between classes ? I found this question to be very useful but the suggested tools capture a static dependency graph. I simply want to see graph of instantiations of classes.

I'm using VS 2008 (but can install other version if needed).

UPD: My goal is this. I have huge old codebase. It has (for example) 500 classes but because DB-driven workflow has changed over the years only (for example) 100 class are used now. That's why static dependency analysis will be too overwhelming to digest.

Community
  • 1
  • 1
expert
  • 29,290
  • 30
  • 110
  • 214
  • 2
    Sounds like [NDepend](http://www.ndepend.com/) is right up your street... – Jon Skeet Aug 15 '12 at 18:36
  • @JonSkeet, I thought so too and I installed trial version. But it seems to be only does static analysis of dependencies where I'd like to get see dependencies in run-time. I have pretty old project which I need to analyze. So out of for example 300 classes maybe only 50 are being really used in run-time. – expert Aug 15 '12 at 18:51
  • I voted to reopne this question. I don't understand why it was closed as not constructive. Other question I linked to didn't answer my question. That's why I clearly stated it. – expert Aug 15 '12 at 18:52
  • @exacerbatedexpert, ehm, you're wrong, Sir. Maybe the question itself isn't that perfectly formed, but if you read it carefully, it's so obvious - how to monitor run-time dependencies of a .NET app. Where's a discussion? – walther Aug 15 '12 at 22:17
  • 5
    I do not see how a static analyzer will be able to verify your run time dependencies. Static tools are quite limited. Let it run under a memory profiler and check which types were created. That would be the only way to be really sure. – Alois Kraus Aug 15 '12 at 22:56
  • @AloisKraus checking what types are created doesn't help for static classes – Cole Tobin Aug 25 '12 at 03:44
  • No but it can give you a good indication which types are not used anymore when you execute typical use cases you still need to support. As with any tool you get only approximate results but this actually measured data is much more useful than seeing not dependency to a class in a static analysis tool. No analysis tools I am aware of does try to resolve run time dependencies of any DI framework. You need to be aware that dependencies are also configurable and whole type chains are hidden in your configuration files which are not accessible to code analysis tools anyway. – Alois Kraus Aug 25 '12 at 09:23

4 Answers4

2

CLRProfiler can capture/display CallGraph: http://www.scribd.com/doc/3376247/CLRProfiler.

The file format is documented, so you can add your own analisys.

Feng Yuan
  • 709
  • 5
  • 4
1

ANTS lets you visualize the call graph. Not precisely what you're looking for, but it might help. They have a 14 day trial and if you decide to buy it, it's well worth the money for profiling your .NET apps.

The .NET Memory Profiler lets you view instance graphs as well. A bit less spendy than ANTS and might do what you need to do.

JP Alioto
  • 44,864
  • 6
  • 88
  • 112
1

Not a call graph but a call list but IntelliTrace in VS can tell you the call history. If you filter for calls to constructors you probably can get most of the way there.

Mike
  • 418
  • 3
  • 10
0

Doxygen is a free tool that can also generate call graphs along with some basic documentation.

Peter Gluck
  • 8,168
  • 1
  • 38
  • 37
  • Interesting tool. But I don't see that it would help in this instance. The OP is looking for a tool to make the run-time dependencies as opposed to the static dependencies. Doesn't look like Doxygen will do this. – Davin Tryon Aug 16 '12 at 15:31
  • According to the [Doxygen feature list](http://www.stack.nl/~dimitri/doxygen/features.html) it can "generate include dependency graphs, collaboration diagrams, call graphs, directory structure graphs, and graphical class hierarchy graphs." Wouldn't a collaboration diagram assist with run-time dependencies? I'm pretty sure I generated something like that a few years back... – Peter Gluck Aug 17 '12 at 06:51
  • To me it looks like a collaboration diagram will [show what classes collaborate together](http://www.ibm.com/developerworks/aix/library/au-learningdoxygen/) (in terms of what classes the target class is dependent upon). It doesn't look like there is a way to run your code and have doxygen tell you only which execution paths occurred (which is what I think the OP is looking for). But if you know a specific configuration to do that, I'd make an edit to your answer and show how. – Davin Tryon Aug 17 '12 at 08:38