-
Notifications
You must be signed in to change notification settings - Fork 4k
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
"Add null check" quickfix should support generating ArgumentNullException.ThrowIfNull() calls #61181
Comments
This would need to be only available on projects using .NET 6 or above. |
@Bosch-Eli-Black I wouldn't check for the target framework, but rather whether the method exists and has the correct signature. |
It's also be sweet if there were a quickfix to convert this: if (name == null)
throw new ArgumentNullException(nameof(name)); to this: ArgumentNullException.ThrowIfNull(name); (Preferably a quickfix that could be run across all |
@davidwengier Oooh, thanks! Guess I was in the wrong repo 🙂 Let me comment over there. Thanks again! 🙂 |
@Neme12 Ah, yes, good point; that's probably the proper way to do that 🙂 |
The "Add null check" quickfix in Visual Studio doesn't have an option for generating a null check using
ArgumentNullException.ThrowIfNull()
.Consider the following code:
The "Add null check" quickfix looks like this:
I'd like for the quickfix to also have an option for generating a call to
ArgumentNullException.ThrowIfNull()
, so that the resulting code looks like this:The text was updated successfully, but these errors were encountered: