NSubstitute icon indicating copy to clipboard operation
NSubstitute copied to clipboard

Arg.Any<Arg.AnyType>() does not match arguments passed by reference

Open gianvitodifilippo opened this issue 1 year ago • 0 comments

Describe the bug Arg.Any<Arg.AnyType>() does not match arguments passed by reference

To Reproduce

IMyService service = Substitute.For<IMyService>();
MyArgument arg = new();
service.MyMethod(ref arg);

// The following line throws.
service.Received().MyMethod(ref Arg.Any<Arg.AnyType>());

public interface IMyService
{
  void MyMethod<T>(ref T argument);
}

private class MyArgument { }

Expected behaviour Arg.Any<Arg.AnyType>() should match arguments passed by reference

Environment:

  • NSubstitute version: 5.1.0
  • NSubstitute.Analyzers version: 1.0.17
  • Platform: net8.0 on Windows

gianvitodifilippo avatar Mar 13 '24 10:03 gianvitodifilippo