Reputation: 10566
Is there a programmatic way or tool that allows to iterate over all classes in project/assembly and find out other dependent classes? Resharper has similar functionality, but I wasn't able to find the way to export the results in some easy-to-analyze format.
My end goal is to create dependency graph between classes (per class), not aggregated by project/namespace/etc
My end goal is to get list like that <Class Name>: <Dependency1>, <Dependency N>
- Class1: Class2, Class6, Class9
- Class2: Class1, Class4
- Class3:
- Class4: Class2, Class5
Etc
Update: I am using Visual Studio 2015 Premium.
Upvotes: 3
Views: 5532
Reputation: 13842
You can also try the tool NDepend that integrates with VS2015 (all SKUs, Premium included) and also VS 2019, 2017, 2013, 2012, 2010 all SKUs except the older Express SKU.
With NDepend you can edit in Visual Studio C# linq queries that are compiled/executed live. For example the code query below shows all classes dependencies:
from t in Application.Types
select new { t, t.TypesUsed, t.TypesUsingMe }
Code queries results can be exported to graph and this way many kind of dependency graph can be generated: Call Graph, Class Inheritance Graph, Coupling Graph...
I wasn't able to find the way to export the results in some easy-to-analyze format.
In addition to live code querying in Visual Studio, the NDepend code querying is available through an API that you can harness to create C# programs and to export any data in any format.
The new NDepend version 2020.1 now let's you generate a call graph for a class or a method within a click:
Disclaimer: I work for NDepend
Upvotes: 3
Reputation:
The feature you're looking for is Code Maps. I'm not sure if they're available in VS 2015 Premium now, but they weren't upon initial release. The comments on this article might help you out: New ways to quickly create a Code Map.
Upvotes: 0