Write codegen outputs as explicit UTF-8 - #1720
Conversation
ReviewReviewed the diff for #1720. This is a scoped, Code quality
Correctness
Test coverage
Other
Overall this looks like a clean, well-motivated, low-risk internal tooling improvement. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1720 +/- ##
======================================
Coverage 98% 98%
======================================
Files 514 514
Lines 24141 24141
======================================
Hits 23748 23748
Misses 393 393
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Review: Write codegen outputs as explicit UTF-8Scope check: this only touches Breaking changesNone. New quantities or unitsN/A — not touched by this PR. Generated codeNo generated files changed, and that's expected rather than a gap: Potential bug: encoding switched from "throw on invalid bytes" to "silently replace"
new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)Per the Practical effect: internal static readonly Encoding Utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);StyleUsing-directive ordering nit in Code quality
Test coverageNo Performance / securityNo concerns — |
Motivation
CodeGen currently relies on default file encodings from
File.WriteAllText,File.CreateText,StreamWriter, and related read helpers. Those defaults can differ by runtime/API history and make generated output encoding/BOM behavior less obvious than it should be.We want generated output to be stable across platforms and avoid review noise from UTF-8 BOM differences.
Changes
CodeGenFilehelper that reads text as UTF-8 and detects an existing BOM, but writes generated/codegen-normalized files as explicit UTF-8 without BOM.Validation
dotnet build CodeGen\CodeGen.csprojgenerate-code.bat