Skip to content

Arg.Is() yields NS1004 warning: Argument matcher used with a non-virtual member of a class #163

Closed
@ArneMancofi

Description

Why am I getting the NS1004 warning Argument matcher used with a non-virtual member of a class for the expression Arg.Is((int? x) => x > 0) in this code?

using NSubstitute;
namespace NSubstituteTest {
  public interface IFoo { int Bar(int? x); }

  public class NSubstituteTest {
    public void Test(bool b)
    {
      var foo = Substitute.For<IFoo>();
      foo.Bar(b ? null : Arg.Is((int? x) => x > 0)).Returns(42);
    }                 // -------------------------
  }
}

I am using NSubstitute.Analyzers.CSharp v1.0.14.

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions