feat(dart): add external-type serialization - #3886
Merged
chaokunyang merged 8 commits intoJul 27, 2026
Merged
Conversation
chaokunyang
marked this pull request as ready for review
July 26, 2026 23:55
chaokunyang
requested review from
LiangliangSui,
ayush00git,
pandalee99 and
urlyy
July 26, 2026 23:55
pandalee99
approved these changes
Jul 27, 2026
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.
Why?
Dart classes owned by dependencies cannot carry Fory annotations. Applications
need generated serializers for those types without copying values into local
models or adding a second registration, carrier, root, or polymorphic path.
What does this PR do?
ForyStruct.targetand constructor selection so anabstract finallocal schema declaration generates a direct serializer for a closed external
class.
registration, field descriptors, carrier codecs, root APIs, reference
resolver, compatible reads, and polymorphic registration.
validates the external contract at generation time, including generic type
rendering, re-exported nullable aliases, and constructor-cycle constraints.
registration, polymorphism, references, compatible mode, generic targets,
Java-to-Dart xlang exchange, and JavaScript compilation.
APIs without migration or removed-API material.
Related issues
N/A
AI Contribution Checklist
AI Usage Disclosure
Does this PR introduce any user-facing change?
The public Dart annotation API adds optional
targetandconstructorarguments to
ForyStruct. The wire format is unchanged.Verification
cd dart/packages/fory && dart run build_runner build && dart analyze && dart testcd dart/packages/fory-test && dart run build_runner build && dart analyze && dart testcd dart && dart analyze && dart testcd dart/packages/external-type-test-models && dart analyzedart compile jsfordart/packages/fory-test/tool/external_type_js_smoke.dart, followed by Nodeexecution
FORY_DART_JAVA_CI=1 ENABLE_FORY_DEBUG_OUTPUT=1 mvn -T16 --no-transfer-progress test -Dtest=org.apache.fory.xlang.DartXlangTestBenchmark
Fresh
apache/mainordinary benchmarks were run in adjacent baseline/currentpairs. Every retained median met the less-than-1% slowdown gate, and the
generated ordinary benchmark source was byte-identical.
Equivalent ordinary/external generated paths were measured in AOT mode with
split debugging data:
Negative values are slowdowns; every slowdown is below 1%. Serialized bytes
and normalized generated serializer bodies matched. The fixed-iteration VM
allocation check reported identical per-class object counts for all eight
serialize/deserialize lanes at 1,000 iterations.