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

Closed
qrjo opened this issue Jul 24, 2024 · 1 comment · Fixed by #1518
Closed

Constructor arguments should be nullable #1494

qrjo opened this issue Jul 24, 2024 · 1 comment · 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
@kzu kzu closed this as completed in #1518 Sep 27, 2024
@devlooped-bot devlooped-bot removed this from the 5.0.0 milestone Sep 27, 2024
@devlooped-bot devlooped-bot added the backed Backed via SponsorLink label Sep 27, 2024
@devlooped devlooped locked and limited conversation to collaborators Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants