Skip to content

Ignore a trailing line terminator in comment text [patch] - #173

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/issue-170-drop-trailing-line-terminator
Nov 4, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/issue-170-drop-trailing-line-terminator

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #170

Summary

LineTerminators.Split was a plain string.Split, so text ending in a line terminator kept an empty last element, and both of its callers wrote that element as a line:

  • WriteAutoGeneratedHeader("Copyright (c) X\r\n") wrote a bare // between the copyright and // <auto-generated />.
  • DocComment { Summary = "Hello.\n" } split the summary over three lines and added an empty /// line, where "Hello." alone gives /// <summary>Hello.</summary>. The same applied to every other element, <param> included.

Changes

  • LineTerminators.Split drops one empty trailing element when there is more than one line. This follows the rule TemplateRendering.SplitLines already uses. It recognises every terminator: LF, CRLF, CR, NEL, LS and PS.
  • A blank line inside the text, as in "A\n\nB", is still written as a bare // / ///, because only the tail is dropped.
  • The method uses Array.Resize instead of lines[..^1], because the netstandard2.0 target has no RuntimeHelpers.GetSubArray.

Tests

  • Header with a trailing terminator, once for each of the six terminators: no bare //.
  • Header "A\n\nB\n" keeps its inner blank line.
  • Summary = "Hello." followed by LF, CRLF or LS renders on one line.
  • Summary = "A\nB\n" renders two content lines with no empty ///.
  • A <param> whose text ends in \n renders on one line.
  • All 12 new test cases fail on main and pass with the fix. I checked this by reverting LineTerminators.cs and running them again.
  • Full suite: 261/261.

Generated by Claude Code

LineTerminators.Split kept the empty tail that a trailing terminator
leaves, so a copyright notice ending in a newline got a bare // line
before the auto-generated marker, and a one-line doc summary ending in
one was laid out over several lines with an empty ///. Drop that one
empty tail, as TemplateRendering.SplitLines already does. A blank line
inside the text is still written.

Fixes #170

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5LkA4KtEKYNbjk5tz
@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit c8023f0 into main Nov 4, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the claude/issue-170-drop-trailing-line-terminator branch November 4, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A copyright or doc comment text ending in a newline gets an extra empty // / /// line, and a one-line summary is split across three lines

2 participants