Skip to content

Add actionable remediation approaches and patterns for CA2219 (Fixes #48230) - #56653

Open
Manish-1kumar wants to merge 1 commit into
dotnet:mainfrom
Manish-1kumar:users/manish/issue-48230-ca2219-alternative-approaches
Open

Manish-1kumar wants to merge 1 commit into
dotnet:mainfrom
Manish-1kumar:users/manish/issue-48230-ca2219-alternative-approaches

Conversation

@Manish-1kumar

Copy link
Copy Markdown
Contributor

Description

Resolves #48230.

In \docs/fundamentals/code-analysis/quality-rules/ca2219.md\ (CA2219: Do not raise exceptions in exception clauses), replaces the brief prohibition with concrete guidance and alternative patterns for handling cleanup operations that can fail.

Changes Included

  • Added *Catch and log cleanup exceptions inside \ inally* pattern with code sample showing how to prevent secondary exceptions from masking primary exceptions.
  • Added guidance for exception filters (\catch (...) when (...)), explaining that exceptions inside filters are silently caught and evaluate to \ alse.\
  • Added Use \Environment.FailFast\ for unrecoverable cleanup failures guidance for critical unmanaged or interop state corruption where execution cannot safely proceed.\
  • Validated with \markdownlint-cli2\ (0 issues).

@dotnetrepoman dotnetrepoman Bot added this to the November 2026 milestone Nov 1, 2026
@dotnet-policy-service dotnet-policy-service Bot added dotnet-fundamentals/svc community-contribution Indicates PR is created by someone from the .NET community. labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CA2219 (Do not use throw in finally) documentation should suggest alternative approaches

1 participant