Repository navigation
Comment every line of a multi-line copyright, and refuse a multi-line region name [patch] - #152
Merged
Merged
Conversation
… region name [patch] WriteAutoGeneratedHeader prefixed the whole copyright with "// " once, so the second and later lines of a multi-line notice were written as code and the generated file failed to compile. Each line is now written as its own comment, split at every terminator the C# compiler recognises (LF, CRLF, CR, NEL, LINE SEPARATOR and PARAGRAPH SEPARATOR), and an empty line becomes a bare "//". RegionScope had the same root cause: a name containing a line break left the rest of the name outside the #region directive. It now throws ArgumentException before writing anything. The line splitting DocComment already used moves into an internal LineTerminators helper that all three share. Fixes #151 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW67iMrjvYtnNY3p2qt
|
This was referenced Nov 1, 2026
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 #151
What changed
WriteAutoGeneratedHeaderused to write// {copyright}once, so only the first line of a multi-line notice was commented. It now splits the copyright into lines and writes// {line}for each one, or a bare//for an empty line. The split happens at every terminator the C# compiler recognises: LF, CRLF, CR, NEL (U+0085), LINE SEPARATOR (U+2028) and PARAGRAPH SEPARATOR (U+2029). A single-line copyright gives the same output as before.RegionScopenow throwsArgumentExceptionwhen the name contains any of those terminators. It throws before anything is written, the same validate-first approach as Unknown TypeKind or AccessorKind writes half a declaration before throwing, and an Expression accessor with no BodyFactory emitsget => ;#142, so the rest of the name can no longer end up outside the#regiondirective.LineTerminatorshelper (internal).DocComment's privateSplitLineshas moved here, so all three callers use the same list of terminators.DocComment's behaviour is unchanged.copyrightparameter docs now describe how a multi-line notice is written.The null check on
copyrightis nowcopyright is { Length: > 0 }instead of!string.IsNullOrEmpty(...). On netstandard2.0,IsNullOrEmptyhas no nullable annotations, so the old form raised CS8604 when the value was passed to the splitter.Tests
AutoGeneratedHeaderCommentsEveryLineOfAMultiLineCopyright: one data row for each of the six terminators.AutoGeneratedHeaderWritesABlankCopyrightLineAsABareComment: an SPDX line, a blank line, then a holder line.RegionScopeRejectsANameThatSpansLinesBeforeWriting: one row for each terminator. Each row checks that the exception is thrown and that nothing was written.With the
CodeBlockerExtensions.csandScopes.cschanges reverted, all 13 new cases fail. With them in place, the full suite passes (236/236, net10.0, Linux). The local Sonar run (-p:CustomAfterMicrosoftCommonProps=.sonarlint/sonar-local.props) reports no new findings in the library.Notes
WriteFileHeader. That fix lives in its own repository and is not part of this PR.Generated by Claude Code