Skip to content

DRAFT - Multi throw if nulls #68234

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

Closed
wants to merge 4 commits into from

Conversation

SteveDunn
Copy link
Contributor

There's some issues with this idea WRT method overload resolution. Just creating this PR to show the issue

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Apr 19, 2022
@ghost
Copy link

ghost commented Apr 19, 2022

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost added new-api-needs-documentation and removed community-contribution Indicates that the PR has been added by a community member labels Apr 19, 2022
@ghost
Copy link

ghost commented Apr 19, 2022

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

{
public void Bar(string s1, string s2)
{
ArgumentNullException.ThrowIfNull(s1, (object?)s2); // sadly, have to cast to force the correct overload.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we have to cast to force the correct overload. This also impacts the parameter name reported in the exception message.

@teo-tsirpanis
Copy link
Contributor

Hello @SteveDunn and thanks for taking the initiative. Your PR is adding a new public API which first must be formally suggested and approved according to the process. Until that happens, I'm afraid I have to close it. Feel free to open another one if the API gets approved.

@SteveDunn
Copy link
Contributor Author

@teo-tsirpanis - understood. My idea didn't work anyway, because of overload resolution. I should've closed it myself, but didn't think of that (I just thought to make if DRAFT)

@ghost ghost locked as resolved and limited conversation to collaborators May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants