Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor arguments should be nullable #1494

Open
qrjo opened this issue Jul 24, 2024 · 1 comment · May be fixed by #1518
Open

Constructor arguments should be nullable #1494

qrjo opened this issue Jul 24, 2024 · 1 comment · May be fixed by #1518

Comments

@qrjo
Copy link

qrjo commented Jul 24, 2024

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:

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)

Back this issue
Back this issue

@daCostaeurogard
Copy link

daCostaeurogard commented Aug 22, 2024

Yes , i encountered the same problem as well see https://developercommunity.visualstudio.com/t/Dot-Net-xunit-test-to-fail-with-exceptio/10713601

But i got Nul errors, so that he tests failed

@kzu kzu added backed Backed via SponsorLink and removed backed Backed via SponsorLink labels Aug 31, 2024
@kzu kzu added this to the 5.0.0 milestone Sep 3, 2024
@Asafima Asafima linked a pull request Sep 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants