moq.analyzers icon indicating copy to clipboard operation
moq.analyzers copied to clipboard

Moq1100 incorrectly firing on nullable parameters

Open marcovr opened this issue 6 months ago • 0 comments

Analyzer Moq1100 is incorrectly firing in the following case:

public interface IFoo
{
    bool DoSomething(object? bar);
}

var mock = new Mock<IFoo>();
mock.Setup(m => m.DoSomething(It.IsAny<object?>())).Returns((object? bar) => true);

The analyzer reports:

Moq1100: Callback signature must match the signature of the mocked method

Note: this not only happens with object but also other types

marcovr avatar Aug 05 '24 17:08 marcovr