feat(generator): auto-discover and generate factories for nested types - #19
Draft
andreadelfante wants to merge 25 commits into
Draft
feat(generator): auto-discover and generate factories for nested types#19andreadelfante wants to merge 25 commits into
andreadelfante wants to merge 25 commits into
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…d resolver Also add test: explicit FakerType wins over nullable field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…aceType branch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…eld-map branch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ait generator Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…values Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t 3.x build_test 3.x stores asset outputs as raw bytes (List<int>), not strings. Wrap all contains(...) and allOf(contains(...)) output matchers in decodedMatches() so the string comparison works correctly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Escape backslashes and single quotes in string literal trait overrides to prevent generating invalid Dart syntax - Detect enum-typed constructor params and emit TODO placeholder instead of generating EnumFixture.factory().makeSingle() which does not compile - Guard @FixtureFor against abstract classes and non-ClassElement targets with an informative InvalidGenerationSourceError - Add bounds check on FakerType.values[enumIndex] deserialization - Validate trait names as legal Dart identifiers to prevent code injection - Add publish_to: none to suppress path-dependency pub warning Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This reverts commit 7eb7028.
…annotations - Fix FixtureGenerator to iterate annotationsOf() instead of annotatedWith() so multiple @FixtureFor on the same function are all processed (source_gen 1.5 annotatedWith uses firstAnnotationOf which skips subsequent annotations) - Remove duplicate GENERATED CODE header (LibraryBuilder already adds it) - Add example/ dart package: Dog (plain), User (Freezed+JSON), traits, fields override, lib and test fixtures, full build_runner workflow Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add packages table, generator approach docs, and FakerType reference to the main README. Add docs/migration/v3-to-v4.md (SDK bump, no API changes) and docs/migration/manual-to-generator.md (setup, before/after comparison, traits, hasJson). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When a model has fields of custom class type (single or List<T>), the generator now automatically produces a base FixtureFactory for each nested type without requiring an explicit @FixtureFor declaration. Discovery is recursive and hasJson propagates to nested types that expose toJson(). Explicit @FixtureFor always takes precedence. Adds Owner example model with nested User and List<Dog> to demonstrate the pattern, plus 6 generator tests and 4 example integration tests. Updates README and migration guide to document the new behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
andreadelfante
marked this pull request as draft
May 18, 2026 19:50
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add melos.yaml workspace with analyze/test/build/format scripts - Add root pubspec.yaml as Melos workspace root (not published) - Fix setup action: Dart 2.14 → 3.7, dart pub get → melos bootstrap, add pub-cache caching - Fix test/analyze workflows: use melos run instead of bare dart commands - Add example-build job to exercise build_runner end-to-end - Fix publish: replace single-package reusable workflow with OIDC + melos publish - Fix release: move if-guard from step to job level - Fix default: restrict push trigger to main+tags, fix cancel-in-progress to preserve tag pipelines - Remove publish_to:none from data_fixture_dart_generator, change path dep → ^1.0.0 - Add repository field to annotations and generator pubspecs - Renovate: config:base → config:recommended Co-Authored-By: Claude Opus 4.7 <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.
Summary
User user,List<Dog> dogs) and produces a baseFixtureFactoryfor each — no extra@FixtureForneededOwner → User → Address → Countryall get factories from a single annotationhasJson: truepropagates to nested types that exposetoJson(); nested types withouttoJson()fall back toFixtureFactory@FixtureForon a nested type always takes precedence — no duplicates generatedList<CustomType>element type is discovered and auto-generated; the list field itself defaults to[]in the definitionChanges
constructor_resolver.dart:ResolvedParamcarriescustomClassElementandlistElementClassElementfor tracking nested typesfixture_generator.dart: two-phase generation — explicit@FixtureForfirst, then recursive auto-gen loopexample/lib/models/owner.dart: new nested example model (User user,List<Dog> dogs)example/lib/fixtures.dart: registers@FixtureFor(Owner)—UserandDogare NOT re-declared (already explicit)README.md+manual-to-generator.md: document nested auto-discovery,hasJsonpropagation, and explicit-wins ruleTest plan
dart testinpackages/data_fixture_dart_generator— 37 tests pass (6 new nested auto-gen tests)dart testinexample/— 10 tests pass (4 newOwnerintegration tests)dart testinpackages/data_fixture_dart— 14 tests pass (no regressions)dart analyzeinexample/— no issues🤖 Generated with Claude Code