Skip to content

NET-1536 New Rule Idea: You should not use the null forgiving operator when nullable context is disabled #9691

@mary-georgiou-sonarsource

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Rule IdeaIdea for a rule that has NOT been specified.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions