dotnet / dotnet/docs

The examples do not trigger CA2000

Open
#25,722 1 comment 0 reactions 0 assignees View on GitHub
dotnet-fundamentals/svc okr-quality
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
15h 21m
Merged PRs (30d)
370

Description

Neither of the examples on this page trigger CA2000 when using the Roslyn analyzers built into the project SDK. I am able to trigger CA2000 on other code in the same project (e.g. by not disposing a `SqlConnection`), but not from these examples. I initially thought that only the second example was a problem, because it uses a local `StreamReader`, even though the "Special Cases" section says that `TextReader` is excluded. However, the first example does not trigger CA2000 either.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 80e2f8df-7039-c826-764e-88abefb6744b
* Version Independent ID: f75bace0-4c3a-5936-8e19-9e2334fd9848
* Content: [CA2000: Dispose objects before losing scope (code analysis) - .NET](https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2000)
* Content Source: [docs/fundamentals/code-analysis/quality-rules/ca2000.md](https://github.com/dotnet/docs/blob/main/docs/fundamentals/code-analysis/quality-rules/ca2000.md)
* Product: **dotnet-fundamentals**
* GitHub Login: @gewarren
* Microsoft Alias: **gewarren**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.