The GitHub Actions job "npm_and_yarn in /javascript for lodash - Update #1217573949" on fory.git/main has failed. Run started by GitHub user dependabot[bot] (triggered by dependabot[bot]).
Head commit for run: 8ef0bf5932d6044e9282dac4cec41f5bf17af502 / Ayush Kumar <[email protected]> feat(dart): add uint annotation types to the fory's codegen system (#3181) ## Why? While unsigned integer type annotations (`@Uint8Type`, `@Uint16Type`, `@Uint32Type`, `@Uint64Type`) were added in PR #3144, they were not integrated into the code generation system. This meant: * The annotation definitions existed but were not recognized by the code generator * No support for annotation-based type specification like `@Uint8Type() int age` in struct fields * Users couldn't use the protobuf/flatbuffer-style ergonomic API that was intended * No way to specify encoding variants (fixed vs varint) for uint32/uint64 via annotations during code generation ## What does this PR do? ### 1. Created Uint Annotation Analyzer Added `uint_annotation_analyzer.dart` to detect and parse uint type annotations during code generation: ```dart class UintAnnotationAnalyzer { UintAnnotationResult analyze( List<ElementAnnotation> metadata, LocationMark locationMark, ) { // Detects @Uint8Type, @Uint16Type, @Uint32Type, @Uint64Type // Extracts encoding options (fixed, varint, tagged) // Returns appropriate ObjType } } ``` **Supported annotations:** * `@Uint8Type()` → `ObjType.UINT8` * `@Uint16Type()` → `ObjType.UINT16` * `@Uint32Type()` → `ObjType.UINT32` * `@Uint32Type(encoding: UintEncoding.varint)` → `ObjType.VAR_UINT32` * `@Uint64Type()` → `ObjType.UINT64` * `@Uint64Type(encoding: UintEncoding.varint)` → `ObjType.VAR_UINT64` * `@Uint64Type(encoding: UintEncoding.tagged)` → `ObjType.TAGGED_UINT64` ### 2. Extended Type Identifier System Updated `analysis_type_identifier.dart` to recognize uint annotation types: ```dart static final List<Type3StringKey> _keys = [ // ... existing annotations Type3StringKey('Uint8Type', 'package', 'fory/src/annotation/uint_types.dart'), Type3StringKey('Uint16Type', 'package', 'fory/src/annotation/uint_types.dart'), Type3StringKey('Uint32Type', 'package', 'fory/src/annotation/uint_types.dart'), Type3StringKey('Uint64Type', 'package', 'fory/src/annotation/uint_types.dart'), ]; ``` ### 3. Integrated Annotation-Based Type Override Modified `type_analyzer_impl.dart` to support annotation-based type override: ```dart TypeSpecGen getTypeImmutableAndTagWithOverride( TypeDecision typeDecision, LocationMark locationMark, ObjType objTypeOverride, ) { // Uses annotation-specified ObjType instead of default type resolution } ``` ### 4. Updated Field Analyzer Modified `field_analyzer_impl.dart` to check for uint annotations: ```dart // Check for uint annotations final uintAnnotationResult = Analyzer.uintAnnotationAnalyzer.analyze( element.metadata, locationMark, ); if (uintAnnotationResult.hasAnnotation) { // Use annotation-based type override fieldType = Analyzer.typeAnalyzer.getTypeImmutableAndTagWithOverride( typeDecision, locationMark, uintAnnotationResult.objType!, ); } ``` ## Related issues Completes the unsigned integer annotation types support initiated in PR #3144 by integrating the annotations into the code generation system. ## Does this PR introduce any user-facing change? * [x] Does this PR introduce any public API change? * **Dart**: Users can now use `@Uint8Type()`, `@Uint16Type()`, `@Uint32Type()`, `@Uint64Type()` annotations on native `int` fields in `@ForyClass` structs * Enables encoding variant specification via `encoding` parameter for uint32/uint64 * Provides more ergonomic API: `@Uint8Type() int age` instead of `UInt8 age` * [ ] Does this PR introduce any binary protocol compatibility change? * No changes to binary encoding format * Uses existing ObjType mappings and serializers * Type IDs remain the same: UINT8 (40), UINT16 (41), UINT32 (42), VAR_UINT32 (43), UINT64 (44), VAR_UINT64 (45), TAGGED_UINT64 (46) ## Benchmark N/A - This PR only adds annotation processing during code generation (build-time). No runtime performance impact. --------- Co-authored-by: Shawn Yang <[email protected]> Report URL: https://github.com/apache/fory/actions/runs/21246318813 With regards, GitHub Actions via GitBox --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
