NsDepCop is a static code analysis tool that helps you to enforce namespace dependency rules in C# projects.
- Runs as part of the build process and reports dependency problems.
- No more unplanned or unnoticed dependencies in your system.
What is this dependency control anyway?
- Add the NsDepCop NuGet package to your C# projects:
- Add a file called config.nsdepcop. Edit it and describe dependency rules.
- Dependency violations will be underlined in the code editor and also reported at build time just like compiler errors/warnings.
See the Help for details.
- Install the NsDepCop Config XML Schema Support for Visual Studio to get validation and IntelliSense while editing the config.nsdepcop files.
- For Visual Studio 2017/2019:
- For Visual Studio 2015: see the instructions in Help.
- For Visual Studio 2017/2019:
The big change in v2.0 is that the implementation changed from MSBuild task + Visual Studio Extension to a standard Roslyn analyzer.
- Supports .NET Core / .NET 5 projects too.
- No need for the NsDepCop Visual Studio Extension any more.
- The NuGet package works both at build time and inside Visual Studio editor.
- If the NuGet package is added to a project then it appears in Solution Explorer: project / Dependencies / Analyzers / NsDepCop.Analyzer
- Issue severities can be configured using Visual Studio light bulb menu or .editorconfig files.
- Requires Visual Studio 2019 (16.10.0 or later).
- Dropped support for VS 2015/2017. For those, use NsDepCop v1.11.0.
- No need for the out-of-process service host any more.
- No more "Unable to communicate with NsDepCop service".
Please note that the AutoLowerMaxIssueCount feature is temporarily not supported. Do not yet upgrade to v2.0 if you're using that.
- See the Change Log for version history.
- Please use the Issue Tracker to record bugs and feature requests.
- Or find me on twitter
- Roslyn for the best parser API.
- ReSharper for the free licence of this amazing tool.
- DotNet.Glob for the globbing library.