feat(dart): Introduce id based enum serialization#3482
Open
yash-agarwa-l wants to merge 8 commits intoapache:mainfrom
Open
feat(dart): Introduce id based enum serialization#3482yash-agarwa-l wants to merge 8 commits intoapache:mainfrom
yash-agarwa-l wants to merge 8 commits intoapache:mainfrom
Conversation
analyze if the input is valid and pass to spec update EnumSpec to support idToValue map for id-based enum serialization
30a3919 to
1c56dfe
Compare
Contributor
Author
|
Firstly, Thank you sm for the clarification about this in the discussions, it took some time to complete it.
|
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?
The Dart module, only supports ordinal enum serialization, where each enum
value is serialized as its position index (0, 1, 2...), which breaks in different
cases like adding or reordering values. This adds optional id based serialization
with so that we can provide unique id to every while preserving ordinal serialization
as the default fallback.
What does this PR do?
- partial @ForyEnumId usage
- duplicate IDs
Related issues
AI Contribution Checklist
AI Usage Disclosure
AI assistance was used to suggest tests and for better warnings in enum_analyzer.
dart/packages/fory/lib/src/codegen/analyze/impl/struct/enum_analyzer_impl.dart
dart/packages/fory-test/test/
Does this PR introduce any user-facing change?
@ForyEnumIdis a new annotation users will write in their codeForyEnumIdclass is publicly accessibleBenchmark
General struct performance remained similar because those benchmarks do not exercise enum serialization paths.