-
Notifications
You must be signed in to change notification settings - Fork 229
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
New Rule Idea: Null forgiving operator and conditional access should not be gratuitous/detrimental #7320
Comments
Same issue is thacked in dotnet Roslyn |
Any information on this rule? |
I created a roslyn analyzer to implement this, but its not working as expected, but if anyone is interested in add some thoughts https://github.com/luizfbicalho/NullableAnalyzer |
After considering this rule we decided to specify the following: string s = Test(true);
_ = s?.ToString(); // Noncompliant, you should remove ? and if you want to suppress a warning use !
string Test(bool condition) => condition ? "Hello": null; and add a new rule idea |
One more update:
I overlapping with S2583/S2589 so we decided to not proceed with its implementation. |
There are two mechanisms to either check for null or ignore a null check:
There are some cases that one of them might be either redundant, or actually making the program crash every time:
It might be two rules as well, one for null-forgiving
!
and one for conditional access?
.The text was updated successfully, but these errors were encountered: