-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Enable CA2213: Disposable fields should be disposed #15805
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
Conversation
|
CodeFactor "complex method" issues are false positives, see #15721. |
|
I'd qualify these all as bugs - if a class is IDisposable we should implement and call Dispose(). |
Unfortunately it is not quite that simple, some disposables are not owned by the class as they are injected via a property, etc. In any case, I've annotated each suppression with a link to #15803, so we can track these issues. |
We need to review every case and either fix as bug or suppress with description why it is not bug and maybe add more info in (XML) docs. |
|
PowerShell-CI-linux test failure, see #15814. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
We could merge this PR to enable the rule, and then review each case in #15803, |
|
/rebase |
Enable [CA2213: Disposable fields should be disposed](https://docs.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2213)
c95cd65 to
284588e
Compare
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
| <Description>PowerShell's Microsoft.PowerShell.Commands.Utility project</Description> | ||
| <NoWarn>$(NoWarn);CS1570;CA1416</NoWarn> | ||
| <!-- CA2213: https://github.com/PowerShell/PowerShell/issues/15803 --> | ||
| <NoWarn>$(NoWarn);CS1570;CA1416;CA2213</NoWarn> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this if we suppress with pragma in files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not suppress with pragma as the error was not tracible to a specific line of code, please see the PR description.
|
Since the issues are in different subsystems they will be analyzed and fixed by different experts. So I think it make sense to enumerate the issues with code references in #15803 as task list. |
|
@xtqqczze Thanks! I think we should fix bugs before we merge the PR to avoid hiding the bugs. |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
Enable CA2213: Disposable fields should be disposed
#pragma warning disableMicrosoft.PowerShell.Commands.Utilitydue to error that was not suppressible with#pragma:Contributes to #15803.
Related issue: dotnet/roslyn-analyzers#4407
cc: @iSazonov