NsDepCop - Namespace and Assembly Dependency Checker Tool for C#

June 19, 2026 ยท View on GitHub

NsDepCop is a static code analysis tool that enforces namespace and assembly dependency rules in C# projects.

  • It runs as part of the build process and reports any dependency problems.
  • No more unplanned or unnoticed dependencies in your system.

What is this dependency control anyway? And why should you automate it?

Getting Started

  1. Add the NsDepCop NuGet package to your C# projects: NuGet Package
  2. Add a text file named 'config.nsdepcop' to your project, then edit it to define your dependency rules.
  3. Dependency violations will be underlined in the code editor and reported at build time just like compiler errors/warnings.

See the Help for details.

Or check out this step-by-step tutorial video by plainionist.

Requirements

NsDepCop runs inside the C# compiler, so the build toolchain (Visual Studio / .NET SDK) determines compatibility, not the project's target framework:

NsDepCopVisual Studio.NET SDKRoslyn
3.0+2022 17.0+6.0+4.0+
2.7.x and earlier2019 16.9+5.0+3.9+

Newer C# syntax is only analyzed when the toolchain's Roslyn supports it โ€” e.g. C# 14 extension members need Roslyn 5+ (VS 2026 / .NET 10 SDK).

Versions

Feedback

More Info

Thanks to

License

Other Tools