Skip to content
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: You should not use the null forgiving operator when nullable context is disabled #9691

Open
mary-georgiou-sonarsource opened this issue Oct 31, 2024 · 0 comments
Labels
Area: C# C# rules related issues. Type: Rule Idea Idea for a rule that has NOT been specified.

Comments

@mary-georgiou-sonarsource
Copy link
Contributor

mary-georgiou-sonarsource commented Oct 31, 2024

When the Nullable context is disabled, the nullable forgiving operator is a no-op.
There's no need to use it.

#nullable disable

string s  = Method();
_ = s!.ToString(); // Noncompliant, as it's noop and just adds noise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: Rule Idea Idea for a rule that has NOT been specified.
Projects
None yet
Development

No branches or pull requests

1 participant