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

Fix S3247 FN: When cast expression contains parentheses #9491

Closed
sebastien-marichal opened this issue Jul 1, 2024 · 0 comments · Fixed by #9492
Closed

Fix S3247 FN: When cast expression contains parentheses #9491

sebastien-marichal opened this issue Jul 1, 2024 · 0 comments · Fixed by #9492
Assignees
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: False Negative Rule is NOT triggered when it should be.
Milestone

Comments

@sebastien-marichal
Copy link
Contributor

sebastien-marichal commented Jul 1, 2024

#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.

@sebastien-marichal sebastien-marichal added Type: False Negative Rule is NOT triggered when it should be. Area: C# C# rules related issues. labels Jul 1, 2024
sebastien-marichal added a commit that referenced this issue Jul 1, 2024
sebastien-marichal added a commit that referenced this issue Jul 1, 2024
@sebastien-marichal sebastien-marichal added the Sprint: Hardening Fix FPs/FNs/improvements label Jul 1, 2024
@sebastien-marichal sebastien-marichal self-assigned this Jul 1, 2024
@sebastien-marichal sebastien-marichal changed the title Fix S3247 FN: When cast expression contains parenthesis Fix S3247 FN: When cast expression contains parentheses Jul 1, 2024
@sebastien-marichal sebastien-marichal added this to the 9.29 milestone Jul 10, 2024
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. Sprint: Hardening Fix FPs/FNs/improvements Type: False Negative Rule is NOT triggered when it should be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants