Repository navigation
Commit bb97a5d
committed
fix(extractor): recognize null-conditional
`EmitFlowExpr` only treated `x.Dispose()` (member access) as a release; `x?.Dispose()`
(null-conditional — a member BINDING under a conditional access) fell through to "use".
So a `finally { x?.Dispose(); }` modelled the dispose as a use, never releasing x. The
finally-before-return threading (this PR) widened that latent false positive onto the
return path: a try-with-finally + return that disposes via `?.` was bailed before, but is
now analysed and would falsely report OWN001 (Codex review).
Fix: recognize `x?.Dispose()`/`x?.Close()`/`x?.DisposeAsync()` as a release too, mirroring
IsDisposeShaped (which already handled the member-binding form for the may-throw / catch
checks). Pinned by a new sample NullCondFinallyDispose (`ncf` must stay silent in CI).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg8kSk1YT14x7A1vo5zgEDx?.Dispose() as a release in EmitFlowExpr1 parent 95af05c commit bb97a5d
3 files changed
Lines changed: 28 additions & 1 deletion
File tree
- .github/workflows
- frontend/roslyn
- OwnSharp.Extractor
- samples
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
320 | 322 | | |
321 | 323 | | |
322 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
615 | 629 | | |
616 | 630 | | |
617 | 631 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
284 | 295 | | |
285 | 296 | | |
286 | 297 | | |
| |||
0 commit comments