Make ScopeAfterManualDispose actually dispose while a scope is active - #94
Merged
Conversation
…active [patch] `ScopeAfterManualDisposeOfCodeBlockerShouldThrowException` was byte-identical to `ScopeWithDisposedCodeBlockerShouldThrowException`: it disposed the CodeBlocker and then asserted that *constructing* a Scope throws. Its name, and its own "Dispose the CodeBlocker while scope is still active" comment, promise something else — and that path was untested. It now opens a scope first, disposes the CodeBlocker out from under it, and asserts that closing the scope throws `ObjectDisposedException` when `EndScope` writes its brace to the disposed writer. CA2000 is suppressed on the one line, with justification: disposing the scope is the act under test and it throws, so a `using` block would let the exception escape the assert rather than reach it. Found by the local SonarCloud reproduction added for #88 (`S4144`), which is also the first end-to-end confirmation that the setup surfaces real findings. CLAUDE.md records what the run reports on `main` as a calibration baseline. The issue's remaining acceptance criterion still needs dashboard access. Full suite: 168 passed. The Sonar run is now clean apart from five pre-existing `S2699` warnings. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N1cVfacJWw1uM42DUmPfUg
|
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.



Related to #88 — this is a finding produced by the local SonarCloud reproduction that issue asked for, and the first end-to-end confirmation that the setup surfaces real problems.
The defect
ScopeAfterManualDisposeOfCodeBlockerShouldThrowExceptionwas byte-identical in behaviour toScopeWithDisposedCodeBlockerShouldThrowException— Sonar'sS4144. Both disposed theCodeBlockerand then asserted that constructing aScopethrows.That is not what the test's name says, and not what its own comment says:
No scope was ever active. The path the test claims to cover — a
CodeBlockerdisposed out from under a live scope — had no coverage at all.It now opens a scope first, disposes the
CodeBlocker, and asserts that closing the scope throwsObjectDisposedException, which is what happens whenEndScopewrites its brace to the disposed writer.CA2000is suppressed on that one line with a justification: disposing the scope is the act under test and it throws, so ausingblock would let the exception escape the assert instead of reaching it. Same pragma style asCodeBlocker.cs:180, and scoped to the single statement.On #88 itself
The issue reads as outstanding, but its implementation landed on
mainin233a1b7. Verifying it against the acceptance criteria:.sonarlint/sonar-local.props+.globalconfigexist and work; the invocation is documented inCLAUDE.md.sonarcloud.iois not reachable from the agent sandbox (CONNECT tunnel failed, response 403), so the one unidentified issue from Generalize CodeBlocker into a code-generation substrate #87 cannot be named, and the globalconfig cannot be calibrated against the real quality profile. Enabling every rule the analyzer ships would be a superset, not a match, so it would not satisfy this criterion either. This needs someone with dashboard access; I'd leave Add a local SonarCloud reproduction #88 open for it.What the run reports on
maintoday, now recorded inCLAUDE.mdas a calibration baseline:S4144onScopeTests.cs(fixed here) and fiveS2699warnings for test methods that assert nothing. TheS2699ones are left alone — several look like deliberate "does not throw" tests, and deciding that is a judgement call rather than a defect fix.Testing
dotnet test— 168 passed, 0 failed.dotnet build -p:CustomAfterMicrosoftCommonProps=$PWD/.sonarlint/sonar-local.props— build succeeded;S4144gone, five pre-existingS2699warnings remain.One caveat: the sandbox has .NET SDK 10.0.111 (Roslyn 5.0) and
ktsu.Sdk.Analyzersrequires Roslyn 5.9, so both runs above had that one analyzer package dropped (CSC : error CS9057otherwise). The Sonar and .NET analyzers themselves ran normally —CA2000firing on the first draft of this change is the evidence.🤖 Generated with Claude Code
https://claude.ai/code/session_01N1cVfacJWw1uM42DUmPfUg
Generated by Claude Code