Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ArneMancofi opened this issue Aug 26, 2021 · 1 comment · Fixed by #166
Labels
bug Something isn't working
Milestone

Comments

@ArneMancofi
Copy link

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.

@tpodolak
Copy link
Member

Thanks for reporting. There is nothing wrong with your code, this one is clearly a bug on analyzers side.

@tpodolak tpodolak added the bug Something isn't working label Aug 27, 2021
@tpodolak tpodolak added this to the 1.0.15 milestone Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants