Preprocess T4 templates at build time - #95
Merged
Merged
Conversation
Templates were preprocessed only by Visual Studio's "Run Custom Tool", with the resulting .cs files checked in. A .tt edit made outside VS built and ran the old logic silently. The generator csproj now runs the pinned dotnet-t4 local tool over every Templates\**\*.tt before compiling, emitting a gitignored <Template>.g.cs beside each template. Editing a .tt and building is the whole loop, on any platform or IDE, and compile errors in template code point at the .tt file and line. Turning this on surfaced one dormant edit: ScalarTemplate.tt referenced a non-existent GraphqlType.ScalarTypeName and had never been regenerated, so it had never compiled. Changed to scalarType.Name, matching the behaviour the shipped output already had. Note this activates template edits that were written but never preprocessed: generated clients now carry XML doc comments, an ArgumentNullException guard on the client constructor and tidier indentation. The checked-in TestClient/TestClientNullable are left as they are; refreshing them is separate work. Co-Authored-By: Claude Opus 5 (1M context) <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.
Templates were preprocessed only by Visual Studio's "Run Custom Tool", with the resulting .cs files checked in. A .tt edit made outside VS built and ran the old logic silently.
The generator csproj now runs the pinned dotnet-t4 local tool over every Templates***.tt before compiling, emitting a gitignored .g.cs beside each template. Editing a .tt and building is the whole loop, on any platform or IDE, and compile errors in template code point at the .tt file and line.
Turning this on surfaced one dormant edit: ScalarTemplate.tt referenced a non-existent GraphqlType.ScalarTypeName and had never been regenerated, so it had never compiled. Changed to scalarType.Name, matching the behaviour the shipped output already had.
Note this activates template edits that were written but never preprocessed: generated clients now carry XML doc comments, an ArgumentNullException guard on the client constructor and tidier indentation. The checked-in TestClient/TestClientNullable are left as they are; refreshing them is separate work.