Skip to content

Fix S3247 FN: When cast expression contains parentheses #9491

@sebastien-marichal

Description

@sebastien-marichal

#9486 Introduce an FN when casting an object to access an inner property with parenthesis:

if (arg.Property is Fruit)                  // Compliant - FN
{
    _ = ((Fruit)(arg.Property)).Property;
}

if (arg.Property is Fruit)                  // Noncompliant
{
    _ = ((Fruit)arg.Property).Property;     // Secondary
}

When not using parenthesis, the rule raises as expected.

Metadata

Metadata

Labels

False NegativeRule is NOT triggered when it should be.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions