Repository navigation
docs: the READMEs show the generated code for OrderId, Email and a closed set - #104
Merged
Merged
Conversation
…osed set Gael Fraiteur of Metalama suggested showing the generated code for the simple cases (metalama/Metalama discussion 2305). The root README shows what OrderId gets, and the Generators README what Email and OrderStatus get, each in a collapsed block beside where the page declares it: the field, the private constructor, Value, From or TryFrom, FromKnownGood and Revalidate, CompareTo and ToString; for the closed set the static constructor that names the members, Name and Match. The blocks are trimmed, not pasted. The woven code is fully qualified, puts attributes on every member and casts on every returned expression: OrderId alone is about 200 lines, and AspectTesting's expected files are no shorter (spike, #93). So the check compares reading forms. The samples project sets MetalamaEmitCompilerTransformedFiles, and GeneratedCodeBlockTests (conventions) holds each block marked <!-- not compiled: generated code for {file}, trimmed (GeneratedCodeBlockTests) --> to the woven form of that sample file: every member shown, body included, and every interface of its base list, after both sides lose attributes, comments, namespace qualifiers, casts and this., and System.String reads as string. A block may leave members out, and says so in a comment. Seeded: a From body changed in the root README fails, printing the block's member and the generated one. A_member_that_differs_is_found holds the comparison to a wrong body, an extra member and an interface the woven base list lacks. Closes #92 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 #92
Problem
The READMEs said in words what the generators add. Gaël Fraiteur of Metalama suggested showing the generated code for the simple cases instead (discussion 2305).
Change
OrderId: the field, the private constructor,Value,From,CompareToandToString.Email(TryFrom,FromKnownGoodandRevalidate, each callingCreate) and forOrderStatus(the static constructor that names the members,Name,Match).MetalamaEmitCompilerTransformedFiles.GeneratedCodeBlockTests(conventions): a block marked<!-- not compiled: generated code for {file}, trimmed (GeneratedCodeBlockTests) -->is held to the woven form of that sample file. Every member shown, body included, and every interface in its base list has to be in it.The blocks are trimmed, not pasted. The woven code is fully qualified, carries attributes on every member and casts on every returned expression, and
OrderIdalone is about 200 lines. AspectTesting's expected files are no shorter (#93). So both sides are compared in a reading form: no attributes, comments, namespace qualifiers, casts orthis., andSystem.Stringreads asstring. Hence the issue's "what the build emits" holds member by member, after that normalisation.Tests
Frombody changed in the root README, the test fails and prints the shown member beside the generated one.A_member_that_differs_is_foundpins the comparison on a fixture: a wrong body, an extra member, and an interface the woven base list lacks.🤖 Generated with Claude Code