fix: bind using directly to constructed TestConsole (cs/local-not-disposed) - #16
Merged
Merged
Conversation
…posed) The build-mode: none CodeQL run reopened cs/local-not-disposed on the Width(120) test: `using var test = new TestConsole().Width(120)` binds the using to Width()'s return value, and CodeQL cannot prove a fluent method returns its receiver, so it saw the `new TestConsole()` as an undisposed disposable. Split the fluent call onto its own statement so the using binds directly to the construction. Behaviour-preserving; 80/80 tests pass on both TFMs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Follow-up to #15. When CodeQL switched to
build-mode: none, it reopenedcs/local-not-disposedon theWidth(120)test (now alert #5).using var test = new TestConsole().Width(120);binds theusingto the return value ofWidth(). CodeQL can't prove a fluent method returns its own receiver, so it treated thenew TestConsole()as a disposable that never reaches ausing. Splitting the fluent call onto its own statement makes theusingbind directly to the constructed console:TestConsole.Widthmutates in place and returnsthis, so discarding the return value is equivalent — behaviour-preserving.Verification
dotnet build -c Release— clean, 0 warnings.dotnet test -c Release— 80/80 pass onnet8.0andnet10.0.fixedonmain; this clears the last remaining open one.🤖 Generated with Claude Code