Skip to content

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

@gianvitodifilippo

Description

@gianvitodifilippo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions