Default to LF line endings, and add a local SonarCloud reproduction - #90
Merged
Merged
Conversation
CodeBlocker writes through IndentedTextWriter, which terminates lines with Environment.NewLine. That made the same calls produce different bytes on different machines, and generated code is almost always committed, diffed, or compared against a golden file — all of which want reproducibility more than they want the local convention. Callers had to remember to pass NewLines.Lf, and forgetting was silent. Flip the default: CodeBlocker.DefaultNewLineString is NewLines.Lf, used by every constructor and factory overload that does not take a terminator, and substituted for a null one. NewLines.Host is still there as the opt-in for callers who genuinely want the platform terminator. This is a breaking change for anyone on Windows relying on the old default, hence [major]. Tests asserted against Environment.NewLine throughout, which passes on Linux for the wrong reason and would have hidden the Windows break entirely. They now assert against CodeBlocker.DefaultNewLineString, and NewLineTests covers both that the default is LF regardless of host and that the host terminator is still reachable by asking for it. Closes #89 Co-Authored-By: Claude <noreply@anthropic.com>
CI analyses this repository with the SonarCloud scanner, which injects the Sonar analyzers into the compilation. A plain `dotnet build` does not run them, so findings are invisible locally and only surface after a push — and the bot comment links to a dashboard rather than naming them. That bit #87: the gate passed but reported three new issues with no way to see what they were. Add an opt-in .sonarlint/ that nothing imports automatically: dotnet build -p:CustomAfterMicrosoftCommonProps=$PWD/.sonarlint/sonar-local.props Note "After", not "Before". Every project here declares its SDK with <Sdk Name="..." /> elements rather than the <Project Sdk="..."> attribute, and CustomBeforeMicrosoftCommonProps does not reach that form — the reason the equivalent setup in ktsu.Semantics only ever reached one project. This is what identified #87's three findings (two S3267, one S3878) and let them be fixed before the next push. Known gap, recorded in the globalconfig and CLAUDE.md: SonarCloud reported one new issue on #87 that this configuration does not reproduce. sonarcloud.io is not reachable from the agent sandbox, so the rule behind it could not be identified and the calibration criterion in #88 is not met. CLAUDE.md also picks up the architecture refresh the merged work left it owing — the TextWriter constructors, the other scopes, the preamble helpers, the template object model, and the line-ending rule for tests. Co-Authored-By: Claude <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Closes #89. Addresses #88 — with one acceptance criterion I could not meet; see below.
#89 — LF becomes the default line terminator
[major]CodeBlockerwrites throughIndentedTextWriter, which terminates lines withEnvironment.NewLine. That made the same calls produce different bytes on different machines. Generated code is almost always committed, diffed, or compared against a golden file, and every one of those wants reproducibility more than it wants the local convention — so the deterministic terminator is the better default, and the old one is the thing worth opting into.CodeBlocker.DefaultNewLineStringisNewLines.Lf, used by every constructor and factory overload that does not take a terminator, and substituted for anullone.NewLines.Hostis unchanged and still reachable:CodeBlocker.Create(CodeBlocker.DefaultIndentString, NewLines.Host).[major]: anyone on Windows relying on the old default gets different bytes out.The test suite was asserting the bug into place. Every expectation was written against
Environment.NewLine, which on a Linux runner is LF — so the suite would have gone green on this change while Windows silently broke. All of them now assert againstCodeBlocker.DefaultNewLineString, andNewLineTestsgained explicit coverage that the default is LF regardless of host and that the host terminator is still available by asking for it.README.mdis reworded to match:NewLines.Hostis presented as the opt-in rather than the default, the samples drop the now-redundant explicitNewLines.Lfargument, and the API reference gains a Constants table.#88 — local SonarCloud reproduction
[patch]CI runs the Sonar analyzers via the SonarCloud scanner; a plain
dotnet builddoes not, so findings only surface after a push and the bot comment links to a dashboard rather than naming them..sonarlint/wires the same analyzers into a local build, imported by nothing and pointed at explicitly:dotnet build -p:CustomAfterMicrosoftCommonProps=$PWD/.sonarlint/sonar-local.propsAfter, notBefore. Every project here declares its SDK with<Sdk Name="..." />elements rather than the<Project Sdk="...">attribute, andCustomBeforeMicrosoftCommonPropsdoes not reach that form — which is exactly why the equivalent setup inktsu.Semanticsonly ever reached one of its projects. That repo'sCLAUDE.mdrecords the limitation but not the fix.This is what identified #87's three findings (two
S3267, oneS3878) and let them be fixed before the next push.Criterion not met
I can't confirm this.
sonarcloud.iois unreachable from this sandbox (the proxy returns 403 on CONNECT), so there's no dashboard read to calibrate against, and the one unidentified finding from #87 is still unidentified. What's here is the Semantics globalconfig withS1481left enabled andS3267/S2699raised because CI named them on #87 — a starting point, not a verified match. The gap is recorded in bothsonar-local.globalconfigandCLAUDE.mdso it doesn't read as calibrated when it isn't. Leave #88 open for whoever has dashboard access to close it.Also
CLAUDE.mdpicks up the architecture refresh the merged work left it owing: theTextWriterconstructors, the other scopes, the preamble helpers, the template object model, and theWriteLineNoTabspending-tab trap. It also now states the line-ending rule for tests, which is the thing that would have caught the false green above.Verification
S4144andS2699only in test files byte-identical tomain— nothing new from this change.Generated by Claude Code