Skip to content

Enable CA2213 disposable-field analysis - #28605

Open
bgoodman-ui wants to merge 1 commit into
PowerShell:masterfrom
bgoodman-ui:ca2213/enable-analyzer
Open

bgoodman-ui wants to merge 1 commit into
PowerShell:masterfrom
bgoodman-ui:ca2213/enable-analyzer

Conversation

@bgoodman-ui

Copy link
Copy Markdown

Turn CA2213 (Disposable fields should be disposed) from none to warning now that the violations tracked in #15803 are fixed or explicitly suppressed.

Depends on the two CA2213 fix PRs (engine and cmdlet/host); the rule was left disabled there because PowerShell.Common.props treats analyzer warnings as errors.

PR Summary

PR Context

PR Checklist

Turn CA2213 (Disposable fields should be disposed) from none to warning now that the violations tracked in PowerShell#15803 are fixed or explicitly suppressed.

Depends on the two CA2213 fix PRs (engine and cmdlet/host); the rule was left disabled there because PowerShell.Common.props treats analyzer warnings as errors.
@bgoodman-ui
bgoodman-ui requested a review from a team as a code owner December 5, 2026 04:59
Copilot AI balanced review requested due to automatic review settings December 5, 2026 04:59
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Enabling CA2213 leaves outstanding disposal violations that become build errors under TreatWarningsAsErrors, so prerequisite disposal fixes or justified suppressions are needed.

1 open issue
What changed in this PR

Enables disposable-field analysis to prevent future CA2213 violations, following the cleanup tracked in #15803.

Changes:

  • Raises CA2213 severity from none to warning; existing build settings treat these warnings as errors.
File Description
.globalconfig Enables CA2213 disposable-field diagnostics.

Review effort: Balanced

Comment thread .globalconfig
# CA2213: Disposable fields should be disposed
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca2213
dotnet_diagnostic.CA2213.severity = none
dotnet_diagnostic.CA2213.severity = warning
@bgoodman-ui bgoodman-ui reopened this Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants