NSubstitute
NSubstitute copied to clipboard
Arg.Any<Arg.AnyType>() does not match arguments passed by reference
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