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?
- Add the NsDepCop NuGet package to your C# projects:
- Add a text file named 'config.nsdepcop' to your project, then edit it to define your dependency rules.
- 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.
NsDepCop runs inside the C# compiler, so the build toolchain (Visual Studio / .NET SDK) determines compatibility, not the project's target framework:
| NsDepCop | Visual Studio | .NET SDK | Roslyn |
|---|---|---|---|
| 3.0+ | 2022 17.0+ | 6.0+ | 4.0+ |
| 2.7.x and earlier | 2019 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).
- See the Change Log for version history.
- Use the Issue Tracker to submit bugs and feature requests.
- Use the Discussions forum for questions.
- Diagnostics Reference
- Configuring XML schema support for config.nsdepcop files
- Troubleshooting
- How to contribute?
- Roslyn for the amazing parser API.
- DotNet.Glob for the globbing library.
- Check out my other project: Codartis Diagram Tool, a code visualization tool for C#.