Skip to content

S2219 FP: Is operator used for pattern matching #3605

@pavel-mikula-sonarsource

Description

S2219 As reported in this community thread

Description

Constant used for pattern matching cannot be replaced by simple null check.

Repro steps

public class Repro
{
    public string StringProperty { get; set; }
    public const string Example = "Lorem Ipsum";

    public void Go(Repro value)
    {
        bool result = value.StringProperty is Example;
    }
}

Metadata

Metadata

Labels

False PositiveRule IS triggered when it shouldn't be.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions