Skip to content

Retire GeneratedSource once CodeBlocker emits deterministic newlines #184

Description

@matt-edmondson

Summary

GeneratedSource.cs exists solely to undo a CodeBlocker behaviour:

internal static string NormalizeLineEndings(string source) =>
    source.Replace("\r\n", "\n").Replace("\n", "\r\n");

Its own remarks say why:

ktsu.CodeBlocker writes through IndentedTextWriter, which uses Environment.NewLine — so the same metadata produced CRLF output on Windows and LF output on Linux. Generator output under Semantics.Quantities/Generated/ is committed to the repository and verified by CI, so it has to be byte-identical regardless of who builds it.

That is a workaround for a gap in the writer, not a Semantics concern. ktsu-dev/CodeBlocker#81 fixes it at the source.

Tasks

  • Once Make output line endings deterministic and configurable CodeBlocker#81 ships, configure the newline at CodeBlocker construction (CRLF, to match end_of_line = crlf in .editorconfig and *.cs text eol=crlf in .gitattributes).
  • Delete NormalizeLineEndings and either delete GeneratedSource.Add or keep it as a thin context.AddSource wrapper if it earns its place.
  • Related: the template model's body-layout logic splits on Environment.NewLine (Close the correctness and coverage gaps in the C# template object model CodeBlocker#85, item 4). That is a second host dependency the normalization pass does not fix — a method body assembled on Linux can be laid out differently from the same body on Windows, and post-hoc newline rewriting cannot undo a layout decision. Confirm this is closed out before deleting the pass.
  • Consider whether verify-generated.yml can then drop runs-on: windows-latest — it is pinned there today only so git's autocrlf matches the committed CRLF endings.

Acceptance criteria

  • Building Semantics.Quantities on Linux and on Windows produces byte-identical files under Generated/.
  • verify-generated passes with no normalization pass in the generator.

Context

Part of #181. Blocked on ktsu-dev/CodeBlocker#81 and ktsu-dev/CodeBlocker#85.

Activity

  1. added a commit that references this issue on Sep 15, 2026
    55f4f4b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions