Kristoffer
Kristoffer

Reputation: 834

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, e.g. that Root.ModuleC uses stuff in Root.ModuleA?

Upvotes: 2

Views: 2437

Answers (4)

Patrick from NDepend team
Patrick from NDepend team

Reputation: 13842

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 query for namespaces dependency cycles

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

Dependency Graph with namespaces dependency cycle

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

Dependency Matrix with namespaces dependency cycle

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

Upvotes: 2

dkackman
dkackman

Reputation: 15579

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

Upvotes: 2

Jim Bolla
Jim Bolla

Reputation: 8295

Have you tried NDepend?

Upvotes: 3

Oded
Oded

Reputation: 499382

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.

Upvotes: 1

Related Questions