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 S2259 FP: Reset fields on this invocation with flow captures #6103

Closed
martin-strecker-sonarsource opened this issue Sep 15, 2022 · 0 comments · Fixed by #6150
Closed
Assignees
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@martin-strecker-sonarsource
Copy link
Contributor

#6065 introduced "reset" logic for fields, if an instance method is invoked. The logic fails, if the invocation takes an argument expression, that branches:

if (this.ObjectField == null)
{{
    this.InstanceMethod(StaticObjectField == null ? 1 : 0);
}}
this.ObjectField.ToString();  // Don't report here

Reproducer: #6102

@martin-strecker-sonarsource martin-strecker-sonarsource added Type: False Positive Rule IS triggered when it shouldn't be. Area: CFG/SE CFG and SE related issues. Area: C# C# rules related issues. labels Sep 15, 2022
@martin-strecker-sonarsource martin-strecker-sonarsource added this to the 8.45 milestone Sep 15, 2022
@github-actions github-actions bot added this to False Positive in Backlog Sep 15, 2022
@martin-strecker-sonarsource martin-strecker-sonarsource moved this from To do to In progress in Best Kanban Sep 30, 2022
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Sep 30, 2022
@pavel-mikula-sonarsource pavel-mikula-sonarsource modified the milestones: 8.46, 8.47 Oct 3, 2022
@pavel-mikula-sonarsource pavel-mikula-sonarsource moved this from Review in progress to In progress in Best Kanban Oct 5, 2022
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Oct 6, 2022
@github-actions github-actions bot moved this from Review in progress to Review approved in Best Kanban Oct 6, 2022
@pavel-mikula-sonarsource pavel-mikula-sonarsource changed the title S2259: FP for fields not reset on invocation on this Fix S2259 FP: Reset fields on this invocation with flow captures Oct 6, 2022
Backlog automation moved this from False Positive to Done Oct 6, 2022
Best Kanban automation moved this from Review approved to Validate Peach Oct 6, 2022
@martin-strecker-sonarsource martin-strecker-sonarsource moved this from Validate Peach to Done in Best Kanban Oct 14, 2022
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. Area: CFG/SE CFG and SE related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
Best Kanban
  
Done
Backlog
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants