-
Notifications
You must be signed in to change notification settings - Fork 473
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
Analyzer to guard against comparing struct to null #3986
Comments
I believe this is exactly encompasses dotnet/roslyn#45744 and is already checked into roslyn master |
Great, closing this as external! |
Thanks @jmarolf! I read through the PR you linked and its linked PRs, and I'm curious how to enable this.
|
|
Describe the problem you are trying to solve
We checked if a variable of struct type is null. The check was negative, and we took incorrect code path.
We should have checked if the variable is default. This would have resulted in positive check, and we would have taken correct code path.
I would like to guard against such with an analyzer.
Does an analyzer like this already exist?
Describe suggestions on how to achieve the rule
== null
or!= null
)null
withdefault
I guess implementation could be similar to one of CA2242
Additional context
Sample scenario
The text was updated successfully, but these errors were encountered: