Repository navigation
Skip empty entries in a PragmaScope warning list [patch] - #167
Merged
matt-edmondson merged 1 commit intoNov 4, 2026
Merged
Conversation
The IEnumerable<string> constructor joined its entries before the empty check ran, so a list of empty strings joined to ", " and wrote `#pragma warning disable , ` (CS1072). Entries are now trimmed and null, empty or whitespace ones are dropped before joining, so such a list is a no-op and a mixed list carries no trailing comma. Fixes #166 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3PT52Zo3M7fFP8Z6J
|
matt-edmondson
deleted the
claude/issue-166-pragma-empty-warning-entries
branch
November 4, 2026 00:54
This was referenced Nov 4, 2026
matt-edmondson
pushed a commit
that referenced
this pull request
Nov 4, 2026
…ill refused PragmaScope.JoinWarnings trimmed every entry (#167), which stripped the terminator PragmaScopeRejectsWarningsThatSpanLinesBeforeWriting (#155) relies on, so main failed that test on every platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5jpiuVuBRXSgitSY1
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
…e and out of the semicolon [patch] (#162) * Keep a preprocessor directive in an expression body off the arrow line and out of the semicolon [patch] WriteExpressionBody wrote the first content line straight after " => ", even a directive (CS1040), and appended the semicolon to the last line with code, which could be #endif (CS1025). A body that opens with a directive now starts on the line after the arrow, and when a directive follows the last line of code the semicolon goes on its own line after it, so every #if branch reaches it. Covers PropertyTemplate ExpressionBodyFactory and AccessorKind.Expression. Fixes #158 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3C2EQ5hMiLw63t4Aa * Split the semicolon placement out of WriteExpressionBody SonarCloud S3776 flagged the method's cognitive complexity (19 > 15) after the directive handling. The choice of which line takes the semicolon moves to FindTerminatedLine, and the code/directive checks become private helpers; behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3C2EQ5hMiLw63t4Aa * Keep a pragma warning holding a line terminator untrimmed so it is still refused PragmaScope.JoinWarnings trimmed every entry (#167), which stripped the terminator PragmaScopeRejectsWarningsThatSpanLinesBeforeWriting (#155) relies on, so main failed that test on every platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5jpiuVuBRXSgitSY1 --------- Co-authored-by: Claude <noreply@anthropic.com>
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.



Fixes #166
Summary
PragmaScope(CodeBlocker, IEnumerable<string>)joined its entries with", "before the empty check inBegin/Endran. A list of empty strings therefore joined to", "and wrote#pragma warning disable ,(CS1072), and a mixed list like{ "CS0168", "" }wrote a trailing comma.The constructor now trims each entry and drops null, empty and whitespace ones before joining:
new PragmaScope(cb, ["", ""])writes no directives.new PragmaScope(cb, ["CS0168", ""])writes#pragma warning disable CS0168, with no trailing comma.The string constructor is unchanged.
Tests
PragmaScopeWithOnlyEmptyWarningEntriesIsANoOpandPragmaScopeSkipsEmptyWarningEntriesAmongRealOnesboth fail onmainand pass with the fix. I checked this by revertingScopes.csand running them again.Generated by Claude Code