简体   繁体   中英

Tool for finding namespace dependencies in my project?

Dependency Walker seems to be a good tool for finding module (DLL) dependencies. But what if I have all these "modules" in the same assembly, separated by namespace like below?

namespace Root.ModuleA { ... }
namespace Root.ModuleB { ... }
namespace Root.ModuleC { ... }

Does a tool exist that can find out namespace dependencies inside my assembly, eg that Root.ModuleC uses stuff in Root.ModuleA ?

Have you tried NDepend ?

Visual Studio's Architecture Explorer does a pretty good job of that. There is a dependency graph specific to namesspaces .

To complete the tijmenvdk note, two default rules (over LINQ queries, CQLinq) are proposed concerning namespace dependency cycle:

You can try these rules on your code now, NDepend proposes a free time-limited full-featured trial edition . Then you can export dependencies between namespaces to a dependency graph or a dependency matrix (the matrix is better suited if you have dozens of namespaces):

命名空间依赖循环的 CQLinq 查询

The dependency graph could look like (notice the namespaces in red entangled in a cycles):

具有命名空间依赖循环的依赖关系图

The dependency matrix could look like (notice the cycle highlighted with a red square)

具有命名空间依赖循环的依赖矩阵

To go further you can read these two whitebooks on partitioning .NET code through assemblies and namespaces. Also recently Hendry Luk wrote a complete blog post about getting rid of namespaces dependency cycles in its project SheepAop.

Disclaimer: I am one of the developers of the tool

nDepend is probably the best tool for this job.

The dependency matrix view will show you all namespaces and how they related to each other.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM