Repository navigation
Commit dfb0835
committed
extractor: treat StringWriter/StringReader fields as dispose-optional
A StringWriter is StringBuilder-backed and a StringReader reads a string — neither
holds an OS handle or unmanaged resource, so Dispose() frees nothing real and an
undisposed owning field of these is not a leak. Add System.IO StringWriter/StringReader
to IsDisposeOptional (the same lever already used for Task/ValueTask/DataTable/DataSet/
DataView), so the owned-field detector stays silent on them. MemoryStream is deliberately
NOT exempted — it can own a real buffer and still warns.
Surfaced by the oracle on Newtonsoft.Json (field-notes #8): TraceJsonReader/TraceJsonWriter
own undisposed StringWriter/JsonTextWriter fields; CodeQL/Infer# correctly stay silent on
the StringWriter (not a real resource), Own.NET over-reported. Adds a HolderWithStringWriter
control to ResolvedDisposableSample + a CI assertion it stays silent.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011YMngnax1jsy378fSAZb9r1 parent 7ab1009 commit dfb0835
3 files changed
Lines changed: 27 additions & 1 deletion
File tree
- .github/workflows
- frontend/roslyn
- OwnSharp.Extractor
- samples
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
260 | 266 | | |
261 | 267 | | |
262 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
717 | | - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
718 | 725 | | |
719 | 726 | | |
720 | 727 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments