Skip to content

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

Closed

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

Activity

  1. 304NotModified commented on Oct 28, 2024

    @304NotModified
    Contributor

    Fixed by

    #811

    Release 5.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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