Cysharp / Cysharp/ConsoleAppFramework

LF-only multi-line <summary> breaks generated code on Windows

Open
#249 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
2.2k
Forks
127
PR merge metrics
No merged PRs in 30d

Description

A command method with a <summary> that wraps across multiple /// lines fails to build, but only when the source file has LF-only line endings (no \r) and the build runs on Windows. This happens with plain LF .cs files, which is common with .gitattributes normalization or editors that default to LF.

Reproduced with ConsoleAppFramework 5.7.13, .NET SDK 10.0.302, and Windows 11.

Repro (Program.cs, saved with LF line endings):

ConsoleApp.Run(args, Hello);

/// <summary>
/// line one of the summary
/// line two of the summary
/// </summary>
void Hello()
{
    Console.WriteLine("hello");
}

dotnet build fails with:

ConsoleApp.Run.g.cs(23,7): error CS0708: 'ConsoleApp.two': cannot declare instance members in a static class
ConsoleApp.Run.g.cs(23,14): error CS0708: 'ConsoleApp.the': cannot declare instance members in a static class
ConsoleApp.Run.g.cs(23,2): error CS0246: The type or namespace name 'line' could not be found
ConsoleApp.Run.g.cs(23,11): error CS0246: The type or namespace name 'of' could not be found

With EmitCompilerGeneratedFiles=true, the generated file shows why:

    /// <summary>
    /// Usage: [-h|--help] [--version]<br/>
    /// <br/>
    /// line one of the summary
 line two of the summary<br/>
    /// <br/>
    /// </summary>

Line 2 of the summary is missing its /// prefix, so it breaks out of the comment.

I traced this to GetSummary()/GetParams() preserving the source file's line endings, while Emitter.EmitRun splits the resulting help text using Environment.NewLine. On Windows, an LF-only source file therefore isn't split correctly.

I tested a fix that normalizes the extracted documentation text and handles all common line endings in the emitter. The repro and existing generator tests pass:

https://github.com/Cysharp/ConsoleAppFramework/compare/master...shimat:ConsoleAppFramework:fix/multiline-summary-newline-normalization

I haven't opened a PR yet, but can do so if this approach looks reasonable.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the LF-only Program.cs reproduction and inspect GetSummary(), GetParams(), and Emitter.EmitRun, where the issue traces newline handling. Run the repro and existing generator tests on Windows with LF-only input. Done means multiline summaries retain their /// prefixes and the generated code builds for common line endings.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.