-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Change argument null exceptions to use ArgumentNullException.ThrowIfNull #43482
Comments
@stephentoub You're the author of many of the PRs in dotnet/runtime that switch code to use ArgumentNullException.ThrowIfNull. Is there a way to automate this, or did you update it manually? |
When |
@stephentoub Do you know what happened to the fixer when A fixer that converts from |
It would be. dotnet/runtime#68326 tracks it. @RikkiGibson wrote the initial analyzer/fixer and I believe was looking into revamping it for ThrowIfNull. |
Ok! FYI @rafikiassumani-msft @mkArtakMSFT @adityamandaleeka This has the area-runtime label, but changes apply in web frameworks and blazor areas as well. Could delay doing anything here until an updated analyzer+fixer is ready and then change all null tests automatically. |
You mean I wrote a sweet regex for nothing? 😄 |
src/Servers was done in #43502 |
We can use this analyzer dotnet/roslyn-analyzers#6293 |
ASP.NET Core checks and throws for null all over the place. e.g.
aspnetcore/src/HttpClientFactory/Polly/src/DependencyInjection/PollyHttpClientBuilderExtensions.cs
Lines 33 to 41 in a450cb6
ArgumentNullException.ThrowIfNull
is used in modern code, but we should go through existing code to useArgumentNullException.ThrowIfNull
.Pros: less code, small potential perf gains from inlining (exception moved into another method), consistency.
The text was updated successfully, but these errors were encountered: