The contract being violated
scripts/CheckStyle.ps1 states the intended relationship in its own header:
Declaration-run column alignment (CS0019) IS gated: it flags only runs
scripts/FixDeclAlign.ps1 can mechanically repair, and skips every shape that
parser does not understand.
and again inline:
scripts/FixDeclAlign.ps1: CS0019 skips any run this cannot parse, so the
gate only ever fires on runs the fixer can repair.
So running FixDeclAlign.ps1 -Apply on a flagged run should always clear the
flag. Anything else is a tooling bug, not a user error — the whole point of the
gating rule is that the fix is mechanical.
Observed
While implementing spec 019 (adding file and column to AssemblyError),
CS0019 fired on the declaration run. FixDeclAlign.ps1 -Apply rewrote the run
and the checker still rejected it. Resolved by deleting the inline trailing
comments on the declarations, at which point the fixer's output passed.
Likely mechanism (not yet confirmed)
The two scripts share an identical declaration regex — CheckStyle.ps1:700 and
FixDeclAlign.ps1:17 are the same string — so they agree on which lines form
a run. The divergence is in what happens to a trailing comment.
FixDeclAlign.ps1 strips the comment, aligns the declaration body, then
re-appends the comment at a fixed three-space offset:
# FixDeclAlign.ps1:28-32
# Strip trailing comment, then the semicolon.
$m = [regex]::Match($Line, '\s*(//.*)$')
if ($m.Success) { $comment = $m.Groups[1].Value; $body = $Line.Substring(0, $m.Index) }
# FixDeclAlign.ps1:170
if ($p.Comment -ne '') { $s += ' ' + $p.Comment }
A fixed three-space gap after each ; leaves the comments themselves ragged
whenever the declarations differ in length. If CS0019's run analysis treats the
trailing comment as another aligned column, the fixer's output is misaligned by
the checker's own standard and the gate fires again — which matches the observed
behavior and matches the fact that deleting the comments made it pass.
Needs confirming against the CS0019 alignment implementation before fixing.
Why it is worth fixing rather than working around
The stated contract is what makes CS0019 acceptable as a hard gate: a violation
is mechanically repairable, so the gate costs a command rather than judgment.
When the fixer cannot clear it, the developer is left guessing at an alignment
rule with no tool that expresses it — and the workaround they reach for is
deleting comments, which loses information to satisfy a formatter.
Repro sketch
Construct a declaration run whose members differ in length and carry trailing
// comments, misalign it, run FixDeclAlign.ps1 -Apply, then run
CheckStyle.ps1. Expected: clean. Observed (per the spec-019 session): CS0019
still fires.
Possible fixes
- Have
FixDeclAlign align the comment column too, rather than emitting a fixed
three-space gap.
- Or have CS0019 ignore the comment column entirely, so the fixer's output is
correct by the checker's standard.
Either closes the gap; the first preserves more of the house style, the second
is the smaller change. What matters is that the two agree, since the gate's
legitimacy rests on that.
The contract being violated
scripts/CheckStyle.ps1states the intended relationship in its own header:and again inline:
So running
FixDeclAlign.ps1 -Applyon a flagged run should always clear theflag. Anything else is a tooling bug, not a user error — the whole point of the
gating rule is that the fix is mechanical.
Observed
While implementing spec 019 (adding
fileandcolumntoAssemblyError),CS0019 fired on the declaration run.
FixDeclAlign.ps1 -Applyrewrote the runand the checker still rejected it. Resolved by deleting the inline trailing
comments on the declarations, at which point the fixer's output passed.
Likely mechanism (not yet confirmed)
The two scripts share an identical declaration regex —
CheckStyle.ps1:700andFixDeclAlign.ps1:17are the same string — so they agree on which lines forma run. The divergence is in what happens to a trailing comment.
FixDeclAlign.ps1strips the comment, aligns the declaration body, thenre-appends the comment at a fixed three-space offset:
A fixed three-space gap after each
;leaves the comments themselves raggedwhenever the declarations differ in length. If CS0019's run analysis treats the
trailing comment as another aligned column, the fixer's output is misaligned by
the checker's own standard and the gate fires again — which matches the observed
behavior and matches the fact that deleting the comments made it pass.
Needs confirming against the CS0019 alignment implementation before fixing.
Why it is worth fixing rather than working around
The stated contract is what makes CS0019 acceptable as a hard gate: a violation
is mechanically repairable, so the gate costs a command rather than judgment.
When the fixer cannot clear it, the developer is left guessing at an alignment
rule with no tool that expresses it — and the workaround they reach for is
deleting comments, which loses information to satisfy a formatter.
Repro sketch
Construct a declaration run whose members differ in length and carry trailing
//comments, misalign it, runFixDeclAlign.ps1 -Apply, then runCheckStyle.ps1. Expected: clean. Observed (per the spec-019 session): CS0019still fires.
Possible fixes
FixDeclAlignalign the comment column too, rather than emitting a fixedthree-space gap.
correct by the checker's standard.
Either closes the gap; the first preserves more of the house style, the second
is the smaller change. What matters is that the two agree, since the gate's
legitimacy rests on that.