CheckId | NS1000 |
Category | Non-substitutable member |
Substituting for non-virtual member of a class.
A violation of this rule occurs when NSubstitute's features like:
Returns()
ReturnsForAnyArgs()
ReturnsNull()
ReturnsNullForAnyArgs()
Throws()
ThrowsForAnyArgs()
are used with non-virtual members of a class.
To fix a violation of this rule, make the member of your class virtual or substitute for interface.
This warning can be suppressed by disabling the warning in the ruleset file for the project or by suppressing it (for selected members) in nsubstitute.json
file. See the configuration section for details on how to set this up.
The warning can also be suppressed programmatically for an assembly:
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Non-substitutable member", "NS1000:Non-virtual setup specification.", Justification = "Reviewed")]
Or for a specific code block:
#pragma warning disable NS1000 // Non-virtual setup specification.
// the code which produces warning
#pragma warning restore NS1000 // Non-virtual setup specification.