moq.analyzers
moq.analyzers copied to clipboard
Moq1100 incorrectly firing on nullable parameters
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