moq icon indicating copy to clipboard operation
moq copied to clipboard

Constructor arguments should be nullable

Open qrjo opened this issue 1 year ago • 0 comments

The constructor arguments that are passed to a mocked class' constructor are now typed as object[], this causes a lot of unwarranted warnings when passing null, because the mocked class in question might actually allow null for its arguments. The type should be changed to object?[].

I'm running into this problem when constructing Mock<T>:

public Mock(params object[] args)
public Mock(MockBehavior behavior, params object[] args)

These should be changed to:

public Mock(params object?[] args)
public Mock(MockBehavior behavior, params object?[] args)

qrjo avatar Jul 24 '24 15:07 qrjo