Repository navigation
refactor: define the file header and collection materialiser once - #440
Open
kevin-mcmanus wants to merge 1 commit into
Open
kevin-mcmanus wants to merge 1 commit into
kevin-mcmanus wants to merge 1 commit into
Conversation
Two helpers existed in several copies across the generators. The auto-generated file header had four implementations (facet, flatten, wrapper, GenerateDtos). They were not identical: each named its own generator, GenerateDtos carried no version and appended #nullable enable, and flatten read the assembly version by reflection rather than through FacetConstants. So the shared helper takes the generator name and whether to include a version, and each call site keeps its exact previous text. WrapCollectionProjection — which maps a collection shape to its materialising call, and is the single place that decides which collection types are supported — was private to ExpressionBuilder. It moves to GeneratorUtilities, with ExpressionBuilder delegating to it. No behaviour change. Verified by emitting every generated file for Facet.Tests before and after: 823 files, byte-for-byte identical. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
kevin-mcmanus
marked this pull request as ready for review
October 12, 2026 14:46
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.
Small refactor. No behaviour change.
The generated-file header had four implementations —
CodeBuilder,FlattenCodeBuilder,WrapperCodeBuilder,GenerateDtosGenerator— and they were subtly different. Each named its own generator;GenerateDtoscarried no version and appended#nullable enable;FlattenCodeBuilderread the assembly version by reflection rather than throughFacetConstants. So a single shared header would have silently rewritten three generators' output. The shared helper takes the generator name and whether to include a version, and every call site keeps its exact previous text.WrapCollectionProjectionmaps a collection shape to its materialising call and is the single place deciding which collection types Facet supports. It wasprivatetoExpressionBuilder; it moves toGeneratorUtilities, withExpressionBuilderdelegating to it.Verified by emitting every generated file for
Facet.Testsonmasterand on this branch and diffing: 823 files, byte-for-byte identical.This PR supports my proposal for #143, which needs both helpers, but it stands on its own.
No test file is touched, and the suite passes — though the 823-file diff above is the stronger evidence.
Checklist
dotnet testlocally.