fix(style): read a trailing comment as a comment, not as a member - #72
Merged
Conversation
A wrapped suppression closing with a trailing `//` comment was passed over in silence. The checker asks two questions of the line the attribute closes on: does the attribute end here, and does the line end here. The second answered no — a comment followed — so the site was filed as the one shape the checker admits it cannot read, a `)]` with a member after it, and produced no record at all. That is the outcome this checker exists to avoid. Both modes said "Nothing to report." and exited 0, which is exactly what a clean tree says, so a wrapped suppression could escape the rule entirely by carrying a note, and --fix had nothing to decline and so nothing to exit non-zero for. A `//` is not a member. It runs to the end of the line, so nothing can be hiding behind it and joining up to that line is safe. A `/*` still is not read: a member can follow its close on the same line, and telling that apart is parsing C# again. Two cases join the checker's own test — the wrapped-then-comment site it now rewrites, and the block-comment site it must still leave alone — along with the two counts they move. The repository itself carried no site of either shape, so nothing else changes. CLAUDE.md and CONTRIBUTING.md, in both languages, enumerate the shapes the checker stays silent on. A trailing comment is now named as not one of them, since reading it as one is what cost the rule its teeth. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M5U2BZXpHQr7YcfNHVx9dA
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.
Summary
A wrapped suppression closing with a trailing
//comment was passed over in silence — in both modes, with exit 0. That is the one outcome indistinguishable from a clean tree, which is the failure this checker and its test exist to prevent.Reproduced
The checker asks two questions of the line the attribute closes on: does the attribute end here (
)]anywhere), and does the line end here ()]at the end). The second answered no, because a comment followed — so the site was filed as the shape the checker admits it cannot read, a)]with a member after it, and produced no record at all. Not a report, not a decline: nothing. So--fixalso had nothing to exit non-zero for.A wrapped suppression could therefore escape the rule entirely by carrying a note.
Type of change
Changes
closesLinealso accepts)]followed by only a//comment. A//runs to the end of the line, so nothing can be hiding behind it and joining up to that line is safe. A/*is deliberately still unread — a member can follow its close on the same line, and telling that apart is parsing C# again.CLAUDE.md,CONTRIBUTING.mdanddocs/for-users/CONTRIBUTING.fr.mdall enumerate the shapes the checker stays silent on. A trailing comment is now named as not one of them, since reading it as one is what cost the rule its teeth.Scope
The repository carried no site of either shape —
lint-layout.shover the tree is still "Nothing to report." — so no C# changes with this.No changelog entry: the checker is a repository tool, not something the packages ship, and the changelog documents the packages.
Testing
tools/style/lint-layout.test.sh— passes; fails without the fix on the new casetools/style/lint-layout.shover the tree — nothing to reportdotnet test— documentation suite green (192), which is what theCONTRIBUTINGtranslation pairing runs throughtests/PackageSmokeTest/run.sh— not run: no packaging, analyzer or entry-point change; nothing undersrc/is touchedPublic API
Documentation
docs/updatedCHANGELOG.mdanddocs/for-users/CHANGELOG.fr.mdboth updated🤖 Generated with Claude Code
https://claude.ai/code/session_01M5U2BZXpHQr7YcfNHVx9dA
Generated by Claude Code