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 S2952 FP: Field disposal not recognized for some well known Dispose patterns #6782

Open
martin-strecker-sonarsource opened this issue Feb 22, 2023 · 0 comments
Labels
Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.

Comments

@martin-strecker-sonarsource
Copy link
Contributor

Follow up to #6229

#6229 (comment)

Description

S2952 recognizes this pattern:

 public void Cleanup() => fs.Dispose(); // Compliant: disposal is taking place in Dispose() too
 public void Dispose() => fs.Dispose();

These comparable constructs are not detected

  1. Disposed in virtual Dispose(bool disposing) of the dispose pattern
 public void Cleanup() => fs.Dispose(); // FP
 public void override Dispose(bool disposing) => fs.Dispose(); 
  1. Disposed in DisposeAsync
 public void Cleanup() => fs.Dispose(); // FP
 public Task DisposeAsync(bool disposing) => fs.Dispose(); 
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. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

No branches or pull requests

1 participant