Skip to content

Latest commit

 

History

History
47 lines (36 loc) · 1.29 KB

File metadata and controls

47 lines (36 loc) · 1.29 KB

NS1000

CheckId NS1000
Category Non-substitutable member

Cause

Substituting for non-virtual member of a class.

Rule description

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.

How to fix violations

To fix a violation of this rule, make the member of your class virtual or substitute for interface.

How to suppress violations

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.