Skip to content

Nothing checks that a generated file still matches its generator #1034

Description

@Rafael-SOWNet

What is wrong

Several files in this repository are generated and checked in. Nothing rebuilds them and compares,
so a template can stop matching its output and the build stays green — the file is only discovered to
be unregenerable the next time somebody actually tries.

That happened. Sources/Utils/Utils/EquationSystemFunctionPattern.txt still said Tensor? long after
the type was renamed to Matrix?, so nobody could have regenerated AdditionalExtensions.cs as it
stood
; the same file had also silently lost its // This file is auto-generated banner. Both were
found only because #1029 needed to put documentation into the generator rather than into its output,
and both are repaired there.

What is and is not stale today

Measured on 6b93b401 (master, v2.3.0) with dotnet-t4, regenerating each template and diffing
against the committed file:

generator output result
Convenience/CompilationExtensions.tt CompilationExtensions.cs reproduces exactly
Functions/Compilation/Compile.Linq.Definition.tt Compile.Linq.Definition.cs reproduces exactly
Functions/Compilation/IntoLinq/MathAllMethods.tt MathAllMethods.cs reproduces exactly
Utils/ExtensionGenerator.cs + *.txt templates AdditionalExtensions.cs was stale; repaired by #1029
Core/Antlr/AngouriMath.g the ANTLR parser not measured here

In each of the three T4 cases the whole diff is the six-line copyright header, which no template
emits and which is added separately. So the T4 half is green today — and nothing would tell us
the day it stopped being.

What to build

A CI job that regenerates every checked-in generated file and fails if the result differs from what
is committed, ignoring the copyright header block that the generators do not produce.

  • dotnet tool install -g dotnet-t4, then run each .tt and diff. The three templates are listed in
    AngouriMath.csproj under <None Update="...tt">, so the job can read them from there rather than
    hard-coding a list that will itself go stale.
  • Run Sources/Utils/Utils for AdditionalExtensions.cs and the generated test file, and diff.
  • ANTLR is the awkward one and can be a second step or a separate issue: regeneration needs the ANTLR
    tool at a pinned version and AntlrPostProcessor.cs runs over the output, so getting a
    byte-reproducible result needs care. Do not include it until it is reproducible, because a gate
    that is red for reasons nobody can fix gets disabled.

Acceptance criteria

  1. The job is green on master after Give every member of AngouriMath.Extensions a worked, executed example (#585, #746 item 4) #1029 merges, and fails if a template is edited without its
    output being regenerated — demonstrated by pushing exactly that and showing the red.
  2. The failure message names the file and shows the diff, not just "files differ".
  3. The header block that generators do not emit is excluded deliberately and the exclusion is
    commented, so it cannot quietly grow to hide a real difference.
  4. It does not require a tool the other jobs cannot install.

Dependencies

#1029 must merge first — it is what makes the Utils generator reproducible again. The T4 half
could land before it, but a gate that covers half the generators and is silent about the half that
actually broke is the wrong shape; better to land it whole.

Independent of everything else currently open. Relates to
#746's third standing condition —
correctness coverage grows with the surface — and to its item 77.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions