yash-agarwa-l opened a new pull request, #3482:
URL: https://github.com/apache/fory/pull/3482

   ## 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?
   
   - Adds @ForyEnumId(int id) for enum values
   - Registers ForyEnumId in analysis type detection
   - Updates enum analysis to collect IDs and emit build-time warnings for:
            - partial @ForyEnumId usage
            - duplicate IDs
   - Falls back to ordinal serialization when annotations are incomplete or 
duplicated
   - Extends EnumSpec with an optional idToValue map
   - Updates generated enum specs to include the ID map when valid
   - Updates EnumSerializer to use ID-based read/write when the map is present, 
otherwise keep ordinal behavior
   - Adds codegen and serializer tests
   
   ## 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/
   
   - [x] I included a completed [AI Contribution 
Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs)
 in this PR description and the required AI Usage Disclosure.
   - [x] I included the standardized AI Usage Disclosure block below.
   - [x] I can explain and defend all important changes without AI help.
   - [x] I reviewed AI-assisted code changes line by line before submission.
   - [x] I ran adequate human verification and recorded evidence (checks run 
locally or in CI, pass/fail summary, and confirmation I reviewed results).
   - [x] I added/updated tests and specs where required.
   - [x] I validated protocol/performance impacts with evidence when applicable.
   - [x] I verified licensing and provenance compliance.
   
   ## Does this PR introduce any user-facing change?
   - [x] Does this PR introduce any public API change?
             `@ForyEnumId` is a new annotation users will write in their code
             `ForyEnumId` class is publicly accessible
   - [ ] Does this PR introduce any binary protocol compatibility change?
   
   ## Benchmark
   General struct performance remained similar because those benchmarks do not 
exercise enum serialization paths.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to