C# - Application to show all dependencies between

2020-08-15 03:37发布

问题:

Is there some kind of an application that analyzes source code and graphically shows all the connections between function?

I need it for a legacy code I'm working on - It's huge , functional and badly written... :(

回答1:

NDepend can manage calling graph well indeed as suggested madgnome. Let me develop a bit. First you can ask for the call Graph with a CQL query, second you can export the query result to the Dependency Graph or Dependency Matrix.

Concretely, below we ask for methods' callers of the class AppDomain in NUnit 2.4.8 (it could be a method, a field, a namespace ... whatever). This menu could appear also in Visual Studio thanks to the NDepend VS addin.

Then a CQL query is generated for us, we can see that 30 methods are matched in the calling graph. We have the option to export hese set of methods o a graphical graph...

...and here is the outputed graph (see a large version picture of this graph here)



回答2:

NDepend do exactly that and more other things (code metrics...)



回答3:

In Visual Studio 2010 Ultimate you can Generate Sequence Diagrams:

http://www.devcurry.com/2010/03/generate-sequence-diagrams-in-visual.html

You can also check MSDN documentation for details:

http://msdn.microsoft.com/en-us/library/dd409458.aspx

And this might be of interest too (Generate Dependency Graphs for .NET Code):

http://msdn.microsoft.com/en-us/library/dd409453.aspx



回答4:

.Net Reflector is pretty neat - I've used it a couple of times for getting this sort of information. There are a number of addins, at least one of which generates dependency diagrams.

Also, in VS.Net 2008 or higher, right-click 'Find All References' can be useful.



回答5:

ReSharper provides features that allow you to see graph of methods, that are calling your method and vice verse. (Outgoing and Incoming calls)

This is new feature called "Call Tracking"