LouisLou2 commented on code in PR #2112:
URL: https://github.com/apache/fury/pull/2112#discussion_r2006855590
##########
dart/README.md:
##########
@@ -1,2 +1,218 @@
-A sample command-line application with an entrypoint in `bin/`, library code
-in `lib/`, and example unit test in `test/`.
+# Fury Dart
+
+## Overview
+
+This PR adds Dart language support to Apache Fury, implementing a
comprehensive serialization solution for Dart and Flutter applications. Fury
Dart consists of approximately 15,000 lines of code and provides an efficient
serialization mechanism that works within Flutter's reflection limitations.
+
+## Implementation Approach
+
+Dart supports reflection, but Flutter explicitly prohibits it. To address this
constraint, Fury Dart uses a combination of:
+
+1. Core serialization/deserialization logic
+2. Static code generation for type handling
+
+This approach ensures compatibility with Flutter while maintaining the
performance and flexibility expected from Fury.
+
+## Features
+
+- XLANG mode support for cross-language serialization
+- Reference tracking for handling object graphs
+- Support for primitive types, collections, and custom classes
+- Serializer registration system
+- Code generation for class and enum serialization
+- Support for nested collections with automatic generic type conversion
+- Custom serializer registration
+- Support for using ByteWriter/ByteReader as serialization sources
+
+## Usage Examples
+
+### Basic Class Serialization
+
+```dart
+import 'package:fury_core/fury_core.dart';
+
+part 'some_class.g.dart';
+
+@furyClass
+class SomeClass with _$SomeClassFury {
+ late int id;
+ late String name;
+ late Map<String, double> map;
+
+ SomeClass(this.id, this.name, this.map);
+
+ SomeClass.noArgs();
+}
+```
+
+After annotating your class with `@furyClass`, run:
+
+```bash
+dart run build_runner build
+```
+
+This generates the necessary code in `some_class.g.dart` and creates the
`_$SomeClassFury` mixin.
+
+### Serializing and Deserializing
+
+```dart
+Fury fury = Fury(
+ xlangMode: true,
Review Comment:
Indeed, considering Dart's type system, I believe XLANG mode can cover most
serialization scenarios. The Dart official library provides a considerably more
streamlined set of types compared to Java. In fact, to support certain XLANG
types, we've had to implement some custom types in our Fury Dart implementation.
There are a few types worth discussing:
**Types currently in Fury but without XLANG support:**
- DateTime (Dart's primary temporal type, equivalent to Java's LocalDateTime)
- Duration (not yet supported in XLANG)
- Decimal (not provided by Dart core, but available via mature community
packages like [decimal](https://pub.dev/packages/decimal))
**Types not mentioned in Fury's type system:**
1. BigInt (from dart:core)
2. Dart Record (similar to Java 14's record type) - I should note that I've
encountered challenges using Fury with Java 14+ versions, seemingly due to
`Unsafe` support issues.(If I got it wrong at this point, please let me know)
3. Uri (from dart:core)
I believe it's feasible to use the XLANG approach for types that currently
lack XLANG support without significant issues. Looking at the overall picture,
XLANG mode already provides high coverage of data types needed for most Dart
serialization scenarios.
Given this analysis, it seems reasonable to focus our efforts on XLANG mode
rather than implementing a separate native serialization approach.
--
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]