Allow Dart macros to generate a single package-relative library - #9
Merged
Merged
Conversation
…ases A definition with nothing beside it used to generate nothing, and every project that wanted model classes wrote and maintained its own Mustache. There is now one model template, shipped in the binary, used wherever a diagram generates model classes. Every record and every union case comes out of it as an immutable value — ==, hashCode, toString, copyWith — built by the same Rust that builds them for @dmx('model'), so the annotated path and the diagram path cannot say different things about the same type. JSON is never a member of a generated class: it goes on an `extension <Name>Json`, and nested decodes name the extension. The runtime import is prefixed, so a diagram that declares its own Result, Ok or Err cannot hide the one the codec means. Union cases are named the way typeDiagram's own emitters name them — the case's own name — and take their union's name as a prefix only where Dart's single namespace forces it: `Ok` belongs to two unions in the parity corpus, and `String` is Dart's own. A case with neither name available is refused (DMX8010) rather than generated as two classes under one name. That alignment is what tdbin interop needs. Also brings the duplication gate back under its budget. It was breached at 7.6% before this branch: the typeDiagram goldens join the generated-output list already in .deslop.toml, the two typeDiagram suites share one Workspace fixture, and several test bodies that differed only in their data are table-driven. The budget ratchets 7.0 -> 6.8.
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.
TLDR
Let Dart macros emit one ordinary library at a safe package-relative path, unblocking NAP's single-file Flutter SDK.
Details
How Do The Automated Tests Prove It Works?
For AI
Fixes #7. The runtime wire shape is unchanged. This supports a real Dart DmxMacro returning DmxGeneratedFile, not a Python code-generation layer. Issue #8 separately tracks inline --insert-regions behavior.