Roslyn analysers for NSubstitute.
Clone or download
Pull request Compare This branch is 216 commits ahead, 1 commit behind tpodolak:dev.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
build [GH-50] - missing releasenotes.cake file added Oct 28, 2018
tests [GH-52] - ReturnsNullForAnyArgs visual basic tests Nov 3, 2018
.gitignore [GH-2] - missing assemblyinfos added Jun 3, 2018 [GH-11] - Removing Newtonsoft.Json, supporting suppressions for exten… Jul 15, 2018
Analyzers.ruleset [GH-38] - Fixing stylecops, using fully qualified name for InternalsV… Sep 29, 2018
Directory.Build.props [GH-38] - Proper way of including stylecops analyzers Sep 29, 2018 Rename LICENSE to Jun 2, 2018
NSubstitute.Analyzers.sln [GH-47] - ignoring local symbols when searching for re-entrant calls (#… Oct 26, 2018 Documentation review Oct 22, 2018
StyleCop.json Stylecop added May 27, 2018
global.json Adding global.json May 15, 2018

Analyzers to detect possible NSubstitute usage problems, such as attempts to setup non-virtual members.

Branch Build Coverage
Master Build status Coverage Status
Dev Build status Coverage Status

Install via NuGet


NSubstitute was designed with the aim of having concise, friendly syntax for mocking. The downside of this syntax is that certain failure modes are hard to detect. One example is attempting to mock non-virtual members -- NSubstitute can not see these calls so can not communicate problems such as sub.Received().NonVirtualCall(). Thanks to the goodness of Roslyn analyzers, we now have the option to detect cases like these (as originally proposed in NSubstitute issue #328).


For documentation and reasoning on the rules themselves, see the Documentation.


Please report any problems or ask questions via the Issue tracker.