Repository navigation
Put an expression body's semicolon before a trailing line comment [patch] - #149
Merged
matt-edmondson merged 1 commit intoOct 30, 2026
Merged
Conversation
…tch] WriteExpressionBody appended the semicolon to the last line with content, so `x // note` became `x // note;` and the expression was never terminated (CS1002). VerbatimStringScanner now also reports where each top-level line comment starts, ignoring `//` inside literals, block comments and interpolation holes. The semicolon goes after the code and before the comment, and a comment-only last line leaves it on the last line of code. Fixes #144 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3gZxmT7yZRzkmnHAX
|
matt-edmondson
deleted the
claude/issue-144-semicolon-before-line-comment
branch
October 30, 2026 02:48
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 #144
What changed
TemplateRendering.WriteExpressionBodyused to append the terminating;to the last line that had content, without checking for a line comment.items.Length // cached upstreamtherefore rendered as=> items.Length // cached upstream;and failed to compile (CS1002). The semicolon now goes after the code and before the comment:=> items.Length; // cached upstream. If the last content line holds only a comment, the semicolon goes on the last line that has code. The change coversPropertyTemplate.ExpressionBodyFactoryandAccessorTemplate.Expression, which both use this path.VerbatimStringScanner.FindLineCommentsis new, as the issue suggested. It reports where each top-level//comment starts. It reuses the scanner's existing walk, so a//inside a string, character, verbatim or raw literal, a block comment, or an interpolation hole is not reported. The lines are scanned together, so a//on a line that an earlier line's verbatim string continues onto is not taken for a comment.Tests
There are six new tests in
TemplateTests, one per acceptance criterion, plus a verbatim-string case:x // crenders=> x; // c.} // crenders}; // c."http://x"is not treated as containing a comment.//inside a verbatim string opened on an earlier line is not treated as a comment.AccessorTemplate.Expressionwithx // crendersget => x; // c.With the fix reverted, the four behaviour tests fail. The two string-literal tests pass either way, because they guard against the new comment detection matching inside a literal. With the fix in place, the full suite passes (229/229, net10.0). The local Sonar build (
.sonarlint/sonar-local.props) reports only the five existingS2699findings thatCLAUDE.mdlists.Generated by Claude Code