Skip to content

Build tools: centralize code-gen indent handling in a CodeWriter#3121

Merged
mgravell merged 1 commit into
StackExchange:mainfrom
zhengyazhao:refactor/build-tools-code-writer
Jul 10, 2026
Merged

Build tools: centralize code-gen indent handling in a CodeWriter#3121
mgravell merged 1 commit into
StackExchange:mainfrom
zhengyazhao:refactor/build-tools-code-writer

Conversation

@zhengyazhao

Copy link
Copy Markdown
Contributor

Implements #3033 using the second sketch from the issue: a small builder-style CodeWriter wrapping the existing StringBuilder, replacing the per-method int indent + local NewLine() pattern in AsciiHashGenerator (4 occurrences).

On the IndentedTextWriter option: its indent-on-next-write semantics would subtly change emitted whitespace. Since there was no functional win to justify that, I kept the StringBuilder core so the change is provably inert. (The preamble in Generate intentionally still writes to the raw StringBuilder to keep the diff minimal.)

Verification: captured generated output (EmitCompilerGeneratedFiles) before and after — AsciiHash.generated.cs (1,835 lines) is byte-for-byte identical; full solution builds with zero warnings; RESPite.Tests pass (1717/1717).

Closes #3033

…ckExchange#3033)

Replaces the per-method 'int indent + local NewLine()' pattern in
AsciiHashGenerator with a small builder-style CodeWriter wrapping the
existing StringBuilder, per the second sketch in StackExchange#3033. Generated
output is byte-for-byte identical.
@mgravell

mgravell commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Seems fine.. similar to some related code in my other libs... I can't think of a reason not to...

@mgravell
mgravell merged commit b334dcf into StackExchange:main Jul 10, 2026
3 of 5 checks passed
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.

Busywork: build-tools; investigate / refactor to use IndentedTextWriter

2 participants