You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by ch...@apache.org on 2026/04/19 16:33:58 UTC
(fory-site) branch main updated: Release 0.17.0 (#441)
This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory-site.git
The following commit(s) were added to refs/heads/main by this push:
new 784978835 Release 0.17.0 (#441)
784978835 is described below
commit 784978835dca77e7888ccb2f27d56fca7ec056ac
Author: Shawn Yang <sh...@gmail.com>
AuthorDate: Mon Apr 20 00:33:54 2026 +0800
Release 0.17.0 (#441)
---
.claude/skills/release-major-version/SKILL.md | 278 ++++
blog/2026-03-17-fory_0_16_0_release.md | 2 +-
blog/2026-04-19-fory_0_17_0_release.md | 296 ++++
docs/guide/java/compression.md | 2 +-
docs/guide/rust/index.md | 2 +-
docs/guide/xlang/getting-started.md | 2 +-
docs/start/install.md | 30 +-
docs/start/usage.md | 4 +-
docusaurus.config.ts | 3 +-
.../version-0.17/.keep | 0
.../2026-04-19-fory_0_17_0_release.md | 286 ++++
.../current/benchmarks/cpp/README.md | 110 +-
.../current/benchmarks/dart/README.md | 73 +
.../current/benchmarks/dart/mediacontent.png | Bin 0 -> 52584 bytes
.../current/benchmarks/dart/mediacontentlist.png | Bin 0 -> 55357 bytes
.../current/benchmarks/dart/sample.png | Bin 0 -> 42105 bytes
.../current/benchmarks/dart/samplelist.png | Bin 0 -> 51598 bytes
.../current/benchmarks/dart/struct.png | Bin 0 -> 38645 bytes
.../current/benchmarks/dart/structlist.png | Bin 0 -> 44541 bytes
.../current/benchmarks/dart/throughput.png | Bin 0 -> 89092 bytes
.../current/benchmarks/javascript/README.md | 104 ++
.../current/benchmarks/javascript/mediacontent.png | Bin 0 -> 55168 bytes
.../benchmarks/javascript/mediacontentlist.png | Bin 0 -> 56815 bytes
.../current/benchmarks/javascript/sample.png | Bin 0 -> 57185 bytes
.../current/benchmarks/javascript/samplelist.png | Bin 0 -> 57215 bytes
.../current/benchmarks/javascript/struct.png | Bin 0 -> 50777 bytes
.../current/benchmarks/javascript/structlist.png | Bin 0 -> 54735 bytes
.../current/benchmarks/javascript/throughput.png | Bin 0 -> 81947 bytes
.../current/benchmarks/python/README.md | 102 +-
.../current/benchmarks/rust/README.md | 195 ++-
.../current/benchmarks/rust/mediacontent.png | Bin 0 -> 54130 bytes
.../current/benchmarks/rust/mediacontentlist.png | Bin 0 -> 54154 bytes
.../current/benchmarks/rust/sample.png | Bin 0 -> 44641 bytes
.../current/benchmarks/rust/samplelist.png | Bin 0 -> 46992 bytes
.../current/benchmarks/rust/struct.png | Bin 0 -> 49558 bytes
.../current/benchmarks/rust/structlist.png | Bin 0 -> 45987 bytes
.../current/benchmarks/rust/throughput.png | Bin 0 -> 75422 bytes
.../current/compiler/compiler-guide.md | 103 +-
.../current/compiler/generated-code.md | 351 ++++-
.../current/compiler/index.md | 18 +-
.../current/compiler/schema-idl.md | 195 ++-
.../current/guide/cpp/_category_.json | 2 +-
.../current/guide/cpp/index.md | 87 +-
.../guide/{scala => csharp}/_category_.json | 2 +-
.../current/guide/csharp/basic-serialization.md | 131 ++
.../current/guide/csharp/configuration.md | 124 ++
.../current/guide/csharp/cross-language.md | 105 ++
.../current/guide/csharp/custom-serializers.md | 84 ++
.../current/guide/csharp/field-configuration.md | 75 +
.../current/guide/csharp/index.md | 104 ++
.../current/guide/csharp/references.md | 72 +
.../current/guide/csharp/schema-evolution.md | 90 ++
.../current/guide/csharp/supported-types.md | 97 ++
.../current/guide/csharp/thread-safety.md | 73 +
.../current/guide/csharp/troubleshooting.md | 92 ++
.../current/guide/csharp/type-registration.md | 82 ++
.../current/guide/{xlang => dart}/_category_.json | 2 +-
.../current/guide/dart/basic-serialization.md | 144 ++
.../current/guide/dart/code-generation.md | 113 ++
.../current/guide/dart/configuration.md | 121 ++
.../current/guide/dart/cross-language.md | 193 +++
.../current/guide/dart/custom-serializers.md | 139 ++
.../current/guide/dart/field-configuration.md | 127 ++
.../current/guide/dart/index.md | 141 ++
.../current/guide/dart/schema-evolution.md | 92 ++
.../current/guide/dart/supported-types.md | 102 ++
.../current/guide/dart/troubleshooting.md | 103 ++
.../current/guide/dart/type-registration.md | 98 ++
.../current/guide/go/_category_.json | 2 +-
.../current/guide/go/codegen.md | 256 ++--
.../current/guide/go/index.md | 15 +-
.../current/guide/graalvm_guide.md | 55 +-
.../current/guide/java/_category_.json | 2 +-
.../current/guide/java/advanced-features.md | 2 +-
.../current/guide/java/compression.md | 66 +-
.../current/guide/java/configuration.md | 66 +-
.../current/guide/java/custom-serializers.md | 713 ++--------
.../current/guide/java/enum-configuration.md | 104 ++
.../current/guide/java/field-configuration.md | 7 +-
.../current/guide/java/index.md | 79 +-
.../current/guide/java/migration.md | 2 +-
.../current/guide/java/schema-evolution.md | 40 +-
.../current/guide/java/troubleshooting.md | 112 +-
.../current/guide/java/type-registration.md | 65 +-
.../current/guide/java/virtual-threads.md | 114 ++
.../guide/{cpp => javascript}/_category_.json | 4 +-
.../guide/javascript/basic-serialization.md | 219 +++
.../current/guide/javascript/cross-language.md | 128 ++
.../current/guide/javascript/index.md | 141 ++
.../current/guide/javascript/references.md | 111 ++
.../current/guide/javascript/schema-evolution.md | 99 ++
.../current/guide/javascript/supported-types.md | 177 +++
.../current/guide/javascript/troubleshooting.md | 105 ++
.../current/guide/javascript/type-registration.md | 200 +++
.../current/guide/kotlin/_category_.json | 2 +-
.../current/guide/kotlin/fory-creation.md | 14 +-
.../current/guide/kotlin/index.md | 36 +-
.../current/guide/python/_category_.json | 2 +-
.../current/guide/python/custom-serializers.md | 32 +-
.../current/guide/python/type-registration.md | 2 +-
.../current/guide/rust/_category_.json | 2 +-
.../current/guide/rust/index.md | 60 +-
.../current/guide/scala/_category_.json | 2 +-
.../current/guide/scala/fory-creation.md | 15 +-
.../current/guide/scala/index.md | 40 +-
.../guide/{kotlin => swift}/_category_.json | 2 +-
.../current/guide/swift/basic-serialization.md | 114 ++
.../current/guide/swift/configuration.md | 99 ++
.../current/guide/swift/cross-language.md | 97 ++
.../current/guide/swift/custom-serializers.md | 84 ++
.../current/guide/swift/field-configuration.md | 92 ++
.../current/guide/swift/index.md | 84 ++
.../current/guide/swift/polymorphism.md | 80 ++
.../current/guide/swift/references.md | 110 ++
.../current/guide/swift/row-format.md | 38 +
.../current/guide/swift/schema-evolution.md | 77 +
.../current/guide/swift/troubleshooting.md | 92 ++
.../current/guide/swift/type-registration.md | 76 +
.../current/guide/xlang/_category_.json | 2 +-
.../current/guide/xlang/getting-started.md | 76 +-
.../specification/java_serialization_spec.md | 4 +-
.../specification/xlang_implementation_guide.md | 553 +++++---
.../specification/xlang_serialization_spec.md | 2 +-
.../current/specification/xlang_type_mapping.md | 4 +-
.../current/start/install.md | 46 +-
.../current/start/usage.md | 4 +-
.../version-0.17/benchmarks/cpp/README.md | 104 ++
.../version-0.17/benchmarks/cpp/REPORT.md | 116 ++
.../version-0.17/benchmarks/cpp/mediacontent.png | Bin 0 -> 51863 bytes
.../benchmarks/cpp/mediacontentlist.png | Bin 0 -> 54504 bytes
.../version-0.17/benchmarks/cpp/sample.png | Bin 0 -> 48714 bytes
.../version-0.17/benchmarks/cpp/samplelist.png | Bin 0 -> 51686 bytes
.../version-0.17/benchmarks/cpp/struct.png | Bin 0 -> 47309 bytes
.../version-0.17/benchmarks/cpp/structlist.png | Bin 0 -> 48428 bytes
.../version-0.17/benchmarks/cpp/throughput.png | Bin 0 -> 73763 bytes
.../version-0.17/benchmarks/csharp/README.md | 129 ++
.../benchmarks/csharp/mediacontent.png | Bin 0 -> 53148 bytes
.../benchmarks/csharp/mediacontentlist.png | Bin 0 -> 52044 bytes
.../version-0.17/benchmarks/csharp/sample.png | Bin 0 -> 51280 bytes
.../version-0.17/benchmarks/csharp/samplelist.png | Bin 0 -> 55993 bytes
.../version-0.17/benchmarks/csharp/struct.png | Bin 0 -> 53639 bytes
.../version-0.17/benchmarks/csharp/structlist.png | Bin 0 -> 47081 bytes
.../version-0.17/benchmarks/csharp/throughput.png | Bin 0 -> 77537 bytes
.../version-0.17/benchmarks/dart/README.md | 73 +
.../version-0.17/benchmarks/dart/mediacontent.png | Bin 0 -> 52584 bytes
.../benchmarks/dart/mediacontentlist.png | Bin 0 -> 55357 bytes
.../version-0.17/benchmarks/dart/sample.png | Bin 0 -> 42105 bytes
.../version-0.17/benchmarks/dart/samplelist.png | Bin 0 -> 51598 bytes
.../version-0.17/benchmarks/dart/struct.png | Bin 0 -> 38645 bytes
.../version-0.17/benchmarks/dart/structlist.png | Bin 0 -> 44541 bytes
.../version-0.17/benchmarks/dart/throughput.png | Bin 0 -> 89092 bytes
.../version-0.17/benchmarks/go/README.md | 58 +
.../benchmarks/go/benchmark_combined.png | Bin 0 -> 193421 bytes
.../benchmarks/go/benchmark_mediacontent.png | Bin 0 -> 63179 bytes
.../benchmarks/go/benchmark_mediacontentlist.png | Bin 0 -> 75245 bytes
.../version-0.17/benchmarks/go/benchmark_report.md | 84 ++
.../benchmarks/go/benchmark_results.json | 184 +++
.../benchmarks/go/benchmark_results.txt | 326 +++++
.../benchmarks/go/benchmark_sample.png | Bin 0 -> 64836 bytes
.../benchmarks/go/benchmark_samplelist.png | Bin 0 -> 70519 bytes
.../benchmarks/go/benchmark_struct.png | Bin 0 -> 65532 bytes
.../benchmarks/go/benchmark_structlist.png | Bin 0 -> 63835 bytes
.../benchmarks/go/serialized_sizes.txt | 27 +
.../version-0.17/benchmarks/java/README.md | 239 ++++
.../java/data/jmh-jdk-11-deserialization.csv | 153 ++
.../java/data/jmh-jdk-11-serialization.csv | 153 ++
.../benchmarks/java/data/jmh-jdk-11-zerocopy.csv | 73 +
.../java/java_heap_deserialize_compatible.png | Bin 0 -> 99247 bytes
.../java/java_heap_deserialize_consistent.png | Bin 0 -> 107832 bytes
.../java/java_heap_serialize_compatible.png | Bin 0 -> 108196 bytes
.../java/java_heap_serialize_consistent.png | Bin 0 -> 106382 bytes
.../java/java_offheap_deserialize_compatible.png | Bin 0 -> 104602 bytes
.../java/java_offheap_deserialize_consistent.png | Bin 0 -> 108056 bytes
.../java/java_offheap_serialize_compatible.png | Bin 0 -> 119826 bytes
.../java/java_offheap_serialize_consistent.png | Bin 0 -> 121717 bytes
.../java/java_repo_deserialization_throughput.png | Bin 0 -> 116455 bytes
.../java/java_repo_serialization_throughput.png | Bin 0 -> 124190 bytes
.../benchmarks/java/java_zero_copy_deserialize.png | Bin 0 -> 98312 bytes
.../benchmarks/java/java_zero_copy_serialize.png | Bin 0 -> 98680 bytes
.../version-0.17/benchmarks/javascript/README.md | 104 ++
.../benchmarks/javascript/mediacontent.png | Bin 0 -> 55168 bytes
.../benchmarks/javascript/mediacontentlist.png | Bin 0 -> 56815 bytes
.../version-0.17/benchmarks/javascript/sample.png | Bin 0 -> 57185 bytes
.../benchmarks/javascript/samplelist.png | Bin 0 -> 57215 bytes
.../version-0.17/benchmarks/javascript/struct.png | Bin 0 -> 50777 bytes
.../benchmarks/javascript/structlist.png | Bin 0 -> 54735 bytes
.../benchmarks/javascript/throughput.png | Bin 0 -> 81947 bytes
.../version-0.17/benchmarks/python/README.md | 113 ++
.../benchmarks/python/mediacontent.png | Bin 0 -> 49948 bytes
.../benchmarks/python/mediacontentlist.png | Bin 0 -> 57263 bytes
.../version-0.17/benchmarks/python/sample.png | Bin 0 -> 53682 bytes
.../version-0.17/benchmarks/python/samplelist.png | Bin 0 -> 60171 bytes
.../version-0.17/benchmarks/python/struct.png | Bin 0 -> 54218 bytes
.../version-0.17/benchmarks/python/structlist.png | Bin 0 -> 52290 bytes
.../version-0.17/benchmarks/python/throughput.png | Bin 0 -> 79016 bytes
.../version-0.17/benchmarks/rust/README.md | 103 ++
.../version-0.17/benchmarks/rust/company.png | Bin 0 -> 44643 bytes
.../benchmarks/rust/ecommerce_data.png | Bin 0 -> 44956 bytes
.../version-0.17/benchmarks/rust/mediacontent.png | Bin 0 -> 54130 bytes
.../benchmarks/rust/mediacontentlist.png | Bin 0 -> 54154 bytes
.../version-0.17/benchmarks/rust/person.png | Bin 0 -> 40224 bytes
.../version-0.17/benchmarks/rust/sample.png | Bin 0 -> 44641 bytes
.../version-0.17/benchmarks/rust/samplelist.png | Bin 0 -> 46992 bytes
.../version-0.17/benchmarks/rust/simple_list.png | Bin 0 -> 39423 bytes
.../version-0.17/benchmarks/rust/simple_map.png | Bin 0 -> 45555 bytes
.../version-0.17/benchmarks/rust/simple_struct.png | Bin 0 -> 43007 bytes
.../version-0.17/benchmarks/rust/struct.png | Bin 0 -> 49558 bytes
.../version-0.17/benchmarks/rust/structlist.png | Bin 0 -> 45987 bytes
.../version-0.17/benchmarks/rust/system_data.png | Bin 0 -> 41417 bytes
.../version-0.17/benchmarks/rust/throughput.png | Bin 0 -> 75422 bytes
.../version-0.17/benchmarks/swift/README.md | 46 +
.../version-0.17/benchmarks/swift/throughput.png | Bin 0 -> 84759 bytes
.../version-0.17/community/community.md | 85 ++
.../community/how_to_join_community.md | 108 ++
.../version-0.17/community/how_to_release.md | 431 ++++++
.../version-0.17/community/how_to_verify.md | 119 ++
.../cpp => version-0.17/compiler}/_category_.json | 2 +-
.../compiler/compiler-guide.md | 103 +-
.../version-0.17/compiler/flatbuffers-idl.md | 183 +++
.../compiler/generated-code.md | 351 ++++-
.../{current => version-0.17}/compiler/index.md | 18 +-
.../version-0.17/compiler/protobuf-idl.md | 321 +++++
.../compiler/schema-idl.md | 195 ++-
.../version-0.17/guide/DEVELOPMENT.md | 146 ++
.../version-0.17/guide/_category_.json | 1 +
.../guide/cpp/_category_.json | 2 +-
.../version-0.17/guide/cpp/basic-serialization.md | 238 ++++
.../version-0.17/guide/cpp/configuration.md | 189 +++
.../version-0.17/guide/cpp/cross-language.md | 271 ++++
.../version-0.17/guide/cpp/custom-serializers.md | 371 +++++
.../version-0.17/guide/cpp/field-configuration.md | 504 +++++++
.../{current => version-0.17}/guide/cpp/index.md | 87 +-
.../version-0.17/guide/cpp/polymorphism.md | 480 +++++++
.../version-0.17/guide/cpp/row-format.md | 516 +++++++
.../version-0.17/guide/cpp/schema-evolution.md | 404 ++++++
.../version-0.17/guide/cpp/supported-types.md | 277 ++++
.../version-0.17/guide/cpp/type-registration.md | 225 +++
.../guide/csharp}/_category_.json | 2 +-
.../guide/csharp/basic-serialization.md | 131 ++
.../version-0.17/guide/csharp/configuration.md | 124 ++
.../version-0.17/guide/csharp/cross-language.md | 105 ++
.../guide/csharp/custom-serializers.md | 84 ++
.../guide/csharp/field-configuration.md | 75 +
.../version-0.17/guide/csharp/index.md | 104 ++
.../version-0.17/guide/csharp/references.md | 72 +
.../version-0.17/guide/csharp/schema-evolution.md | 90 ++
.../version-0.17/guide/csharp/supported-types.md | 97 ++
.../version-0.17/guide/csharp/thread-safety.md | 73 +
.../version-0.17/guide/csharp/troubleshooting.md | 92 ++
.../version-0.17/guide/csharp/type-registration.md | 82 ++
.../guide/dart}/_category_.json | 2 +-
.../version-0.17/guide/dart/basic-serialization.md | 144 ++
.../version-0.17/guide/dart/code-generation.md | 113 ++
.../version-0.17/guide/dart/configuration.md | 121 ++
.../version-0.17/guide/dart/cross-language.md | 193 +++
.../version-0.17/guide/dart/custom-serializers.md | 139 ++
.../version-0.17/guide/dart/field-configuration.md | 127 ++
.../version-0.17/guide/dart/index.md | 141 ++
.../version-0.17/guide/dart/schema-evolution.md | 92 ++
.../version-0.17/guide/dart/supported-types.md | 102 ++
.../version-0.17/guide/dart/troubleshooting.md | 103 ++
.../version-0.17/guide/dart/type-registration.md | 98 ++
.../guide/go/_category_.json | 2 +-
.../version-0.17/guide/go/basic-serialization.md | 404 ++++++
.../version-0.17/guide/go/codegen.md | 430 ++++++
.../version-0.17/guide/go/configuration.md | 339 +++++
.../version-0.17/guide/go/cross-language.md | 280 ++++
.../version-0.17/guide/go/custom-serializers.md | 285 ++++
.../{current => version-0.17}/guide/go/index.md | 15 +-
.../version-0.17/guide/go/references.md | 356 +++++
.../version-0.17/guide/go/schema-evolution.md | 340 +++++
.../version-0.17/guide/go/struct-tags.md | 335 +++++
.../version-0.17/guide/go/supported-types.md | 369 +++++
.../version-0.17/guide/go/thread-safety.md | 347 +++++
.../version-0.17/guide/go/troubleshooting.md | 448 ++++++
.../version-0.17/guide/go/type-registration.md | 260 ++++
.../guide/graalvm_guide.md | 55 +-
.../guide/java/_category_.json | 2 +-
.../guide/java/advanced-features.md | 2 +-
.../version-0.17/guide/java/basic-serialization.md | 137 ++
.../version-0.17/guide/java/compression.md | 136 ++
.../guide/java/configuration.md | 66 +-
.../version-0.17/guide/java/cross-language.md | 231 +++
.../version-0.17/guide/java/custom-serializers.md | 220 +++
.../version-0.17/guide/java/enum-configuration.md | 104 ++
.../guide/java/field-configuration.md | 7 +-
.../{current => version-0.17}/guide/java/index.md | 79 +-
.../guide/java/migration.md | 2 +-
.../version-0.17/guide/java/row-format.md | 183 +++
.../guide/java/schema-evolution.md | 40 +-
.../version-0.17/guide/java/troubleshooting.md | 203 +++
.../version-0.17/guide/java/type-registration.md | 113 ++
.../version-0.17/guide/java/virtual-threads.md | 114 ++
.../guide/javascript}/_category_.json | 4 +-
.../guide/javascript/basic-serialization.md | 219 +++
.../guide/javascript/cross-language.md | 128 ++
.../version-0.17/guide/javascript/index.md | 141 ++
.../version-0.17/guide/javascript/references.md | 111 ++
.../guide/javascript/schema-evolution.md | 99 ++
.../guide/javascript/supported-types.md | 177 +++
.../guide/javascript/troubleshooting.md | 105 ++
.../guide/javascript/type-registration.md | 200 +++
.../guide/kotlin/_category_.json | 2 +-
.../version-0.17/guide/kotlin/default-values.md | 137 ++
.../guide/kotlin/fory-creation.md | 14 +-
.../guide/kotlin/index.md | 36 +-
.../guide/kotlin/type-serialization.md | 184 +++
.../guide/python/_category_.json | 2 +-
.../guide/python/basic-serialization.md | 145 ++
.../version-0.17/guide/python/configuration.md | 181 +++
.../version-0.17/guide/python/cross-language.md | 140 ++
.../guide/python/custom-serializers.md | 32 +-
.../guide/python/field-configuration.md | 492 +++++++
.../version-0.17/guide/python/index.md | 160 +++
.../version-0.17/guide/python/migration.md | 85 ++
.../version-0.17/guide/python/numpy-integration.md | 103 ++
.../version-0.17/guide/python/out-of-band.md | 179 +++
.../version-0.17/guide/python/python-native.md | 205 +++
.../version-0.17/guide/python/row-format.md | 169 +++
.../version-0.17/guide/python/schema-evolution.md | 77 +
.../version-0.17/guide/python/security.md | 150 ++
.../version-0.17/guide/python/troubleshooting.md | 186 +++
.../guide/python/type-registration.md | 2 +-
.../guide/rust/_category_.json | 2 +-
.../version-0.17/guide/rust/basic-serialization.md | 166 +++
.../version-0.17/guide/rust/configuration.md | 125 ++
.../version-0.17/guide/rust/cross-language.md | 165 +++
.../version-0.17/guide/rust/custom-serializers.md | 147 ++
.../version-0.17/guide/rust/field-configuration.md | 460 ++++++
.../{current => version-0.17}/guide/rust/index.md | 60 +-
.../version-0.17/guide/rust/polymorphism.md | 232 +++
.../version-0.17/guide/rust/references.md | 213 +++
.../version-0.17/guide/rust/row-format.md | 126 ++
.../version-0.17/guide/rust/schema-evolution.md | 204 +++
.../version-0.17/guide/rust/troubleshooting.md | 164 +++
.../version-0.17/guide/rust/type-registration.md | 126 ++
.../guide/scala/_category_.json | 2 +-
.../version-0.17/guide/scala/default-values.md | 186 +++
.../guide/scala/fory-creation.md | 15 +-
.../{current => version-0.17}/guide/scala/index.md | 40 +-
.../version-0.17/guide/scala/type-serialization.md | 171 +++
.../guide/swift}/_category_.json | 2 +-
.../guide/swift/basic-serialization.md | 114 ++
.../version-0.17/guide/swift/configuration.md | 99 ++
.../version-0.17/guide/swift/cross-language.md | 97 ++
.../version-0.17/guide/swift/custom-serializers.md | 84 ++
.../guide/swift/field-configuration.md | 92 ++
.../version-0.17/guide/swift/index.md | 84 ++
.../version-0.17/guide/swift/polymorphism.md | 80 ++
.../version-0.17/guide/swift/references.md | 110 ++
.../version-0.17/guide/swift/row-format.md | 38 +
.../version-0.17/guide/swift/schema-evolution.md | 77 +
.../version-0.17/guide/swift/troubleshooting.md | 92 ++
.../version-0.17/guide/swift/type-registration.md | 76 +
.../guide/xlang/_category_.json | 2 +-
.../version-0.17/guide/xlang/field-nullability.md | 251 ++++
.../guide/xlang/field-reference-tracking.md | 260 ++++
.../version-0.17/guide/xlang/field-type-meta.md | 301 ++++
.../version-0.17}/guide/xlang/getting-started.md | 92 +-
.../version-0.17/guide/xlang/index.md | 125 ++
.../version-0.17/guide/xlang/row_format.md | 190 +++
.../version-0.17/guide/xlang/serialization.md | 542 +++++++
.../version-0.17/guide/xlang/troubleshooting.md | 321 +++++
.../version-0.17/guide/xlang/type-mapping.md | 113 ++
.../version-0.17/guide/xlang/zero-copy.md | 207 +++
.../version-0.17/introduction/_category_.json | 1 +
.../version-0.17/introduction/benchmark.md | 90 ++
.../version-0.17/introduction/features.md | 210 +++
.../version-0.17/introduction/overview.md | 200 +++
.../version-0.17/start/_category_.json | 1 +
.../{current => version-0.17}/start/install.md | 46 +-
.../{current => version-0.17}/start/usage.md | 4 +-
.../blog/fory_0_17_0_release/dart_throughput.png | Bin 0 -> 89092 bytes
.../fory_0_17_0_release/javascript_throughput.png | Bin 0 -> 81947 bytes
.../version-0.17/benchmarks/cpp/README.md | 104 ++
.../version-0.17/benchmarks/cpp/REPORT.md | 116 ++
.../version-0.17/benchmarks/cpp/mediacontent.png | Bin 0 -> 52226 bytes
.../benchmarks/cpp/mediacontentlist.png | Bin 0 -> 57111 bytes
.../version-0.17/benchmarks/cpp/sample.png | Bin 0 -> 55251 bytes
.../version-0.17/benchmarks/cpp/samplelist.png | Bin 0 -> 53909 bytes
.../version-0.17/benchmarks/cpp/struct.png | Bin 0 -> 51352 bytes
.../version-0.17/benchmarks/cpp/structlist.png | Bin 0 -> 53820 bytes
.../version-0.17/benchmarks/cpp/throughput.png | Bin 0 -> 78902 bytes
.../version-0.17/benchmarks/csharp/README.md | 115 ++
.../benchmarks/csharp/mediacontent.png | Bin 0 -> 53148 bytes
.../benchmarks/csharp/mediacontentlist.png | Bin 0 -> 52044 bytes
.../version-0.17/benchmarks/csharp/sample.png | Bin 0 -> 51280 bytes
.../version-0.17/benchmarks/csharp/samplelist.png | Bin 0 -> 55993 bytes
.../version-0.17/benchmarks/csharp/struct.png | Bin 0 -> 53639 bytes
.../version-0.17/benchmarks/csharp/structlist.png | Bin 0 -> 47081 bytes
.../version-0.17/benchmarks/csharp/throughput.png | Bin 0 -> 77537 bytes
.../version-0.17/benchmarks/dart/README.md | 73 +
.../version-0.17/benchmarks/dart/mediacontent.png | Bin 0 -> 52584 bytes
.../benchmarks/dart/mediacontentlist.png | Bin 0 -> 55357 bytes
.../version-0.17/benchmarks/dart/sample.png | Bin 0 -> 42105 bytes
.../version-0.17/benchmarks/dart/samplelist.png | Bin 0 -> 51598 bytes
.../version-0.17/benchmarks/dart/struct.png | Bin 0 -> 38645 bytes
.../version-0.17/benchmarks/dart/structlist.png | Bin 0 -> 44541 bytes
.../version-0.17/benchmarks/dart/throughput.png | Bin 0 -> 89092 bytes
.../version-0.17/benchmarks/go/README.md | 58 +
.../benchmarks/go/benchmark_combined.png | Bin 0 -> 193421 bytes
.../benchmarks/go/benchmark_mediacontent.png | Bin 0 -> 63179 bytes
.../benchmarks/go/benchmark_mediacontentlist.png | Bin 0 -> 75245 bytes
.../benchmarks/go/benchmark_results.txt | 326 +++++
.../benchmarks/go/benchmark_sample.png | Bin 0 -> 64836 bytes
.../benchmarks/go/benchmark_samplelist.png | Bin 0 -> 70519 bytes
.../benchmarks/go/benchmark_struct.png | Bin 0 -> 65532 bytes
.../benchmarks/go/benchmark_structlist.png | Bin 0 -> 63835 bytes
.../benchmarks/go/serialized_sizes.txt | 27 +
.../version-0.17/benchmarks/java/README.md | 239 ++++
.../java/data/jmh-jdk-11-deserialization.csv | 153 ++
.../java/data/jmh-jdk-11-serialization.csv | 153 ++
.../benchmarks/java/data/jmh-jdk-11-zerocopy.csv | 73 +
.../java/java_heap_deserialize_compatible.png | Bin 0 -> 95479 bytes
.../java/java_heap_deserialize_consistent.png | Bin 0 -> 104022 bytes
.../java/java_heap_serialize_compatible.png | Bin 0 -> 104969 bytes
.../java/java_heap_serialize_consistent.png | Bin 0 -> 102858 bytes
.../java/java_offheap_deserialize_compatible.png | Bin 0 -> 100158 bytes
.../java/java_offheap_deserialize_consistent.png | Bin 0 -> 104245 bytes
.../java/java_offheap_serialize_compatible.png | Bin 0 -> 115647 bytes
.../java/java_offheap_serialize_consistent.png | Bin 0 -> 117336 bytes
.../java/java_repo_deserialization_throughput.png | Bin 0 -> 112116 bytes
.../java/java_repo_serialization_throughput.png | Bin 0 -> 120005 bytes
.../benchmarks/java/java_zero_copy_deserialize.png | Bin 0 -> 93509 bytes
.../benchmarks/java/java_zero_copy_serialize.png | Bin 0 -> 94327 bytes
.../version-0.17/benchmarks/javascript/README.md | 104 ++
.../benchmarks/javascript/mediacontent.png | Bin 0 -> 55168 bytes
.../benchmarks/javascript/mediacontentlist.png | Bin 0 -> 56815 bytes
.../version-0.17/benchmarks/javascript/sample.png | Bin 0 -> 57185 bytes
.../benchmarks/javascript/samplelist.png | Bin 0 -> 57215 bytes
.../version-0.17/benchmarks/javascript/struct.png | Bin 0 -> 50777 bytes
.../benchmarks/javascript/structlist.png | Bin 0 -> 54735 bytes
.../benchmarks/javascript/throughput.png | Bin 0 -> 81947 bytes
.../version-0.17/benchmarks/python/README.md | 113 ++
.../benchmarks/python/mediacontent.png | Bin 0 -> 51723 bytes
.../benchmarks/python/mediacontentlist.png | Bin 0 -> 56440 bytes
.../version-0.17/benchmarks/python/sample.png | Bin 0 -> 47563 bytes
.../version-0.17/benchmarks/python/samplelist.png | Bin 0 -> 48300 bytes
.../version-0.17/benchmarks/python/struct.png | Bin 0 -> 53286 bytes
.../version-0.17/benchmarks/python/structlist.png | Bin 0 -> 50022 bytes
.../version-0.17/benchmarks/python/throughput.png | Bin 0 -> 74287 bytes
.../version-0.17/benchmarks/rust/README.md | 103 ++
.../version-0.17/benchmarks/rust/company.png | Bin 0 -> 44643 bytes
.../benchmarks/rust/ecommerce_data.png | Bin 0 -> 44956 bytes
.../version-0.17/benchmarks/rust/mediacontent.png | Bin 0 -> 54130 bytes
.../benchmarks/rust/mediacontentlist.png | Bin 0 -> 54154 bytes
.../version-0.17/benchmarks/rust/person.png | Bin 0 -> 40224 bytes
.../version-0.17/benchmarks/rust/sample.png | Bin 0 -> 44641 bytes
.../version-0.17/benchmarks/rust/samplelist.png | Bin 0 -> 46992 bytes
.../version-0.17/benchmarks/rust/simple_list.png | Bin 0 -> 39423 bytes
.../version-0.17/benchmarks/rust/simple_map.png | Bin 0 -> 45555 bytes
.../version-0.17/benchmarks/rust/simple_struct.png | Bin 0 -> 43007 bytes
.../version-0.17/benchmarks/rust/struct.png | Bin 0 -> 49558 bytes
.../version-0.17/benchmarks/rust/structlist.png | Bin 0 -> 45987 bytes
.../version-0.17/benchmarks/rust/system_data.png | Bin 0 -> 41417 bytes
.../version-0.17/benchmarks/rust/throughput.png | Bin 0 -> 75422 bytes
.../version-0.17/benchmarks/swift/README.md | 44 +
.../version-0.17/benchmarks/swift/throughput.png | Bin 0 -> 84759 bytes
versioned_docs/version-0.17/community/community.md | 90 ++
.../community/how_to_join_community.md | 105 ++
.../version-0.17/community/how_to_release.md | 645 +++++++++
.../version-0.17/community/how_to_verify.md | 125 ++
.../version-0.17/compiler}/_category_.json | 2 +-
.../version-0.17/compiler/compiler-guide.md | 805 +++++++++++
.../version-0.17/compiler/flatbuffers-idl.md | 199 +++
.../version-0.17}/compiler/generated-code.md | 504 +++++--
versioned_docs/version-0.17/compiler/index.md | 217 +++
.../version-0.17/compiler/protobuf-idl.md | 336 +++++
versioned_docs/version-0.17/compiler/schema-idl.md | 1492 ++++++++++++++++++++
versioned_docs/version-0.17/guide/DEVELOPMENT.md | 131 ++
versioned_docs/version-0.17/guide/_category_.json | 4 +
.../version-0.17}/guide/cpp/_category_.json | 2 +-
.../version-0.17/guide/cpp/basic-serialization.md | 305 ++++
.../version-0.17/guide/cpp/configuration.md | 189 +++
.../version-0.17/guide/cpp/cross-language.md | 271 ++++
.../version-0.17/guide/cpp/custom-serializers.md | 371 +++++
.../version-0.17/guide/cpp/field-configuration.md | 568 ++++++++
versioned_docs/version-0.17/guide/cpp/index.md | 266 ++++
.../version-0.17/guide/cpp/polymorphism.md | 480 +++++++
.../version-0.17/guide/cpp/row-format.md | 512 +++++++
.../version-0.17/guide/cpp/schema-evolution.md | 416 ++++++
.../version-0.17/guide/cpp/supported-types.md | 278 ++++
.../version-0.17/guide/cpp/type-registration.md | 226 +++
.../version-0.17/guide/csharp}/_category_.json | 2 +-
.../guide/csharp/basic-serialization.md | 131 ++
.../version-0.17/guide/csharp/configuration.md | 125 ++
.../version-0.17/guide/csharp/cross-language.md | 107 ++
.../guide/csharp/custom-serializers.md | 84 ++
.../guide/csharp/field-configuration.md | 75 +
versioned_docs/version-0.17/guide/csharp/index.md | 104 ++
.../version-0.17/guide/csharp/references.md | 72 +
.../version-0.17/guide/csharp/schema-evolution.md | 90 ++
.../version-0.17/guide/csharp/supported-types.md | 97 ++
.../version-0.17/guide/csharp/thread-safety.md | 73 +
.../version-0.17/guide/csharp/troubleshooting.md | 94 ++
.../version-0.17/guide/csharp/type-registration.md | 82 ++
.../version-0.17/guide/dart}/_category_.json | 2 +-
.../version-0.17/guide/dart/basic-serialization.md | 144 ++
.../version-0.17/guide/dart/code-generation.md | 113 ++
.../version-0.17/guide/dart/configuration.md | 121 ++
.../version-0.17/guide/dart/cross-language.md | 193 +++
.../version-0.17/guide/dart/custom-serializers.md | 139 ++
.../version-0.17/guide/dart/field-configuration.md | 127 ++
versioned_docs/version-0.17/guide/dart/index.md | 141 ++
.../version-0.17/guide/dart/schema-evolution.md | 92 ++
.../version-0.17/guide/dart/supported-types.md | 102 ++
.../version-0.17/guide/dart/troubleshooting.md | 103 ++
.../version-0.17/guide/dart/type-registration.md | 98 ++
.../version-0.17}/guide/go/_category_.json | 2 +-
.../version-0.17/guide/go/basic-serialization.md | 404 ++++++
.../version-0.17}/guide/go/codegen.md | 56 +-
.../version-0.17/guide/go/configuration.md | 344 +++++
.../version-0.17/guide/go/cross-language.md | 282 ++++
.../version-0.17/guide/go/custom-serializers.md | 285 ++++
versioned_docs/version-0.17/guide/go/index.md | 157 ++
versioned_docs/version-0.17/guide/go/references.md | 356 +++++
.../version-0.17/guide/go/schema-evolution.md | 354 +++++
.../version-0.17/guide/go/struct-tags.md | 373 +++++
.../version-0.17/guide/go/supported-types.md | 369 +++++
.../version-0.17/guide/go/thread-safety.md | 347 +++++
.../version-0.17/guide/go/troubleshooting.md | 448 ++++++
.../version-0.17/guide/go/type-registration.md | 264 ++++
versioned_docs/version-0.17/guide/graalvm_guide.md | 329 +++++
.../version-0.17}/guide/java/_category_.json | 2 +-
.../version-0.17/guide/java/advanced-features.md | 209 +++
.../version-0.17/guide/java/basic-serialization.md | 127 ++
.../version-0.17}/guide/java/compression.md | 2 +-
.../version-0.17/guide/java/configuration.md | 79 ++
.../version-0.17/guide/java/cross-language.md | 231 +++
.../version-0.17/guide/java/custom-serializers.md | 227 +++
.../version-0.17/guide/java/enum-configuration.md | 111 ++
.../version-0.17/guide/java/field-configuration.md | 607 ++++++++
versioned_docs/version-0.17/guide/java/index.md | 210 +++
.../version-0.17/guide/java/migration.md | 120 ++
.../version-0.17/guide/java/row-format.md | 181 +++
.../version-0.17/guide/java/schema-evolution.md | 231 +++
.../version-0.17/guide/java/troubleshooting.md | 203 +++
.../version-0.17/guide/java/type-registration.md | 117 ++
.../version-0.17/guide/java/virtual-threads.md | 127 ++
.../version-0.17/guide/javascript}/_category_.json | 4 +-
.../guide/javascript/basic-serialization.md | 244 ++++
.../guide/javascript/cross-language.md | 128 ++
.../version-0.17/guide/javascript/index.md | 141 ++
.../version-0.17/guide/javascript/references.md | 111 ++
.../guide/javascript/schema-evolution.md | 99 ++
.../guide/javascript/supported-types.md | 177 +++
.../guide/javascript/troubleshooting.md | 105 ++
.../guide/javascript/type-registration.md | 200 +++
.../version-0.17}/guide/kotlin/_category_.json | 2 +-
.../version-0.17/guide/kotlin/default-values.md | 137 ++
.../version-0.17}/guide/kotlin/fory-creation.md | 52 +-
versioned_docs/version-0.17/guide/kotlin/index.md | 108 ++
.../guide/kotlin/type-serialization.md | 184 +++
.../version-0.17}/guide/python/_category_.json | 2 +-
.../guide/python/basic-serialization.md | 145 ++
.../version-0.17/guide/python/configuration.md | 183 +++
.../version-0.17/guide/python/cross-language.md | 140 ++
.../guide/python/custom-serializers.md | 98 +-
.../guide/python/field-configuration.md | 492 +++++++
versioned_docs/version-0.17/guide/python/index.md | 160 +++
.../version-0.17/guide/python/migration.md | 85 ++
.../version-0.17/guide/python/numpy-integration.md | 103 ++
.../version-0.17/guide/python/out-of-band.md | 179 +++
.../version-0.17/guide/python/python-native.md | 205 +++
.../version-0.17/guide/python/row-format.md | 167 +++
.../version-0.17/guide/python/schema-evolution.md | 98 ++
.../version-0.17/guide/python/security.md | 150 ++
.../version-0.17/guide/python/troubleshooting.md | 186 +++
.../guide/python/type-registration.md | 78 +-
.../version-0.17}/guide/rust/_category_.json | 2 +-
.../version-0.17/guide/rust/basic-serialization.md | 166 +++
.../version-0.17/guide/rust/configuration.md | 125 ++
.../version-0.17/guide/rust/cross-language.md | 165 +++
.../version-0.17/guide/rust/custom-serializers.md | 153 ++
.../version-0.17/guide/rust/field-configuration.md | 460 ++++++
.../version-0.17}/guide/rust/index.md | 2 +-
.../version-0.17/guide/rust/polymorphism.md | 232 +++
.../version-0.17/guide/rust/references.md | 213 +++
.../version-0.17/guide/rust/row-format.md | 126 ++
.../version-0.17/guide/rust/schema-evolution.md | 218 +++
.../version-0.17/guide/rust/troubleshooting.md | 164 +++
.../version-0.17/guide/rust/type-registration.md | 126 ++
.../version-0.17}/guide/scala/_category_.json | 2 +-
.../version-0.17/guide/scala/default-values.md | 186 +++
.../version-0.17}/guide/scala/fory-creation.md | 65 +-
versioned_docs/version-0.17/guide/scala/index.md | 100 ++
.../version-0.17/guide/scala/type-serialization.md | 171 +++
.../version-0.17/guide/swift}/_category_.json | 2 +-
.../guide/swift/basic-serialization.md | 114 ++
.../version-0.17/guide/swift/configuration.md | 100 ++
.../version-0.17/guide/swift/cross-language.md | 97 ++
.../version-0.17/guide/swift/custom-serializers.md | 84 ++
.../guide/swift/field-configuration.md | 92 ++
versioned_docs/version-0.17/guide/swift/index.md | 84 ++
.../version-0.17/guide/swift/polymorphism.md | 80 ++
.../version-0.17/guide/swift/references.md | 111 ++
.../version-0.17/guide/swift/row-format.md | 38 +
.../version-0.17/guide/swift/schema-evolution.md | 77 +
.../version-0.17/guide/swift/troubleshooting.md | 92 ++
.../version-0.17/guide/swift/type-registration.md | 76 +
.../version-0.17}/guide/xlang/_category_.json | 2 +-
.../version-0.17/guide/xlang/field-nullability.md | 250 ++++
.../guide/xlang/field-reference-tracking.md | 264 ++++
.../version-0.17/guide/xlang/field-type-meta.md | 301 ++++
.../version-0.17}/guide/xlang/getting-started.md | 2 +-
versioned_docs/version-0.17/guide/xlang/index.md | 162 +++
.../version-0.17/guide/xlang/row_format.md | 190 +++
.../version-0.17/guide/xlang/serialization.md | 548 +++++++
.../version-0.17/guide/xlang/troubleshooting.md | 302 ++++
.../version-0.17/guide/xlang/zero-copy.md | 209 +++
.../version-0.17/introduction/_category_.json | 4 +
.../version-0.17/introduction/benchmark.md | 96 ++
.../version-0.17/introduction/features.md | 210 +++
.../version-0.17/introduction/overview.md | 200 +++
.../specification/java_serialization_spec.md | 485 +++++++
.../version-0.17/specification/row_format_spec.md | 540 +++++++
.../specification/xlang_implementation_guide.md | 439 ++++++
.../specification/xlang_serialization_spec.md | 1464 +++++++++++++++++++
.../specification/xlang_type_mapping.md | 61 +-
versioned_docs/version-0.17/start/_category_.json | 4 +
.../version-0.17}/start/install.md | 30 +-
.../version-0.17}/start/usage.md | 4 +-
versioned_sidebars/version-0.17-sidebars.json | 64 +
versions.json | 1 +
624 files changed, 67521 insertions(+), 2372 deletions(-)
diff --git a/.claude/skills/release-major-version/SKILL.md b/.claude/skills/release-major-version/SKILL.md
new file mode 100644
index 000000000..46721088d
--- /dev/null
+++ b/.claude/skills/release-major-version/SKILL.md
@@ -0,0 +1,278 @@
+---
+name: release-major-version
+description: >-
+ Prepare the Apache Fory site for a new major-ish docs release such as 0.17:
+ write the release blog, checkpoint with git commits, translate the zh-CN
+ release blog and docs, create the versioned docs snapshot, update the
+ default docs version, and run an independent self-review to catch remaining
+ issues. Use when the user asks to cut a new docs/site release version on
+ this repository.
+---
+
+# Release Big Version
+
+Use this skill for the `apache/fory-site` repository when preparing a new docs/site release such as `0.17`.
+
+This skill is for the website/docs repository workflow, not the ASF source release/signing workflow in `docs/community/how_to_release.md`.
+
+## Scope
+
+This workflow covers:
+
+1. Write the release blog post
+2. Git commit the blog/content checkpoint
+3. Translate the zh-CN release blog and zh-CN docs
+4. Git commit the translation checkpoint
+5. Version the docs with `yarn docusaurus docs:version <version>`
+6. Update the default docs version to the new version
+7. Run a fresh subagent review before calling the work done
+
+## Repository Facts You Must Respect
+
+- Current docs live in `docs/`
+- Versioned English docs live in `versioned_docs/version-<ver>/`
+- Versioned sidebars live in `versioned_sidebars/version-<ver>-sidebars.json`
+- Chinese docs live in `i18n/zh-CN/docusaurus-plugin-content-docs/current/`
+- Versioned Chinese docs live in `i18n/zh-CN/docusaurus-plugin-content-docs/version-<ver>/`
+- Chinese blog posts live in `i18n/zh-CN/docusaurus-plugin-content-blog/`
+- Docs version history is recorded in `versions.json`
+- The default released docs version is controlled by `docs.lastVersion` in `docusaurus.config.ts`
+- The wrapped versioning command is `yarn docusaurus docs:version <ver>`, which calls `scripts/docusaurus-with-i18n.sh`
+- The wrapper copies every locale's `current/` docs tree to `version-<ver>/` after Docusaurus versions the English docs
+
+## Important Caveats
+
+- Do not run raw `docusaurus docs:version <ver>` directly. Use `yarn docusaurus docs:version <ver>` so zh-CN docs are copied too.
+- Do not version docs before the English docs and zh-CN docs are in the state you want to freeze for that release.
+- Run `npm run copy-i18n-fallback` before cutting the version if zh-CN `benchmarks/` or `specification/` content may still rely on fallback copies.
+- `copy-i18n-fallback.sh` can create untracked fallback files under `i18n/zh-CN/.../benchmarks` and `.../specification`; do not confuse those with intentional edits.
+- This repo already has some broken zh-CN doc links. A full build can fail for pre-existing reasons unrelated to your release changes. Distinguish new regressions from known baseline issues.
+- Keep `tasks/*.md` and `tasks/lessons.md` out of git.
+- `docs/guide` and `docs/specification` are mainly synced from `apache/fory`; avoid site-only divergence there unless that upstream sync is intentionally part of the release work.
+- Abort early if target-version artifacts already exist unless the user explicitly wants to resume/repair a partial release cut. This includes:
+ - `blog/*fory_<version>_release.md`
+ - `static/img/blog/fory_<version>_release/`
+ - `versioned_docs/version-<version>/`
+ - `versioned_sidebars/version-<version>-sidebars.json`
+ - `i18n/zh-CN/docusaurus-plugin-content-docs/version-<version>/`
+
+## Step 0: Prepare Context
+
+1. Read:
+ - `package.json`
+ - `docusaurus.config.ts`
+ - `versions.json`
+ - `scripts/docusaurus-with-i18n.sh`
+2. Confirm the current latest released version, the target new version, and the previous released version that will become the explicit older-version route after the cut.
+3. Verify the site repo already contains the intended upstream docs state from `apache/fory` before you start. Do not assume the release only touches `docs/guide`.
+ - compare current `docs/` against `versioned_docs/version-<previous-version>/` to discover the actual English doc delta for this release
+ - inspect the changed paths across all doc trees, including `docs/start`, `docs/guide`, `docs/compiler`, `docs/benchmarks`, `docs/specification`, `docs/introduction`, and `docs/community`
+ - explicitly confirm that any upstream docs expected for the release are already synced into this repo before freezing the snapshot
+ - if needed upstream docs are missing, stop and sync or ask the user before freezing a stale snapshot
+4. Check that the target version is clean:
+ - the release blog filename does not already exist unless this is an intentional continuation
+ - the blog asset directory does not already exist unless this is an intentional continuation
+ - `versioned_docs/version-<version>/` does not already exist
+ - `versioned_sidebars/version-<version>-sidebars.json` does not already exist
+ - `i18n/zh-CN/docusaurus-plugin-content-docs/version-<version>/` does not already exist
+5. Build a concrete release-doc scope before editing:
+ - scan `blog/` for the previous release post to use as template
+ - scan `docs/`, `versioned_docs/`, and `i18n/zh-CN/docusaurus-plugin-content-docs/` so you understand the current tree
+ - derive the release-doc scope from `versioned_docs/version-<previous-version>/` vs `docs/`
+ - treat that changed-doc list as the required release-doc scope for zh-CN translation and final review, instead of guessing only a few subtrees
+6. If the task is non-trivial, maintain a task note under `tasks/task-<slug>.md` and archive it to `tasks/history/` when finished.
+
+## Step 1: Write the Release Blog
+
+1. Ask the user to provide the English draft for the release blog if it has not already been provided.
+2. Find the previous release blog in `blog/`, typically `blog/YYYY-MM-DD-fory_<prev>_release.md`.
+3. Use the previous release blog as a structural/reference template, but treat the user-provided English draft as the source content for the new post.
+4. Create or revise the new release post around that English draft rather than inventing the release narrative from scratch.
+5. Update the post carefully:
+ - frontmatter `slug`, `title`, `tags`, date-based filename
+ - opening release paragraph
+ - compare link
+ - PR counts / contributor counts if the post includes them
+ - highlights/features/fixes sections
+ - benchmark images and asset paths
+6. Put blog-specific assets under `static/img/blog/fory_<version>_release/` when the post needs dedicated images.
+7. If you add benchmark images, ensure the referenced static paths and copied files match exactly.
+8. Validate the post for obvious copy/paste errors from the previous release.
+
+## Step 1A: Bump Versioned References in Current Docs
+
+Before translating the zh-CN blog/docs or freezing the docs version, update all pinned current-doc references to the new release version.
+
+Required targets:
+
+1. `docs/start/install.md`
+2. `docs/guide/**/index.md` for each language/runtime that includes versioned install or dependency examples
+3. other current guide pages with pinned version examples, dependency strings, or install snippets
+4. any other current docs page that still advertises the previous release as the recommended install version
+
+Minimum workflow:
+
+1. Replace the previous release version with the new release version in `docs/start/install.md`
+2. Scan all current docs for pinned release strings and update them where they describe the latest recommended version
+3. Explicitly inspect `docs/guide/**/index.md` because these pages often carry language-specific install snippets and versioned dependency examples
+4. Update every latest-version reference before `yarn docusaurus docs:version <version>` so the frozen snapshot inherits the correct release version
+5. Be especially suspicious of:
+ - Maven/Gradle coordinates
+ - `pip install`, `go get`, `cargo add`, `dotnet add package`
+ - Bazel dependency examples
+ - language-guide install snippets under `docs/guide/**`
+ - language `index.md` pages under `docs/guide/**/index.md`
+6. Finish all of these English/current-doc version updates before starting zh-CN translation, so the Chinese docs/blog are translated once from the final English source rather than patched twice
+7. Do this before `yarn docusaurus docs:version <version>` so the released snapshot freezes the correct install guidance
+
+## Step 2: Git Commit the Blog Checkpoint
+
+1. Review the diff for the new blog post and any new assets.
+2. Make a focused git commit for the blog/release-post changes.
+3. Do not bundle unrelated generated files into this commit.
+
+## Step 3: Translate zh-CN Docs
+
+1. Use the Chinese translation workflow skill:
+ - Prefer repo-local `.agents/skills/translate-docs-zh/SKILL.md` if it exists
+ - Otherwise use `.claude/skills/translate-docs-zh/SKILL.md`
+2. Start this step only after the English release blog and all current-doc version bumps are final.
+3. Translate or sync the zh-CN release blog:
+ - source: `blog/<release-file>.md`
+ - target: `i18n/zh-CN/docusaurus-plugin-content-blog/<release-file>.md`
+ - preserve frontmatter structure and blog metadata unless a localized change is needed
+ - keep blog asset paths aligned with the English source unless there is a deliberate zh-only asset change
+4. Translate or sync the zh-CN docs for the doc changes that should ship with the new release.
+ - primary path mapping: `docs/<subpath>` -> `i18n/zh-CN/docusaurus-plugin-content-docs/current/<subpath>`
+ - do not limit this to `docs/guide/**`
+ - translate or sync every changed English doc in the release-doc scope relative to `versioned_docs/version-<previous-version>/`
+ - this includes changed files under `docs/benchmarks/**`, `docs/community/**`, `docs/compiler/**`, `docs/guide/**`, `docs/introduction/**`, `docs/specification/**`, and `docs/start/**`
+ - if a changed English current doc has no matching zh-CN current update before versioning, treat that as a blocking gap unless the file is intentionally English-only and documented as such
+5. Follow the translation skill's hard rule: no external translation tools or services.
+6. If top-level category labels changed, also update:
+ - `i18n/zh-CN/docusaurus-plugin-content-docs/current.json`
+7. If the release needs localized version metadata, plan a manual follow-up for `i18n/zh-CN/docusaurus-plugin-content-docs/version-<version>.json`; the versioning wrapper does not create it.
+
+## Step 4: Git Commit the zh-CN Checkpoint
+
+1. Review only the intended zh-CN docs changes.
+2. Include both the zh-CN release blog and zh-CN docs translation/sync in this checkpoint.
+3. Commit the Chinese translation/sync separately from the release blog commit.
+4. Leave task notes and lessons unstaged.
+
+## Step 5: Freeze the New Docs Version
+
+Before freezing:
+
+```bash
+npm run copy-i18n-fallback
+```
+
+Then, after English and zh-CN current docs are ready, run:
+
+```bash
+yarn docusaurus docs:version <version>
+```
+
+Expected effects:
+
+- Docusaurus snapshots English docs into `versioned_docs/version-<version>/`
+- Docusaurus creates `versioned_sidebars/version-<version>-sidebars.json`
+- The wrapper script copies zh-CN current docs into `i18n/zh-CN/docusaurus-plugin-content-docs/version-<version>/`
+- `versions.json` is updated
+
+After the command:
+
+1. Inspect the new `versioned_docs/version-<version>/` tree
+2. Inspect `versioned_sidebars/version-<version>-sidebars.json`
+3. Inspect `i18n/zh-CN/docusaurus-plugin-content-docs/version-<version>/`
+4. Check for accidental carry-over of placeholder or half-English zh-CN content before accepting the snapshot
+5. Decide whether a manual `i18n/zh-CN/docusaurus-plugin-content-docs/version-<version>.json` should be added for this release
+6. If a later validation/build step generates additional fallback files under the new `version-<version>/` zh-CN tree, inspect them explicitly and decide whether they belong in the release commit
+7. Before accepting the snapshot, explicitly compare the release-doc scope in:
+ - `docs/<subpath>`
+ - `i18n/zh-CN/docusaurus-plugin-content-docs/current/<subpath>`
+ - `i18n/zh-CN/docusaurus-plugin-content-docs/version-<version>/<subpath>`
+ and resolve any obvious case where the versioned zh snapshot froze an older current zh file
+
+## Step 6: Update the Default Docs Version
+
+1. Edit `docusaurus.config.ts`
+2. Change:
+
+```ts
+docs: {
+ lastVersion: '<version>',
+}
+```
+
+3. Keep the existing repo style for `docs.versions` entries unless there is a concrete reason to change it
+4. Verify `versions.json` now lists the new version first
+
+## Step 7: Validate
+
+Minimum validation:
+
+1. `npm run typecheck`
+2. `npm run build`
+3. Review the output and separate:
+ - new failures caused by your changes
+ - pre-existing failures, especially zh-CN broken links
+
+Recommended route checks when the build is usable:
+
+- `/`
+- `/docs`
+- `/zh-CN/docs`
+- `/docs/<previous-version>/`
+- `/zh-CN/docs/<previous-version>/`
+- `/blog`
+- `/zh-CN/blog`
+
+Also run targeted checks:
+
+- parameterize stale-version scans using the actual old/new versions instead of hard-coded values
+- scan at least: `blog`, `docs`, `versioned_docs/version-<version>`, and `i18n/zh-CN/docusaurus-plugin-content-docs`
+- for example, search for the previous release string, older release strings likely to be copy/paste remnants, and placeholders such as `TODO` / `TBD`
+- treat stale latest-version references in current install/docs pages as blocking, especially in `docs/start/install.md`, `docs/guide/**/index.md`, and other `docs/guide/**` pages
+- confirm release blog asset paths exist under `static/img/blog/fory_<version>_release/`
+- compare the release-doc scope against the previous release snapshot so you do not miss changed docs outside `guide/` such as `compiler/generated-code.md`
+- for each changed English current doc in the release-doc scope, verify whether the matching zh current doc is updated, missing, or intentionally left as English fallback
+- if any changed doc under `benchmarks/`, `community/`, `compiler/`, `guide/`, `introduction/`, `specification/`, or `start/` is missing from zh current, treat that as unfinished release work rather than optional follow-up
+
+## Step 8: Fresh Self-Review
+
+Before marking the task complete, spawn a fresh subagent and ask it to review the work with no answer leakage.
+
+The review should check at least:
+
+1. Are there still stale version strings or previous-release copy/paste remnants?
+2. Did versioning update the expected files only?
+3. Are zh-CN docs/versioned docs consistent with the intended snapshot?
+4. Are the zh-CN release blog and English release blog both present and consistent with the intended release state?
+5. Are blog asset paths and benchmark links valid?
+6. Are there any obvious missing follow-up edits, such as `docs/start/install.md` or guide pages with pinned version references that should move to the new release?
+7. Did the workflow accidentally snapshot stale site docs because upstream `apache/fory` doc changes were not synced first?
+8. Did any changed English current doc outside `guide/` fail to get translated or reviewed in zh-CN before versioning, for example under `compiler/`, `benchmarks/`, `specification/`, `start/`, or `introduction/`?
+9. Does every changed zh current doc in the release-doc scope match the intended `version-<version>` snapshot, or did the workflow freeze an older zh current state?
+
+Treat review findings as blocking until resolved or explicitly documented.
+
+## Commit Strategy
+
+Preferred checkpoints:
+
+1. Blog/release-post commit
+2. zh-CN release blog + docs translation commit
+3. versioning/default-version commit
+
+Keep commits focused so rollback and review stay simple.
+
+## Output Requirements
+
+When reporting completion, include:
+
+1. What changed
+2. Which commits or commit boundaries were created
+3. Validation results
+4. Any remaining known issues or pre-existing build failures
diff --git a/blog/2026-03-17-fory_0_16_0_release.md b/blog/2026-03-17-fory_0_16_0_release.md
index ffbcf2c67..6d4086ad0 100644
--- a/blog/2026-03-17-fory_0_16_0_release.md
+++ b/blog/2026-03-17-fory_0_16_0_release.md
@@ -5,7 +5,7 @@ authors: [chaokunyang]
tags: [fory, c#, swift, c++, java, python, compiler]
---
-The Apache Fory team is pleased to announce the 0.16.0 release. This is a major release that includes [91 PR](https://github.com/apache/fory/compare/v0.14.1...v0.15.0) from 17 distinct contributors. See the [Install](https://fory.apache.org/docs/start/install) Page to learn how to get the libraries for your platform.
+The Apache Fory team is pleased to announce the 0.16.0 release. This is a major release that includes [91 PR](https://github.com/apache/fory/compare/v0.15.0...v0.16.0) from 17 distinct contributors. See the [Install](https://fory.apache.org/docs/start/install) Page to learn how to get the libraries for your platform.
## Highlights
diff --git a/blog/2026-04-19-fory_0_17_0_release.md b/blog/2026-04-19-fory_0_17_0_release.md
new file mode 100644
index 000000000..ad7b73304
--- /dev/null
+++ b/blog/2026-04-19-fory_0_17_0_release.md
@@ -0,0 +1,296 @@
+---
+slug: fory_0_17_0_release
+title: Fory v0.17.0 Released
+authors: [chaokunyang]
+tags: [fory, c#, swift, c++, java, python, compiler]
+---
+
+The Apache Fory team is pleased to announce the 0.17.0 release. This is a major release that includes [71 PR](https://github.com/apache/fory/compare/v0.16.0...v0.17.0) from 19 distinct contributors. See the [Install](https://fory.apache.org/docs/start/install) Page to learn how to get the libraries for your platform.
+
+## JavaScript/NodeJS Serialization: First Release
+
+Apache Fory 0.17.0 marks the first release with official JavaScript/NodeJS
+documentation, benchmark coverage, and TypeScript-friendly IDL code generation.
+The JavaScript runtime is built for modern Node.js services and TypeScript
+codebases, while preserving Fory's cross-language object model, schema-driven
+APIs, and optional reference tracking.
+
+**Key capabilities:**
+
+* High-performance serialization for JavaScript and TypeScript objects in Node.js
+* Cross-language compatibility with Java, Python, Go, Rust, C#, Swift, and Dart
+* Schema-driven APIs via `Type.*` builders and TypeScript decorators
+* Optional reference tracking for shared and circular object graphs
+* Compatible mode for schema evolution
+* Configurable depth, binary size, and collection size guardrails
+* JavaScript/TypeScript target support in the Fory IDL/compiler workflow
+* Optional `@apache-fory/hps` fast string path for Node.js 20+
+
+### Quick Start
+
+```ts
+import Fory, { Type } from "@apache-fory/core";
+
+const userType = Type.struct(
+ { typeName: "example.user" },
+ {
+ id: Type.int64(),
+ name: Type.string(),
+ age: Type.int32(),
+ },
+);
+
+const fory = new Fory();
+const { serialize, deserialize } = fory.register(userType);
+
+const bytes = serialize({
+ id: 1n,
+ name: "Alice",
+ age: 30,
+});
+
+const user = deserialize(bytes);
+console.log(user);
+```
+
+* JavaScript guide: https://fory.apache.org/docs/guide/javascript/
+* Compiler docs: https://fory.apache.org/docs/compiler/
+
+### JavaScript Benchmarks
+
+<img src="/img/blog/fory_0_17_0_release/javascript_throughput.png" width="90%"/>
+
+Below are throughput results (ops/sec; higher is better) comparing Fory with
+Protocol Buffers and JSON across representative data structures.
+
+| Datatype | Operation | Fory TPS | Protobuf TPS | JSON TPS | Fastest |
+| ---------------- | ----------- | --------- | ------------ | --------- | ------- |
+| Struct | Serialize | 8,453,950 | 1,903,706 | 3,058,232 | fory |
+| Struct | Deserialize | 9,705,287 | 8,233,664 | 3,860,538 | fory |
+| Sample | Serialize | 1,498,391 | 422,620 | 744,790 | fory |
+| Sample | Deserialize | 1,918,162 | 819,010 | 762,048 | fory |
+| MediaContent | Serialize | 1,293,157 | 729,497 | 1,299,908 | json |
+| MediaContent | Deserialize | 1,638,086 | 1,209,140 | 921,191 | fory |
+| StructList | Serialize | 3,928,325 | 495,648 | 891,810 | fory |
+| StructList | Deserialize | 3,264,827 | 1,529,744 | 986,144 | fory |
+| SampleList | Serialize | 355,581 | 92,741 | 163,120 | fory |
+| SampleList | Deserialize | 424,916 | 163,253 | 162,520 | fory |
+| MediaContentList | Serialize | 286,053 | 148,977 | 282,445 | fory |
+| MediaContentList | Deserialize | 376,826 | 244,622 | 190,155 | fory |
+
+Serialized data sizes (bytes):
+
+| Datatype | Fory | Protobuf | JSON |
+| ---------------- | ---- | -------- | ---- |
+| Struct | 58 | 61 | 103 |
+| Sample | 446 | 377 | 724 |
+| MediaContent | 391 | 307 | 596 |
+| StructList | 184 | 315 | 537 |
+| SampleList | 1980 | 1900 | 3642 |
+| MediaContentList | 1665 | 1550 | 3009 |
+
+Benchmark details: https://github.com/apache/fory/tree/v0.17.0/benchmarks/javascript
+
+## Dart Serialization: First Release
+
+Apache Fory 0.17.0 also marks the first release with official Dart
+documentation, benchmark coverage, a rebuilt runtime, and Dart IDL support.
+The Dart implementation focuses on generated serializers, stable
+cross-language type identity, schema evolution, and predictable APIs for
+service workloads.
+
+**Key capabilities:**
+
+* High-performance Dart serialization with generated code instead of reflection
+* Cross-language compatibility with Java, Python, Go, Rust, C#, Swift, and JavaScript
+* `@ForyStruct` and `@ForyField` annotations with `build_runner` code generation
+* Compatible mode for schema evolution across versions
+* Optional reference tracking for shared and circular object graphs
+* Manual `Serializer<T>` extension points for advanced or custom types
+* Dart target support in the Fory IDL/compiler workflow
+
+### Quick Start
+
+```dart
+import 'package:fory/fory.dart';
+
+part 'person.fory.dart';
+
+enum Color {
+ red,
+ blue,
+}
+
+@ForyStruct()
+class Person {
+ Person();
+
+ String name = '';
+ Int32 age = Int32(0);
+ Color favoriteColor = Color.red;
+}
+
+void main() {
+ final fory = Fory();
+ PersonFory.register(
+ fory,
+ Color,
+ namespace: 'example',
+ typeName: 'Color',
+ );
+ PersonFory.register(
+ fory,
+ Person,
+ namespace: 'example',
+ typeName: 'Person',
+ );
+
+ final bytes = fory.serialize(Person()
+ ..name = 'Ada'
+ ..age = Int32(36)
+ ..favoriteColor = Color.blue);
+ final roundTrip = fory.deserialize<Person>(bytes);
+ print(roundTrip.name);
+}
+```
+
+* Dart guide: https://fory.apache.org/docs/guide/dart/
+* Compiler docs: https://fory.apache.org/docs/compiler/
+
+### Dart Benchmarks
+
+<img src="/img/blog/fory_0_17_0_release/dart_throughput.png" width="90%"/>
+
+Below are throughput results (ops/sec; higher is better) comparing Fory with
+Protocol Buffers across representative data structures.
+
+| Datatype | Operation | Fory TPS | Protobuf TPS | Fastest |
+| ---------------- | ----------- | --------: | -----------: | ------------ |
+| Struct | Serialize | 3,989,432 | 1,884,653 | fory (2.12x) |
+| Struct | Deserialize | 5,828,197 | 4,199,680 | fory (1.39x) |
+| Sample | Serialize | 1,649,722 | 500,167 | fory (3.30x) |
+| Sample | Deserialize | 2,060,113 | 785,109 | fory (2.62x) |
+| MediaContent | Serialize | 800,876 | 391,235 | fory (2.05x) |
+| MediaContent | Deserialize | 1,315,115 | 683,533 | fory (1.92x) |
+| StructList | Serialize | 1,456,396 | 367,506 | fory (3.96x) |
+| StructList | Deserialize | 1,921,006 | 645,958 | fory (2.97x) |
+| SampleList | Serialize | 411,144 | 48,508 | fory (8.48x) |
+| SampleList | Deserialize | 464,273 | 103,558 | fory (4.48x) |
+| MediaContentList | Serialize | 186,870 | 77,029 | fory (2.43x) |
+| MediaContentList | Deserialize | 330,293 | 128,215 | fory (2.58x) |
+
+Serialized data sizes (bytes):
+
+| Datatype | Fory | Protobuf |
+| ---------------- | ---: | -------: |
+| Struct | 58 | 61 |
+| Sample | 446 | 377 |
+| MediaContent | 365 | 307 |
+| StructList | 184 | 315 |
+| SampleList | 1980 | 1900 |
+| MediaContentList | 1535 | 1550 |
+
+Benchmark details: https://github.com/apache/fory/tree/v0.17.0/benchmarks/dart
+
+## Highlights
+
+* refactor(java): refactor fory java serialization api by @chaokunyang in https://github.com/apache/fory/pull/3537
+* refactor(python): refactor python serialization api by @chaokunyang in https://github.com/apache/fory/pull/3543
+* feat(java): reduce java serializer memory usage by share across Fory instances by @chaokunyang in https://github.com/apache/fory/pull/3546
+* feat(java): remove guava dependency from fory java by @chaokunyang in https://github.com/apache/fory/pull/3557
+* refactor(dart): new dart implementation by @chaokunyang in https://github.com/apache/fory/pull/3551
+
+## Features
+
+* refactor(javascript): rename apache-fory/fory to apache-fory/core by @chaokunyang in https://github.com/apache/fory/pull/3489
+* feat(ci): add bazel downloads retry by @BaldDemian in https://github.com/apache/fory/pull/3492
+* feat(go): add configurable size guardrails by @ayush00git in https://github.com/apache/fory/pull/3475
+* refactor(ci): install Bazel using setup-bazel by @BaldDemian in https://github.com/apache/fory/pull/3494
+* perf(rust): Rewrite Rust benchmarks around shared bench.proto data by @chaokunyang in https://github.com/apache/fory/pull/3497
+* feat(cpp): add float16 to c++ by @UninspiredCarrot in https://github.com/apache/fory/pull/3487
+* feat(java): add float support by @mengnankkkk in https://github.com/apache/fory/pull/3254
+* feat(java): support java virtual threads by @chaokunyang in https://github.com/apache/fory/pull/3522
+* perf(java): optimize thread safe fory for java by @chaokunyang in https://github.com/apache/fory/pull/3529
+* test(cpp): optimize float16 sign symmetry test for ASAN by @Geethapranay1 in https://github.com/apache/fory/pull/3531
+* feat(java): add dedicated exception serializers by @chaokunyang in https://github.com/apache/fory/pull/3536
+* refactor(java): refactor fory java serialization api by @chaokunyang in https://github.com/apache/fory/pull/3537
+* refactor(python): refactor python serialization api by @chaokunyang in https://github.com/apache/fory/pull/3543
+* feat(dart): Introduce id based enum serialization by @yash-agarwa-l in https://github.com/apache/fory/pull/3482
+* feat(javascript): add configurable size guardrails by @ayush00git in https://github.com/apache/fory/pull/3539
+* feat(java): reduce java serializer memory usage by share across Fory instances by @chaokunyang in https://github.com/apache/fory/pull/3546
+* refactor(javascript): move serialization runtime state into contexts by @chaokunyang in https://github.com/apache/fory/pull/3549
+* refactor(swift): refine swift api by @chaokunyang in https://github.com/apache/fory/pull/3554
+* feat(xlang): refine xlang api and enum serialization by @chaokunyang in https://github.com/apache/fory/pull/3555
+* feat(java): remove guava dependency from fory java by @chaokunyang in https://github.com/apache/fory/pull/3557
+* refactor(dart): new dart implementation by @chaokunyang in https://github.com/apache/fory/pull/3551
+* feat(compiler): Add JavaScript/TypeScript IDL code generation by @miantalha45 in https://github.com/apache/fory/pull/3394
+* perf(javascript): add javascript benchmark by @chaokunyang in https://github.com/apache/fory/pull/3562
+* perf(dart): optimize struct deserialize with direct dispatch codegen by @yash-agarwa-l in https://github.com/apache/fory/pull/3563
+* feat(dart): add dart IDL support by @chaokunyang in https://github.com/apache/fory/pull/3571
+* feat(python): fix python struct xlang ref track error by @chaokunyang in https://github.com/apache/fory/pull/3574
+* feat: make generate enum use id for wire format by @chaokunyang in https://github.com/apache/fory/pull/3576
+
+## Bug Fix
+
+* fix(java): Restore compact codec fixed width optimizations by @stevenschlansker in https://github.com/apache/fory/pull/3478
+* fix(rust): handle panics from fuzz-found edge cases by @utafrali in https://github.com/apache/fory/pull/3481
+* fix(rust): add error handling logic for std duration; add support for chrono duration by @BaldDemian in https://github.com/apache/fory/pull/3490
+* fix(compiler): validate rpc request/response types by @retryoos in https://github.com/apache/fory/pull/3493
+* fix(c++): fix misaligned address access errors detected by UBSan in buffer.h by @BaldDemian in https://github.com/apache/fory/pull/3479
+* fix(java): finalize codegen config hash on first use by @chaokunyang in https://github.com/apache/fory/pull/3495
+* fix(rust): fix several panics detected by cargo-fuzz by @BaldDemian in https://github.com/apache/fory/pull/3483
+* fix(java): handle private final map codegen by @chaokunyang in https://github.com/apache/fory/pull/3504
+* fix(compiler): repair broken service example and add regression coverage by @VikingDeng in https://github.com/apache/fory/pull/3505
+* fix(rust): deep clone TypeMeta to prevent UB in concurrent scenarios by @BaldDemian in https://github.com/apache/fory/pull/3511
+* fix(compiler): fix failed tests in compiler; add compiler CI by @BaldDemian in https://github.com/apache/fory/pull/3516
+* fix(compiler): allow qualified nested types in FDL rpc signatures by @VikingDeng in https://github.com/apache/fory/pull/3518
+* fix(java): preserve ConcurrentSkipListSet comparator on copy by @mandrean in https://github.com/apache/fory/pull/3520
+* test(compiler): add IR validation and codegen tests for gRPC service support by @darius024 in https://github.com/apache/fory/pull/3528
+* fix(java): Correct resolution of dependent/nested serializers in GraalVM by @rakow in https://github.com/apache/fory/pull/3532
+* fix(java): fix objectstream serializer async jit and graalvm support by @chaokunyang in https://github.com/apache/fory/pull/3534
+* ci: fix Bazel cache paths for C++ workflows by @chaokunyang in https://github.com/apache/fory/pull/3535
+* fix(python): fix wrong calling orders in visit_other by @BaldDemian in https://github.com/apache/fory/pull/3542
+* fix(js): corrected the float64 array size by @ayush00git in https://github.com/apache/fory/pull/3541
+* fix(java): configure type checker during build by @chaokunyang in https://github.com/apache/fory/pull/3550
+* fix(java): auto-select child serializers for sorted containers by @chaokunyang in https://github.com/apache/fory/pull/3552
+* fix(java): support skip optional sql serializers for java11+ by @chaokunyang in https://github.com/apache/fory/pull/3553
+* fix(rust): apply consistent pascalcase naming for nested types by @utafrali in https://github.com/apache/fory/pull/3548
+* fix(javascript): fix flaky javascript idl tests by @chaokunyang in https://github.com/apache/fory/pull/3565
+* fix(swift): fix swift generated code compile warnings by @chaokunyang in https://github.com/apache/fory/pull/3566
+* fix(java): add test for previous uncaught regression. by @PiotrDuz in https://github.com/apache/fory/pull/3573
+
+## Other Improvements
+
+* chore(java): Update Spotless and Checkstyle to allow building with JDK25 by @stevenschlansker in https://github.com/apache/fory/pull/3476
+* chore(java): Clean up Javadoc warnings, and fail the build if any new ones are introduced by @stevenschlansker in https://github.com/apache/fory/pull/3477
+* chore: bump version to 0.16.0 by @chaokunyang in https://github.com/apache/fory/pull/3488
+* docs: add python benchmark result to readme by @chaokunyang in https://github.com/apache/fory/pull/3496
+* docs: fix benchmark plots by @chaokunyang in https://github.com/apache/fory/pull/3498
+* docs: add fory code review skill by @chaokunyang in https://github.com/apache/fory/pull/3500
+* chore: adjust skills softlinks by @chaokunyang in https://github.com/apache/fory/pull/3501
+* chore(cpp): configure CI to extract and execute C++ code from Markdo… by @Tyooughtul in https://github.com/apache/fory/pull/3381
+* docs: improve comments in Java generator by @codewithtarun2005 in https://github.com/apache/fory/pull/3507
+* docs: refactor agents.md to reduce token usage by @chaokunyang in https://github.com/apache/fory/pull/3538
+* docs: add ai-review policy by @chaokunyang in https://github.com/apache/fory/pull/3545
+* chore: Bump org.apache.logging.log4j:log4j-core from 2.25.3 to 2.25.4 in /java/fory-test-core by @dependabot[bot] in https://github.com/apache/fory/pull/3556
+* chore(javascript): rename ref tracking to ref by @chaokunyang in https://github.com/apache/fory/pull/3559
+* docs(dart): add dart docs by @chaokunyang in https://github.com/apache/fory/pull/3560
+* docs(javascript): add javascript docs by @chaokunyang in https://github.com/apache/fory/pull/3561
+* docs: refine dart and javascript docs by @chaokunyang in https://github.com/apache/fory/pull/3567
+* docs(dart): update dart benchmark docs by @yash-agarwa-l in https://github.com/apache/fory/pull/3568
+* docs: update readme by @chaokunyang in https://github.com/apache/fory/pull/3575
+
+## New Contributors
+
+* @utafrali made their first contribution in https://github.com/apache/fory/pull/3481
+* @BaldDemian made their first contribution in https://github.com/apache/fory/pull/3490
+* @retryoos made their first contribution in https://github.com/apache/fory/pull/3493
+* @Tyooughtul made their first contribution in https://github.com/apache/fory/pull/3381
+* @UninspiredCarrot made their first contribution in https://github.com/apache/fory/pull/3487
+* @VikingDeng made their first contribution in https://github.com/apache/fory/pull/3505
+* @codewithtarun2005 made their first contribution in https://github.com/apache/fory/pull/3507
+* @darius024 made their first contribution in https://github.com/apache/fory/pull/3528
+* @rakow made their first contribution in https://github.com/apache/fory/pull/3532
+* @PiotrDuz made their first contribution in https://github.com/apache/fory/pull/3573
+
+**Full Changelog**: https://github.com/apache/fory/compare/v0.16.0...v0.17.0
diff --git a/docs/guide/java/compression.md b/docs/guide/java/compression.md
index 88cfb70a6..cbe344f00 100644
--- a/docs/guide/java/compression.md
+++ b/docs/guide/java/compression.md
@@ -84,7 +84,7 @@ CompressedArraySerializers.registerSerializers(fory);
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-simd</artifactId>
- <version>0.16.0</version>
+ <version>0.17.0</version>
</dependency>
```
diff --git a/docs/guide/rust/index.md b/docs/guide/rust/index.md
index d52a45d52..7e17d6adc 100644
--- a/docs/guide/rust/index.md
+++ b/docs/guide/rust/index.md
@@ -47,7 +47,7 @@ Add Apache Fory™ to your `Cargo.toml`:
```toml
[dependencies]
-fory = "0.13"
+fory = "0.17.0"
```
### Basic Example
diff --git a/docs/guide/xlang/getting-started.md b/docs/guide/xlang/getting-started.md
index ae0d2a17c..039a00a3a 100644
--- a/docs/guide/xlang/getting-started.md
+++ b/docs/guide/xlang/getting-started.md
@@ -57,7 +57,7 @@ go get github.com/apache/fory/go/fory
```toml
[dependencies]
-fory = "0.13"
+fory = "0.17.0"
```
### JavaScript
diff --git a/docs/start/install.md b/docs/start/install.md
index 3c93af80d..5c3d3e37f 100644
--- a/docs/start/install.md
+++ b/docs/start/install.md
@@ -16,14 +16,14 @@ Use Maven to add Apache Fory™:
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-core</artifactId>
- <version>0.16.0</version>
+ <version>0.17.0</version>
</dependency>
<!-- Optional row format support -->
<!--
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-format</artifactId>
- <version>0.16.0</version>
+ <version>0.17.0</version>
</dependency>
-->
<!-- SIMD acceleration for array compression (Java 16+) -->
@@ -31,7 +31,7 @@ Use Maven to add Apache Fory™:
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-simd</artifactId>
- <version>0.16.0</version>
+ <version>0.17.0</version>
</dependency>
-->
```
@@ -44,7 +44,7 @@ Scala 2.13 with Maven:
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-scala_2.13</artifactId>
- <version>0.16.0</version>
+ <version>0.17.0</version>
</dependency>
```
@@ -54,20 +54,20 @@ Scala 3 with Maven:
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-scala_3</artifactId>
- <version>0.16.0</version>
+ <version>0.17.0</version>
</dependency>
```
Scala 2.13 with sbt:
```sbt
-libraryDependencies += "org.apache.fory" % "fory-scala_2.13" % "0.16.0"
+libraryDependencies += "org.apache.fory" % "fory-scala_2.13" % "0.17.0"
```
Scala 3 with sbt:
```sbt
-libraryDependencies += "org.apache.fory" % "fory-scala_3" % "0.16.0"
+libraryDependencies += "org.apache.fory" % "fory-scala_3" % "0.17.0"
```
## Kotlin
@@ -78,7 +78,7 @@ Add Apache Fory™ Kotlin with Maven:
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-kotlin</artifactId>
- <version>0.16.0</version>
+ <version>0.17.0</version>
</dependency>
```
@@ -86,7 +86,7 @@ Add Apache Fory™ Kotlin with Maven:
```bash
python -m pip install --upgrade pip
-pip install pyfory==0.16.0
+pip install pyfory==0.17.0
```
## Go
@@ -94,7 +94,7 @@ pip install pyfory==0.16.0
Use the full Go module path `github.com/apache/fory/go/fory`:
```bash
-go get github.com/apache/fory/go/fory@v0.16.0
+go get github.com/apache/fory/go/fory@v0.17.0
```
If your Go proxy has not picked up the new submodule tag yet, retry later or use `GOPROXY=direct` temporarily.
@@ -103,13 +103,13 @@ If your Go proxy has not picked up the new submodule tag yet, retry later or use
```toml
[dependencies]
-fory = "0.16.0"
+fory = "0.17.0"
```
Or use `cargo add`:
```bash
-cargo add fory@0.16.0
+cargo add fory@0.17.0
```
## JavaScript
@@ -139,12 +139,12 @@ npm run build
Install the `Apache.Fory` NuGet package. It includes both the runtime and the source generator for `[ForyObject]` types.
```bash
-dotnet add package Apache.Fory --version 0.16.0
+dotnet add package Apache.Fory --version 0.17.0
```
```xml
<ItemGroup>
- <PackageReference Include="Apache.Fory" Version="0.16.0" />
+ <PackageReference Include="Apache.Fory" Version="0.17.0" />
</ItemGroup>
```
@@ -154,7 +154,7 @@ Add Apache Fory™ from the GitHub repository with Swift Package Manager:
```swift
dependencies: [
- .package(url: "https://github.com/apache/fory.git", exact: "0.16.0")
+ .package(url: "https://github.com/apache/fory.git", exact: "0.17.0")
],
targets: [
.target(
diff --git a/docs/start/usage.md b/docs/start/usage.md
index 4dc169da0..4fa4a2f0b 100644
--- a/docs/start/usage.md
+++ b/docs/start/usage.md
@@ -172,7 +172,7 @@ let result: Person = try fory.deserialize(data)
print("\(result.name) \(result.age)")
```
-For detailed Swift usage including polymorphism, schema evolution, and troubleshooting, see [Swift Guide](../guide/swift/index.md).
+For detailed Swift usage including polymorphism, schema evolution, and troubleshooting, see [Swift Guide](../guide/swift/).
### Rust Serialization
@@ -496,7 +496,7 @@ For examples with circular references, shared references, and polymorphism acros
- [Cross-Language Serialization Guide](../guide/xlang/index.md)
- [Go Guide - Cross Language](../guide/go/cross-language.md)
- [C# Guide - Cross Language](../guide/csharp/cross-language.md)
-- [Swift Guide - Cross Language](../guide/swift/cross-language.md)
+- [Swift Guide - Cross Language](../guide/swift/cross_language)
## Row Format Encoding
diff --git a/docusaurus.config.ts b/docusaurus.config.ts
index 970d8d0fc..4eacdbdfd 100644
--- a/docusaurus.config.ts
+++ b/docusaurus.config.ts
@@ -38,7 +38,7 @@ const config: Config = {
{
docs: {
sidebarCollapsible: true,
- lastVersion: '0.16',
+ lastVersion: '0.17',
versions: {
current: {
label: 'dev',
@@ -279,4 +279,3 @@ const config: Config = {
};
export default config;
-
diff --git a/i18n/en-US/docusaurus-plugin-content-docs/version-0.17/.keep b/i18n/en-US/docusaurus-plugin-content-docs/version-0.17/.keep
new file mode 100644
index 000000000..e69de29bb
diff --git a/i18n/zh-CN/docusaurus-plugin-content-blog/2026-04-19-fory_0_17_0_release.md b/i18n/zh-CN/docusaurus-plugin-content-blog/2026-04-19-fory_0_17_0_release.md
new file mode 100644
index 000000000..bf080dd13
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-blog/2026-04-19-fory_0_17_0_release.md
@@ -0,0 +1,286 @@
+---
+slug: fory_0_17_0_release
+title: Fory v0.17.0 发布
+authors: [chaokunyang]
+tags: [fory, c#, swift, c++, java, python, compiler]
+---
+
+Apache Fory 团队很高兴宣布 0.17.0 版本正式发布。这是一个重要版本,包含来自 19 位贡献者的 [71 个 PR](https://github.com/apache/fory/compare/v0.16.0...v0.17.0)。请访问 [Install 页面](https://fory.apache.org/docs/start/install) 获取各平台安装方式。
+
+## JavaScript/NodeJS Serialization:首次发布
+
+Apache Fory 0.17.0 首次正式提供 JavaScript/NodeJS 文档、基准测试覆盖,以及对 TypeScript 友好的 IDL 代码生成支持。JavaScript 运行时面向现代 Node.js 服务和 TypeScript 代码库构建,同时保留了 Fory 的跨语言对象模型、Schema 驱动 API,以及可选的引用跟踪能力。
+
+**关键能力:**
+
+* 面向 Node.js 中 JavaScript 和 TypeScript 对象的高性能序列化
+* 支持与 Java、Python、Go、Rust、C#、Swift 和 Dart 的跨语言兼容
+* 通过 `Type.*` builder 与 TypeScript decorator 提供 Schema 驱动 API
+* 可选的引用跟踪,用于处理共享引用和循环引用对象图
+* 用于 Schema 演进的兼容模式
+* 可配置的深度、二进制大小和集合大小护栏
+* 在 Fory IDL/compiler 工作流中支持 JavaScript/TypeScript target
+* 为 Node.js 20+ 提供可选的 `@apache-fory/hps` 快速字符串路径
+
+### 快速开始
+
+```ts
+import Fory, { Type } from "@apache-fory/core";
+
+const userType = Type.struct(
+ { typeName: "example.user" },
+ {
+ id: Type.int64(),
+ name: Type.string(),
+ age: Type.int32(),
+ },
+);
+
+const fory = new Fory();
+const { serialize, deserialize } = fory.register(userType);
+
+const bytes = serialize({
+ id: 1n,
+ name: "Alice",
+ age: 30,
+});
+
+const user = deserialize(bytes);
+console.log(user);
+```
+
+* JavaScript 指南: https://fory.apache.org/docs/guide/javascript/
+* Compiler 文档: https://fory.apache.org/docs/compiler/
+
+### JavaScript 基准测试
+
+<img src="/img/blog/fory_0_17_0_release/javascript_throughput.png" width="90%"/>
+
+以下是代表性数据结构上的吞吐结果(ops/sec,越高越好),用于比较 Fory、Protocol Buffers 与 JSON。
+
+| Datatype | Operation | Fory TPS | Protobuf TPS | JSON TPS | Fastest |
+| ---------------- | ----------- | --------- | ------------ | --------- | ------- |
+| Struct | Serialize | 8,453,950 | 1,903,706 | 3,058,232 | fory |
+| Struct | Deserialize | 9,705,287 | 8,233,664 | 3,860,538 | fory |
+| Sample | Serialize | 1,498,391 | 422,620 | 744,790 | fory |
+| Sample | Deserialize | 1,918,162 | 819,010 | 762,048 | fory |
+| MediaContent | Serialize | 1,293,157 | 729,497 | 1,299,908 | json |
+| MediaContent | Deserialize | 1,638,086 | 1,209,140 | 921,191 | fory |
+| StructList | Serialize | 3,928,325 | 495,648 | 891,810 | fory |
+| StructList | Deserialize | 3,264,827 | 1,529,744 | 986,144 | fory |
+| SampleList | Serialize | 355,581 | 92,741 | 163,120 | fory |
+| SampleList | Deserialize | 424,916 | 163,253 | 162,520 | fory |
+| MediaContentList | Serialize | 286,053 | 148,977 | 282,445 | fory |
+| MediaContentList | Deserialize | 376,826 | 244,622 | 190,155 | fory |
+
+序列化数据大小(bytes):
+
+| Datatype | Fory | Protobuf | JSON |
+| ---------------- | ---- | -------- | ---- |
+| Struct | 58 | 61 | 103 |
+| Sample | 446 | 377 | 724 |
+| MediaContent | 391 | 307 | 596 |
+| StructList | 184 | 315 | 537 |
+| SampleList | 1980 | 1900 | 3642 |
+| MediaContentList | 1665 | 1550 | 3009 |
+
+详细基准数据请参见: https://github.com/apache/fory/tree/v0.17.0/benchmarks/javascript
+
+## Dart Serialization:首次发布
+
+Apache Fory 0.17.0 也正式带来了 Dart serialization 的首次发布,提供官方文档、基准测试覆盖、重构后的运行时,以及 Dart IDL 支持。Dart 实现重点关注生成式 serializer、稳定的跨语言类型标识、Schema 演进,以及面向服务工作负载的可预测 API。
+
+**关键能力:**
+
+* 使用生成代码而非反射实现高性能 Dart serialization
+* 支持与 Java、Python、Go、Rust、C#、Swift 和 JavaScript 的跨语言兼容
+* 提供 `@ForyStruct` 和 `@ForyField` 注解,并结合 `build_runner` 进行代码生成
+* 用于跨版本 Schema 演进的兼容模式
+* 可选的引用跟踪,用于处理共享引用和循环引用对象图
+* 为高级或自定义类型提供手动 `Serializer<T>` 扩展点
+* 在 Fory IDL/compiler 工作流中支持 Dart target
+
+### 快速开始
+
+```dart
+import 'package:fory/fory.dart';
+
+part 'person.fory.dart';
+
+enum Color {
+ red,
+ blue,
+}
+
+@ForyStruct()
+class Person {
+ Person();
+
+ String name = '';
+ Int32 age = Int32(0);
+ Color favoriteColor = Color.red;
+}
+
+void main() {
+ final fory = Fory();
+ PersonFory.register(
+ fory,
+ Color,
+ namespace: 'example',
+ typeName: 'Color',
+ );
+ PersonFory.register(
+ fory,
+ Person,
+ namespace: 'example',
+ typeName: 'Person',
+ );
+
+ final bytes = fory.serialize(Person()
+ ..name = 'Ada'
+ ..age = Int32(36)
+ ..favoriteColor = Color.blue);
+ final roundTrip = fory.deserialize<Person>(bytes);
+ print(roundTrip.name);
+}
+```
+
+* Dart 指南: https://fory.apache.org/docs/guide/dart/
+* Compiler 文档: https://fory.apache.org/docs/compiler/
+
+### Dart 基准测试
+
+<img src="/img/blog/fory_0_17_0_release/dart_throughput.png" width="90%"/>
+
+以下是代表性数据结构上的吞吐结果(ops/sec,越高越好),用于比较 Fory 与 Protocol Buffers。
+
+| Datatype | Operation | Fory TPS | Protobuf TPS | Fastest |
+| ---------------- | ----------- | --------: | -----------: | ------------ |
+| Struct | Serialize | 3,989,432 | 1,884,653 | fory (2.12x) |
+| Struct | Deserialize | 5,828,197 | 4,199,680 | fory (1.39x) |
+| Sample | Serialize | 1,649,722 | 500,167 | fory (3.30x) |
+| Sample | Deserialize | 2,060,113 | 785,109 | fory (2.62x) |
+| MediaContent | Serialize | 800,876 | 391,235 | fory (2.05x) |
+| MediaContent | Deserialize | 1,315,115 | 683,533 | fory (1.92x) |
+| StructList | Serialize | 1,456,396 | 367,506 | fory (3.96x) |
+| StructList | Deserialize | 1,921,006 | 645,958 | fory (2.97x) |
+| SampleList | Serialize | 411,144 | 48,508 | fory (8.48x) |
+| SampleList | Deserialize | 464,273 | 103,558 | fory (4.48x) |
+| MediaContentList | Serialize | 186,870 | 77,029 | fory (2.43x) |
+| MediaContentList | Deserialize | 330,293 | 128,215 | fory (2.58x) |
+
+序列化数据大小(bytes):
+
+| Datatype | Fory | Protobuf |
+| ---------------- | ---: | -------: |
+| Struct | 58 | 61 |
+| Sample | 446 | 377 |
+| MediaContent | 365 | 307 |
+| StructList | 184 | 315 |
+| SampleList | 1980 | 1900 |
+| MediaContentList | 1535 | 1550 |
+
+详细基准数据请参见: https://github.com/apache/fory/tree/v0.17.0/benchmarks/dart
+
+## 发布亮点
+
+* refactor(java): 重构 fory java serialization API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3537
+* refactor(python): 重构 python serialization API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3543
+* feat(java): 通过在 Fory 实例间共享来降低 java serializer 内存占用,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3546
+* feat(java): 从 fory java 中移除 guava 依赖,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3557
+* refactor(dart): 全新的 dart 实现,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3551
+
+## 功能特性
+
+* refactor(javascript): 将 apache-fory/fory 重命名为 apache-fory/core,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3489
+* feat(ci): 为 bazel 下载增加重试机制,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3492
+* feat(go): 增加可配置的大小护栏,作者 @ayush00git,见 https://github.com/apache/fory/pull/3475
+* refactor(ci): 使用 setup-bazel 安装 Bazel,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3494
+* perf(rust): 基于共享的 bench.proto 数据重写 Rust benchmark,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3497
+* feat(cpp): 为 c++ 增加 float16 支持,作者 @UninspiredCarrot,见 https://github.com/apache/fory/pull/3487
+* feat(java): 增加 float 支持,作者 @mengnankkkk,见 https://github.com/apache/fory/pull/3254
+* feat(java): 支持 java virtual threads,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3522
+* perf(java): 优化 java 中线程安全 fory 的性能,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3529
+* test(cpp): 为 ASAN 优化 float16 sign symmetry 测试,作者 @Geethapranay1,见 https://github.com/apache/fory/pull/3531
+* feat(java): 增加专用 exception serializer,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3536
+* refactor(java): 重构 fory java serialization API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3537
+* refactor(python): 重构 python serialization API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3543
+* feat(dart): 引入基于 id 的 enum serialization,作者 @yash-agarwa-l,见 https://github.com/apache/fory/pull/3482
+* feat(javascript): 增加可配置的大小护栏,作者 @ayush00git,见 https://github.com/apache/fory/pull/3539
+* feat(java): 通过在 Fory 实例间共享来降低 java serializer 内存占用,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3546
+* refactor(javascript): 将 serialization 运行时状态移动到 contexts 中,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3549
+* refactor(swift): 改进 swift API,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3554
+* feat(xlang): 改进 xlang API 与 enum serialization,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3555
+* feat(java): 从 fory java 中移除 guava 依赖,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3557
+* refactor(dart): 全新的 dart 实现,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3551
+* feat(compiler): 增加 JavaScript/TypeScript IDL 代码生成,作者 @miantalha45,见 https://github.com/apache/fory/pull/3394
+* perf(javascript): 增加 javascript benchmark,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3562
+* perf(dart): 使用直接分发代码生成为 struct 反序列化提速,作者 @yash-agarwa-l,见 https://github.com/apache/fory/pull/3563
+* feat(dart): 增加 dart IDL 支持,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3571
+* feat(python): 修复 python struct 跨语言引用跟踪错误,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3574
+* feat: 让生成的 enum 在编码格式中使用 id,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3576
+
+## Bug 修复
+
+* fix(java): 恢复 compact codec 定长优化,作者 @stevenschlansker,见 https://github.com/apache/fory/pull/3478
+* fix(rust): 处理 fuzz 发现的边界场景引发的 panic,作者 @utafrali,见 https://github.com/apache/fory/pull/3481
+* fix(rust): 为 std duration 增加错误处理逻辑,并支持 chrono duration,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3490
+* fix(compiler): 校验 rpc request/response 类型,作者 @retryoos,见 https://github.com/apache/fory/pull/3493
+* fix(c++): 修复 UBSan 在 buffer.h 中检测到的未对齐地址访问错误,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3479
+* fix(java): 在首次使用时固定 codegen config hash,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3495
+* fix(rust): 修复 cargo-fuzz 检测到的多个 panic,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3483
+* fix(java): 处理 private final map 的代码生成,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3504
+* fix(compiler): 修复失效的 service 示例并补充回归覆盖,作者 @VikingDeng,见 https://github.com/apache/fory/pull/3505
+* fix(rust): 深拷贝 TypeMeta,避免并发场景中的未定义行为,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3511
+* fix(compiler): 修复 compiler 测试失败问题,并增加 compiler CI,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3516
+* fix(compiler): 允许在 FDL RPC 签名中使用带限定名的嵌套类型,作者 @VikingDeng,见 https://github.com/apache/fory/pull/3518
+* fix(java): 在复制时保留 ConcurrentSkipListSet comparator,作者 @mandrean,见 https://github.com/apache/fory/pull/3520
+* test(compiler): 为 gRPC service 支持增加 IR 校验与代码生成测试,作者 @darius024,见 https://github.com/apache/fory/pull/3528
+* fix(java): 修正 GraalVM 中依赖/嵌套 serializer 的解析,作者 @rakow,见 https://github.com/apache/fory/pull/3532
+* fix(java): 修复 objectstream serializer 的异步 JIT 与 GraalVM 支持,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3534
+* ci: 修复 C++ workflow 的 Bazel 缓存路径,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3535
+* fix(python): 修复 visit_other 中错误的调用顺序,作者 @BaldDemian,见 https://github.com/apache/fory/pull/3542
+* fix(js): 修正 float64 array 大小计算错误,作者 @ayush00git,见 https://github.com/apache/fory/pull/3541
+* fix(java): 在构建期间配置 type checker,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3550
+* fix(java): 为排序容器自动选择子 serializer,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3552
+* fix(java): 支持在 java11+ 中跳过可选 SQL serializer,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3553
+* fix(rust): 为嵌套类型统一应用 PascalCase 命名,作者 @utafrali,见 https://github.com/apache/fory/pull/3548
+* fix(javascript): 修复不稳定的 javascript IDL 测试,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3565
+* fix(swift): 修复 swift 生成代码的编译告警,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3566
+* fix(java): 为此前遗漏的回归问题增加测试,作者 @PiotrDuz,见 https://github.com/apache/fory/pull/3573
+
+## 其他改进
+
+* chore(java): 更新 Spotless 和 Checkstyle,以支持使用 JDK25 构建,作者 @stevenschlansker,见 https://github.com/apache/fory/pull/3476
+* chore(java): 清理 Javadoc 告警,并在引入新告警时让构建失败,作者 @stevenschlansker,见 https://github.com/apache/fory/pull/3477
+* chore: 将版本号提升到 0.16.0,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3488
+* docs: 在 readme 中增加 python benchmark 结果,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3496
+* docs: 修复 benchmark 图表,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3498
+* docs: 新增 fory code review skill,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3500
+* chore: 调整 skills 软链接,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3501
+* chore(cpp): 配置 CI,从 Markdown 中提取并执行 C++ 代码,作者 @Tyooughtul,见 https://github.com/apache/fory/pull/3381
+* docs: 改进 Java generator 中的注释,作者 @codewithtarun2005,见 https://github.com/apache/fory/pull/3507
+* docs: 重构 agents.md 以减少 token 使用,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3538
+* docs: 增加 ai-review 策略,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3545
+* chore: 在 /java/fory-test-core 中将 org.apache.logging.log4j:log4j-core 从 2.25.3 升级到 2.25.4,作者 @dependabot[bot],见 https://github.com/apache/fory/pull/3556
+* chore(javascript): 将 ref tracking 重命名为 ref,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3559
+* docs(dart): 增加 dart 文档,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3560
+* docs(javascript): 增加 javascript 文档,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3561
+* docs: 完善 dart 和 javascript 文档,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3567
+* docs(dart): 更新 dart benchmark 文档,作者 @yash-agarwa-l,见 https://github.com/apache/fory/pull/3568
+* docs: 更新 readme,作者 @chaokunyang,见 https://github.com/apache/fory/pull/3575
+
+## 新贡献者
+
+* @utafrali 首次贡献见 https://github.com/apache/fory/pull/3481
+* @BaldDemian 首次贡献见 https://github.com/apache/fory/pull/3490
+* @retryoos 首次贡献见 https://github.com/apache/fory/pull/3493
+* @Tyooughtul 首次贡献见 https://github.com/apache/fory/pull/3381
+* @UninspiredCarrot 首次贡献见 https://github.com/apache/fory/pull/3487
+* @VikingDeng 首次贡献见 https://github.com/apache/fory/pull/3505
+* @codewithtarun2005 首次贡献见 https://github.com/apache/fory/pull/3507
+* @darius024 首次贡献见 https://github.com/apache/fory/pull/3528
+* @rakow 首次贡献见 https://github.com/apache/fory/pull/3532
+* @PiotrDuz 首次贡献见 https://github.com/apache/fory/pull/3573
+
+**完整更新日志**: https://github.com/apache/fory/compare/v0.16.0...v0.17.0
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/cpp/README.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/cpp/README.md
index a2be4452e..1dc362e9d 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/cpp/README.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/cpp/README.md
@@ -1,60 +1,104 @@
# C++ 基准性能报告
-_生成时间:2025-12-15 23:03:06_
+_生成于 2026-02-19 10:20:08_
## 如何生成本报告
```bash
-cd benchmarks/cpp_benchmark/build
+cd benchmarks/cpp/build
./fory_benchmark --benchmark_format=json --benchmark_out=benchmark_results.json
cd ..
python benchmark_report.py --json-file build/benchmark_results.json --output-dir report
```
-## 硬件与系统信息
+## 硬件与操作系统信息
-| Key | Value |
+| 键 | 值 |
| -------------------------- | ------------------------- |
-| OS | Darwin 24.6.0 |
-| Machine | arm64 |
-| Processor | arm |
-| CPU Cores (Physical) | 12 |
-| CPU Cores (Logical) | 12 |
-| Total RAM (GB) | 48.0 |
-| Benchmark Date | 2025-12-15T23:02:49+08:00 |
-| CPU Cores (from benchmark) | 12 |
+| 操作系统 | Darwin 24.6.0 |
+| 机器架构 | arm64 |
+| 处理器 | arm |
+| CPU 核心数(物理) | 12 |
+| CPU 核心数(逻辑) | 12 |
+| 总内存(GB) | 48.0 |
+| 基准日期 | 2026-02-19T10:19:31+08:00 |
+| CPU 核心数(基准采集) | 12 |
## 基准图表
+下列各类图表均展示吞吐量(ops/sec)。
+
+### 总吞吐量
+

+### Mediacontent
+
+
+
+### Mediacontentlist
+
+
+
+### Sample
+
+
+
+### Samplelist
+
+
+
+### Struct
+
+
+
+### Structlist
+
+
+
## 基准结果
-### 耗时结果(纳秒)
+### 延迟结果(纳秒)
-| Datatype | Operation | Fory (ns) | Protobuf (ns) | Faster |
-| ------------ | ----------- | --------- | ------------- | ----------- |
-| Mediacontent | Serialize | 443.5 | 1982.5 | Fory (4.5x) |
-| Mediacontent | Deserialize | 1349.0 | 2525.2 | Fory (1.9x) |
-| Sample | Serialize | 235.4 | 309.7 | Fory (1.3x) |
-| Sample | Deserialize | 1068.7 | 1397.0 | Fory (1.3x) |
-| Struct | Serialize | 109.4 | 170.0 | Fory (1.6x) |
-| Struct | Deserialize | 129.1 | 161.2 | Fory (1.2x) |
+| 数据类型 | 操作 | fory (ns) | protobuf (ns) | msgpack (ns) | 最快 |
+| ---------------- | ----------- | --------- | ------------- | ------------ | ------- |
+| MediaContent | Serialize | 120.4 | 863.8 | 281.1 | fory |
+| MediaContent | Deserialize | 397.9 | 1197.9 | 2768.6 | fory |
+| MediaContentList | Serialize | 480.9 | 4744.3 | 1407.5 | fory |
+| MediaContentList | Deserialize | 2022.1 | 6426.0 | 13595.9 | fory |
+| Sample | Serialize | 72.8 | 92.0 | 296.1 | fory |
+| Sample | Deserialize | 328.2 | 641.2 | 2642.9 | fory |
+| SampleList | Serialize | 287.3 | 4761.2 | 1506.7 | fory |
+| SampleList | Deserialize | 1711.8 | 4875.2 | 13232.0 | fory |
+| Struct | Serialize | 27.3 | 32.4 | 55.2 | fory |
+| Struct | Deserialize | 21.4 | 25.0 | 747.3 | fory |
+| StructList | Serialize | 69.4 | 419.8 | 285.9 | fory |
+| StructList | Deserialize | 129.4 | 334.4 | 3385.8 | fory |
### 吞吐结果(ops/sec)
-| Datatype | Operation | Fory TPS | Protobuf TPS | Faster |
-| ------------ | ----------- | --------- | ------------ | ----------- |
-| Mediacontent | Serialize | 2,254,915 | 504,410 | Fory (4.5x) |
-| Mediacontent | Deserialize | 741,303 | 396,013 | Fory (1.9x) |
-| Sample | Serialize | 4,248,973 | 3,229,102 | Fory (1.3x) |
-| Sample | Deserialize | 935,709 | 715,837 | Fory (1.3x) |
-| Struct | Serialize | 9,143,618 | 5,881,005 | Fory (1.6x) |
-| Struct | Deserialize | 7,746,787 | 6,202,164 | Fory (1.2x) |
+| 数据类型 | 操作 | fory TPS | protobuf TPS | msgpack TPS | 最快 |
+| ---------------- | ----------- | ---------- | ------------ | ----------- | ------- |
+| MediaContent | Serialize | 8,306,128 | 1,157,712 | 3,557,700 | fory |
+| MediaContent | Deserialize | 2,513,488 | 834,808 | 361,190 | fory |
+| MediaContentList | Serialize | 2,079,229 | 210,777 | 710,492 | fory |
+| MediaContentList | Deserialize | 494,523 | 155,617 | 73,551 | fory |
+| Sample | Serialize | 13,745,041 | 10,871,787 | 3,377,292 | fory |
+| Sample | Deserialize | 3,047,224 | 1,559,633 | 378,369 | fory |
+| SampleList | Serialize | 3,481,110 | 210,029 | 663,693 | fory |
+| SampleList | Deserialize | 584,168 | 205,121 | 75,574 | fory |
+| Struct | Serialize | 36,672,581 | 30,900,039 | 18,114,682 | fory |
+| Struct | Deserialize | 46,637,124 | 39,947,557 | 1,338,225 | fory |
+| StructList | Serialize | 14,419,548 | 2,381,886 | 3,497,903 | fory |
+| StructList | Deserialize | 7,729,173 | 2,990,652 | 295,353 | fory |
### 序列化数据大小(字节)
-| Datatype | Fory | Protobuf |
-| -------- | ---- | -------- |
-| Struct | 32 | 61 |
-| Sample | 384 | 375 |
+| 数据类型 | fory | protobuf | msgpack |
+| ---------------- | ---- | -------- | ------- |
+| Struct | 58 | 61 | 55 |
+| Sample | 446 | 375 | 530 |
+| MediaContent | 365 | 301 | 480 |
+| StructList | 184 | 315 | 289 |
+| SampleList | 1980 | 1890 | 2664 |
+| MediaContentList | 1535 | 1520 | 2421 |
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/README.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/README.md
new file mode 100644
index 000000000..6b8055d7d
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/README.md
@@ -0,0 +1,73 @@
+# Fory Dart 基准
+
+该基准用于比较 Apache Fory 和 Protocol Buffers 在 Dart 中的序列化与反序列化吞吐量。
+
+## 硬件与运行时信息
+
+| 键 | 值 |
+| --------------------- | ---------------------------------------------------------------- |
+| 时间戳 | 2026-04-13T21:55:28.456625Z |
+| 操作系统 | Version 26.2 (Build 25C56) |
+| 主机 | Macbook-Air.local |
+| CPU 核心数(逻辑) | 8 |
+| 内存(GB) | 8.00 |
+| Dart | 3.10.4 (stable) (Tue Dec 9 00:01:55 2025 -0800) on "macos_arm64" |
+| 每个用例的采样次数 | 5 |
+| 每个用例的预热时长(秒) | 1.0 |
+| 每个用例的持续时长(秒) | 1.5 |
+
+## 吞吐结果
+
+
+
+| 数据类型 | 操作 | Fory TPS | Protobuf TPS | 最快 |
+| ---------------- | ----------- | --------: | -----------: | ------------ |
+| Struct | Serialize | 3,989,432 | 1,884,653 | fory (2.12x) |
+| Struct | Deserialize | 5,828,197 | 4,199,680 | fory (1.39x) |
+| Sample | Serialize | 1,649,722 | 500,167 | fory (3.30x) |
+| Sample | Deserialize | 2,060,113 | 785,109 | fory (2.62x) |
+| MediaContent | Serialize | 800,876 | 391,235 | fory (2.05x) |
+| MediaContent | Deserialize | 1,315,115 | 683,533 | fory (1.92x) |
+| StructList | Serialize | 1,456,396 | 367,506 | fory (3.96x) |
+| StructList | Deserialize | 1,921,006 | 645,958 | fory (2.97x) |
+| SampleList | Serialize | 411,144 | 48,508 | fory (8.48x) |
+| SampleList | Deserialize | 464,273 | 103,558 | fory (4.48x) |
+| MediaContentList | Serialize | 186,870 | 77,029 | fory (2.43x) |
+| MediaContentList | Deserialize | 330,293 | 128,215 | fory (2.58x) |
+
+## 序列化大小(字节)
+
+| 数据类型 | Fory | Protobuf |
+| ---------------- | ---: | -------: |
+| Struct | 58 | 61 |
+| Sample | 446 | 377 |
+| MediaContent | 365 | 307 |
+| StructList | 184 | 315 |
+| SampleList | 1980 | 1900 |
+| MediaContentList | 1535 | 1550 |
+
+## 各工作负载图表
+
+### Struct
+
+
+
+### Sample
+
+
+
+### MediaContent
+
+
+
+### StructList
+
+
+
+### SampleList
+
+
+
+### MediaContentList
+
+
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/mediacontent.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/mediacontent.png
new file mode 100644
index 000000000..17bd33a9b
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/mediacontent.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/mediacontentlist.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/mediacontentlist.png
new file mode 100644
index 000000000..a0d404e06
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/mediacontentlist.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/sample.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/sample.png
new file mode 100644
index 000000000..11f2d7743
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/sample.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/samplelist.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/samplelist.png
new file mode 100644
index 000000000..a4b8cb1c0
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/samplelist.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/struct.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/struct.png
new file mode 100644
index 000000000..7d616cbed
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/struct.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/structlist.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/structlist.png
new file mode 100644
index 000000000..01484cfe9
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/structlist.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/throughput.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/throughput.png
new file mode 100644
index 000000000..f0c4d91d8
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/dart/throughput.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/README.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/README.md
new file mode 100644
index 000000000..9aa5ca43a
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/README.md
@@ -0,0 +1,104 @@
+# JavaScript 基准性能报告
+
+_生成于 2026-04-14 17:11:43_
+
+## 如何生成本报告
+
+```bash
+cd benchmarks/javascript
+./run.sh
+```
+
+## 硬件与操作系统信息
+
+| 键 | 值 |
+| -------------------------- | ------------------------ |
+| 操作系统 | Darwin 24.6.0 |
+| 机器架构 | arm64 |
+| 处理器 | arm |
+| CPU 核心数(物理) | 12 |
+| CPU 核心数(逻辑) | 12 |
+| 总内存(GB) | 48.0 |
+| 基准日期 | 2026-04-14T09:09:51.959Z |
+| CPU 核心数(基准采集) | 12 |
+| Node.js | v22.20.0 |
+| V8 | 12.4.254.21-node.33 |
+
+## 基准图表
+
+下列各类图表均展示吞吐量(ops/sec)。
+
+### 总吞吐量
+
+
+
+### MediaContent
+
+
+
+### MediaContentList
+
+
+
+### Sample
+
+
+
+### SampleList
+
+
+
+### Struct
+
+
+
+### StructList
+
+
+
+## 基准结果
+
+### 延迟结果(纳秒)
+
+| 数据类型 | 操作 | fory (ns) | protobuf (ns) | json (ns) | 最快 |
+| ---------------- | ----------- | --------- | ------------- | --------- | ------- |
+| Struct | Serialize | 118.3 | 525.3 | 327.0 | fory |
+| Struct | Deserialize | 103.0 | 121.5 | 259.0 | fory |
+| Sample | Serialize | 667.4 | 2366.2 | 1342.7 | fory |
+| Sample | Deserialize | 521.3 | 1221.0 | 1312.3 | fory |
+| MediaContent | Serialize | 773.3 | 1370.8 | 769.3 | json |
+| MediaContent | Deserialize | 610.5 | 827.0 | 1085.6 | fory |
+| StructList | Serialize | 254.6 | 2017.6 | 1121.3 | fory |
+| StructList | Deserialize | 306.3 | 653.7 | 1014.1 | fory |
+| SampleList | Serialize | 2812.3 | 10782.7 | 6130.4 | fory |
+| SampleList | Deserialize | 2353.4 | 6125.5 | 6153.1 | fory |
+| MediaContentList | Serialize | 3495.9 | 6712.4 | 3540.5 | fory |
+| MediaContentList | Deserialize | 2653.7 | 4087.9 | 5258.9 | fory |
+
+### 吞吐结果(ops/sec)
+
+| 数据类型 | 操作 | fory TPS | protobuf TPS | json TPS | 最快 |
+| ---------------- | ----------- | --------- | ------------ | --------- | ------- |
+| Struct | Serialize | 8,453,950 | 1,903,706 | 3,058,232 | fory |
+| Struct | Deserialize | 9,705,287 | 8,233,664 | 3,860,538 | fory |
+| Sample | Serialize | 1,498,391 | 422,620 | 744,790 | fory |
+| Sample | Deserialize | 1,918,162 | 819,010 | 762,048 | fory |
+| MediaContent | Serialize | 1,293,157 | 729,497 | 1,299,908 | json |
+| MediaContent | Deserialize | 1,638,086 | 1,209,140 | 921,191 | fory |
+| StructList | Serialize | 3,928,325 | 495,648 | 891,810 | fory |
+| StructList | Deserialize | 3,264,827 | 1,529,744 | 986,144 | fory |
+| SampleList | Serialize | 355,581 | 92,741 | 163,120 | fory |
+| SampleList | Deserialize | 424,916 | 163,253 | 162,520 | fory |
+| MediaContentList | Serialize | 286,053 | 148,977 | 282,445 | fory |
+| MediaContentList | Deserialize | 376,826 | 244,622 | 190,155 | fory |
+
+### 序列化数据大小(字节)
+
+| 数据类型 | fory | protobuf | json |
+| ---------------- | ---- | -------- | ---- |
+| Struct | 58 | 61 | 103 |
+| Sample | 446 | 377 | 724 |
+| MediaContent | 391 | 307 | 596 |
+| StructList | 184 | 315 | 537 |
+| SampleList | 1980 | 1900 | 3642 |
+| MediaContentList | 1665 | 1550 | 3009 |
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/mediacontent.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/mediacontent.png
new file mode 100644
index 000000000..45d2c34db
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/mediacontent.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/mediacontentlist.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/mediacontentlist.png
new file mode 100644
index 000000000..a5763d069
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/mediacontentlist.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/sample.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/sample.png
new file mode 100644
index 000000000..57c619b33
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/sample.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/samplelist.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/samplelist.png
new file mode 100644
index 000000000..6e66a0a11
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/samplelist.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/struct.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/struct.png
new file mode 100644
index 000000000..e78a56967
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/struct.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/structlist.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/structlist.png
new file mode 100644
index 000000000..cae684ed2
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/structlist.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/throughput.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/throughput.png
new file mode 100644
index 000000000..fffd41c47
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/javascript/throughput.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/python/README.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/python/README.md
index 0cf659028..053db4c42 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/python/README.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/python/README.md
@@ -1,6 +1,6 @@
# Python 基准性能报告
-_生成于 2026-03-03 13:42:38_
+_生成于 2026-04-14 14:53:18_
## 如何生成本报告
@@ -39,89 +39,75 @@ cd benchmarks/python
### 总吞吐量
-<p align="center">
-<img src="throughput.png" width="90%" />
-</p>
+
-### `MediaContent` 基准
+### Mediacontent
-<p align="center">
-<img src="mediacontent.png" width="90%" />
-</p>
+
-### `MediaContentList` 基准
+### Mediacontentlist
-<p align="center">
-<img src="mediacontentlist.png" width="90%" />
-</p>
+
### Sample
-<p align="center">
-<img src="sample.png" width="90%" />
-</p>
+
### Samplelist
-<p align="center">
-<img src="samplelist.png" width="90%" />
-</p>
+
### Struct
-<p align="center">
-<img src="struct.png" width="90%" />
-</p>
+
### Structlist
-<p align="center">
-<img src="structlist.png" width="90%" />
-</p>
+
## 基准结果
### 延迟结果(纳秒)
-| 数据类型 | 操作 | fory (ns) | pickle (ns) | protobuf (ns) | 最快 |
-| ---------------- | ----------- | --------- | ----------- | ------------- | ------- |
-| Struct | Serialize | 417.9 | 868.9 | 548.9 | fory |
-| Struct | Deserialize | 516.1 | 910.6 | 742.4 | fory |
-| Sample | Serialize | 828.1 | 1663.5 | 2383.7 | fory |
-| Sample | Deserialize | 1282.4 | 2296.3 | 3992.7 | fory |
-| MediaContent | Serialize | 1139.9 | 2859.7 | 2867.1 | fory |
-| MediaContent | Deserialize | 1719.5 | 2854.3 | 3236.1 | fory |
-| StructList | Serialize | 1009.1 | 2630.6 | 3281.6 | fory |
-| StructList | Deserialize | 1387.2 | 2651.9 | 3547.9 | fory |
-| SampleList | Serialize | 2828.3 | 5541.0 | 15256.6 | fory |
-| SampleList | Deserialize | 5043.4 | 8144.7 | 18912.5 | fory |
-| MediaContentList | Serialize | 3417.9 | 9341.9 | 15853.2 | fory |
-| MediaContentList | Deserialize | 6138.7 | 8435.3 | 16442.6 | fory |
+| 数据类型 | 操作 | fory (ns) | pickle (ns) | protobuf (ns) | 最快 |
+| ---------------- | ----------- | --------- | ----------- | ------------- | -------- |
+| Struct | Serialize | 431.3 | 963.9 | 604.3 | fory |
+| Struct | Deserialize | 476.6 | 925.1 | 804.8 | fory |
+| Sample | Serialize | 4966.3 | 12725.1 | 4396.0 | protobuf |
+| Sample | Deserialize | 4362.9 | 6409.2 | 6620.1 | fory |
+| MediaContent | Serialize | 1213.1 | 4263.1 | 3173.7 | fory |
+| MediaContent | Deserialize | 1620.7 | 4625.8 | 4306.3 | fory |
+| StructList | Serialize | 1072.0 | 2798.6 | 3759.0 | fory |
+| StructList | Deserialize | 1334.7 | 2756.7 | 3963.5 | fory |
+| SampleList | Serialize | 23866.8 | 33484.5 | 18711.7 | protobuf |
+| SampleList | Deserialize | 17347.5 | 22999.0 | 36077.1 | fory |
+| MediaContentList | Serialize | 3526.9 | 11258.1 | 17670.6 | fory |
+| MediaContentList | Deserialize | 6241.1 | 10209.5 | 21440.7 | fory |
### 吞吐结果(ops/sec)
-| 数据类型 | 操作 | fory TPS | pickle TPS | protobuf TPS | 最快 |
-| ---------------- | ----------- | --------- | ---------- | ------------ | ------- |
-| Struct | Serialize | 2,393,086 | 1,150,946 | 1,821,982 | fory |
-| Struct | Deserialize | 1,937,707 | 1,098,170 | 1,346,915 | fory |
-| Sample | Serialize | 1,207,542 | 601,144 | 419,511 | fory |
-| Sample | Deserialize | 779,789 | 435,489 | 250,460 | fory |
-| MediaContent | Serialize | 877,300 | 349,688 | 348,780 | fory |
-| MediaContent | Deserialize | 581,563 | 350,354 | 309,018 | fory |
-| StructList | Serialize | 991,017 | 380,145 | 304,732 | fory |
-| StructList | Deserialize | 720,901 | 377,081 | 281,855 | fory |
-| SampleList | Serialize | 353,574 | 180,473 | 65,545 | fory |
-| SampleList | Deserialize | 198,280 | 122,780 | 52,875 | fory |
-| MediaContentList | Serialize | 292,578 | 107,045 | 63,079 | fory |
-| MediaContentList | Deserialize | 162,902 | 118,550 | 60,818 | fory |
+| 数据类型 | 操作 | fory TPS | pickle TPS | protobuf TPS | 最快 |
+| ---------------- | ----------- | --------- | ---------- | ------------ | -------- |
+| Struct | Serialize | 2,318,598 | 1,037,429 | 1,654,700 | fory |
+| Struct | Deserialize | 2,098,391 | 1,081,003 | 1,242,545 | fory |
+| Sample | Serialize | 201,358 | 78,585 | 227,479 | protobuf |
+| Sample | Deserialize | 229,204 | 156,026 | 151,056 | fory |
+| MediaContent | Serialize | 824,338 | 234,569 | 315,087 | fory |
+| MediaContent | Deserialize | 616,999 | 216,177 | 232,216 | fory |
+| StructList | Serialize | 932,803 | 357,322 | 266,029 | fory |
+| StructList | Deserialize | 749,212 | 362,753 | 252,301 | fory |
+| SampleList | Serialize | 41,899 | 29,865 | 53,442 | protobuf |
+| SampleList | Deserialize | 57,645 | 43,480 | 27,718 | fory |
+| MediaContentList | Serialize | 283,535 | 88,825 | 56,591 | fory |
+| MediaContentList | Deserialize | 160,227 | 97,948 | 46,640 | fory |
### 序列化数据大小(字节)
| 数据类型 | fory | pickle | protobuf |
| ---------------- | ---- | ------ | -------- |
-| Struct | 72 | 126 | 61 |
-| Sample | 517 | 793 | 375 |
-| MediaContent | 470 | 586 | 301 |
-| StructList | 205 | 420 | 315 |
-| SampleList | 1810 | 2539 | 1890 |
-| MediaContentList | 1756 | 1377 | 1520 |
+| Struct | 58 | 126 | 61 |
+| Sample | 446 | 1176 | 375 |
+| MediaContent | 391 | 624 | 301 |
+| StructList | 184 | 420 | 315 |
+| SampleList | 1980 | 3546 | 1890 |
+| MediaContentList | 1665 | 1415 | 1520 |
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/README.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/README.md
index fdaa812b8..d09f26abf 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/README.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/README.md
@@ -1,104 +1,103 @@
-## 性能对比报告
+# Rust 基准性能报告
-_生成时间:2025-10-26 18:36:41_
+_生成于 2026-03-20 18:40:46_
-如何生成性能报告:
+## 如何生成本报告
```bash
-cd benchmarks/rust_benchmark
-cargo bench 2>&1 | tee cargo_bench.log
-python benchmark_report.py --log-file cargo_bench.log --output-dir=report_output
+cd benchmarks/rust
+cargo bench --bench serialization_bench 2>&1 | tee results/cargo_bench.log
+cargo run --release --bin fory_profiler -- --print-all-serialized-sizes | tee results/serialized_sizes.txt
+python benchmark_report.py --log-file results/cargo_bench.log --size-file results/serialized_sizes.txt --output-dir results
```
-### 硬件与系统信息
-
-| Key | Value |
-| -------------------- | ------------- |
-| OS | Darwin 24.5.0 |
-| Machine | arm64 |
-| Processor | arm |
-| CPU Cores (Physical) | 12 |
-| CPU Cores (Logical) | 12 |
-| Total RAM (GB) | 48.0 |
-
-### 基准图表
-
-**company**
-
-
-
-**ecommerce_data**
-
-
-
-**person**
-
-
-
-**simple_list**
-
-
-
-**simple_map**
-
-
-
-**simple_struct**
-
-
-
-**system_data**
-
-
-
-### 序列化结果
-
-| Datatype | Size | Operation | Fory TPS | JSON TPS | Protobuf TPS | Fastest |
-| -------------- | ------ | --------- | ---------- | ---------- | ------------ | ------- |
-| company | small | serialize | 10,063,906 | 761,673 | 896,620 | fory |
-| company | medium | serialize | 412,507 | 33,835 | 37,590 | fory |
-| company | large | serialize | 9,183 | 793 | 880 | fory |
-| ecommerce_data | small | serialize | 2,350,729 | 206,262 | 256,970 | fory |
-| ecommerce_data | medium | serialize | 59,977 | 4,699 | 5,242 | fory |
-| ecommerce_data | large | serialize | 3,727 | 266 | 295 | fory |
-| person | small | serialize | 13,632,522 | 1,345,189 | 1,475,035 | fory |
-| person | medium | serialize | 3,839,656 | 337,610 | 369,031 | fory |
-| person | large | serialize | 907,853 | 79,631 | 91,408 | fory |
-| simple_list | small | serialize | 27,726,945 | 4,874,957 | 4,643,172 | fory |
-| simple_list | medium | serialize | 4,770,765 | 401,558 | 397,551 | fory |
-| simple_list | large | serialize | 606,061 | 41,061 | 44,565 | fory |
-| simple_map | small | serialize | 22,862,369 | 3,888,025 | 2,695,999 | fory |
-| simple_map | medium | serialize | 2,128,973 | 204,319 | 193,132 | fory |
-| simple_map | large | serialize | 177,847 | 18,419 | 18,668 | fory |
-| simple_struct | small | serialize | 35,729,598 | 10,167,045 | 8,633,342 | fory |
-| simple_struct | medium | serialize | 34,988,279 | 9,737,098 | 6,433,350 | fory |
-| simple_struct | large | serialize | 31,801,558 | 4,545,041 | 7,420,049 | fory |
-| system_data | small | serialize | 5,382,131 | 468,033 | 569,930 | fory |
-| system_data | medium | serialize | 174,240 | 11,896 | 14,753 | fory |
-| system_data | large | serialize | 10,671 | 876 | 1,040 | fory |
-
-### 反序列化结果
-
-| Datatype | Size | Operation | Fory TPS | JSON TPS | Protobuf TPS | Fastest |
-| -------------- | ------ | ----------- | ---------- | ---------- | ------------ | ------- |
-| company | small | deserialize | 1,145,593 | 718,597 | 917,431 | fory |
-| company | medium | deserialize | 35,195 | 24,474 | 25,057 | fory |
-| company | large | deserialize | 836 | 623 | 623 | fory |
-| ecommerce_data | small | deserialize | 278,427 | 183,237 | 241,109 | fory |
-| ecommerce_data | medium | deserialize | 5,622 | 3,820 | 4,249 | fory |
-| ecommerce_data | large | deserialize | 298 | 204 | 217 | fory |
-| person | small | deserialize | 1,924,372 | 1,214,388 | 1,675,631 | fory |
-| person | medium | deserialize | 371,016 | 265,280 | 266,333 | fory |
-| person | large | deserialize | 84,839 | 63,975 | 61,820 | fory |
-| simple_list | small | deserialize | 6,129,329 | 3,599,582 | 4,429,286 | fory |
-| simple_list | medium | deserialize | 460,745 | 305,409 | 337,336 | fory |
-| simple_list | large | deserialize | 54,348 | 33,962 | 38,776 | fory |
-| simple_map | small | deserialize | 3,686,364 | 3,090,426 | 3,477,051 | fory |
-| simple_map | medium | deserialize | 171,774 | 126,638 | 119,323 | fory |
-| simple_map | large | deserialize | 16,501 | 10,920 | 10,853 | fory |
-| simple_struct | small | deserialize | 31,476,235 | 12,948,168 | 28,280,543 | fory |
-| simple_struct | medium | deserialize | 30,077,902 | 10,431,118 | 23,012,841 | fory |
-| simple_struct | large | deserialize | 28,201,585 | 8,955,759 | 23,528,858 | fory |
-| system_data | small | deserialize | 644,870 | 421,106 | 549,209 | fory |
-| system_data | medium | deserialize | 14,322 | 9,205 | 10,565 | fory |
-| system_data | large | deserialize | 961 | 634 | 706 | fory |
+## 硬件与操作系统信息
+
+| 键 | 值 |
+| --------------------- | ------------------- |
+| 操作系统 | Darwin 24.6.0 |
+| 机器架构 | arm64 |
+| 处理器 | arm |
+| CPU 核心数(物理) | 12 |
+| CPU 核心数(逻辑) | 12 |
+| 总内存(GB) | 48.0 |
+| 基准日期 | 2026-03-20T18:40:44 |
+
+## 基准图表
+
+下列各类图表均展示吞吐量(ops/sec)。
+
+### 总吞吐量
+
+
+
+### MediaContent
+
+
+
+### MediaContentList
+
+
+
+### Sample
+
+
+
+### SampleList
+
+
+
+### Struct
+
+
+
+### StructList
+
+
+
+## 基准结果
+
+### 延迟结果(纳秒)
+
+| 数据类型 | 操作 | fory (ns) | protobuf (ns) | 最快 |
+| ---------------- | ----------- | --------- | ------------- | ------- |
+| Struct | Serialize | 69.6 | 76.8 | fory |
+| Struct | Deserialize | 27.0 | 70.4 | fory |
+| Sample | Serialize | 148.5 | 584.3 | fory |
+| Sample | Deserialize | 350.9 | 983.1 | fory |
+| MediaContent | Serialize | 277.8 | 553.2 | fory |
+| MediaContent | Deserialize | 472.3 | 706.4 | fory |
+| StructList | Serialize | 170.4 | 385.4 | fory |
+| StructList | Deserialize | 96.8 | 294.7 | fory |
+| SampleList | Serialize | 356.2 | 3155.7 | fory |
+| SampleList | Deserialize | 1644.1 | 4361.0 | fory |
+| MediaContentList | Serialize | 657.4 | 2844.0 | fory |
+| MediaContentList | Deserialize | 2397.7 | 3696.6 | fory |
+
+### 吞吐结果(ops/sec)
+
+| 数据类型 | 操作 | fory TPS | protobuf TPS | 最快 |
+| ---------------- | ----------- | ---------- | ------------ | ------- |
+| Struct | Serialize | 14,366,165 | 13,022,359 | fory |
+| Struct | Deserialize | 37,065,866 | 14,202,528 | fory |
+| Sample | Serialize | 6,734,914 | 1,711,537 | fory |
+| Sample | Deserialize | 2,849,409 | 1,017,201 | fory |
+| MediaContent | Serialize | 3,600,230 | 1,807,664 | fory |
+| MediaContent | Deserialize | 2,117,433 | 1,415,689 | fory |
+| StructList | Serialize | 5,866,823 | 2,595,043 | fory |
+| StructList | Deserialize | 10,330,152 | 3,393,051 | fory |
+| SampleList | Serialize | 2,807,333 | 316,887 | fory |
+| SampleList | Deserialize | 608,236 | 229,305 | fory |
+| MediaContentList | Serialize | 1,521,098 | 351,617 | fory |
+| MediaContentList | Deserialize | 417,066 | 270,519 | fory |
+
+### 序列化数据大小(字节)
+
+| 数据类型 | fory | protobuf |
+| ---------------- | ---- | -------- |
+| Struct | 58 | 61 |
+| Sample | 446 | 375 |
+| MediaContent | 365 | 301 |
+| StructList | 184 | 315 |
+| SampleList | 1980 | 1890 |
+| MediaContentList | 1535 | 1520 |
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/mediacontent.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/mediacontent.png
new file mode 100644
index 000000000..8d026ef4b
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/mediacontent.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/mediacontentlist.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/mediacontentlist.png
new file mode 100644
index 000000000..f2bf6b721
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/mediacontentlist.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/sample.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/sample.png
new file mode 100644
index 000000000..e63ebcbad
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/sample.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/samplelist.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/samplelist.png
new file mode 100644
index 000000000..b7ba75b72
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/samplelist.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/struct.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/struct.png
new file mode 100644
index 000000000..e12c6a332
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/struct.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/structlist.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/structlist.png
new file mode 100644
index 000000000..e030cf45f
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/structlist.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/throughput.png b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/throughput.png
new file mode 100644
index 000000000..be89782fb
Binary files /dev/null and b/i18n/zh-CN/docusaurus-plugin-content-docs/current/benchmarks/rust/throughput.png differ
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/compiler-guide.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/compiler-guide.md
index 0046cbcd3..54e888663 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/compiler-guide.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/compiler-guide.md
@@ -63,7 +63,11 @@ foryc --scan-generated [OPTIONS]
| `--cpp_out=DST_DIR` | 将 C++ 代码输出到 `DST_DIR` | (无) |
| `--go_out=DST_DIR` | 将 Go 代码输出到 `DST_DIR` | (无) |
| `--rust_out=DST_DIR` | 将 Rust 代码输出到 `DST_DIR` | (无) |
+| `--javascript_out=DST_DIR` | 将 JavaScript 代码输出到 `DST_DIR` | (无) |
+| `--swift_out=DST_DIR` | 将 Swift 代码输出到 `DST_DIR` | (无) |
+| `--dart_out=DST_DIR` | 将 Dart 代码输出到 `DST_DIR` | (无) |
| `--go_nested_type_style` | Go 嵌套类型命名风格:`camelcase` 或 `underscore` | schema/默认值 |
+| `--swift_namespace_style` | Swift 命名空间风格:`enum` 或 `flatten` | `enum` |
| `--emit-fdl` | 对非 `.fdl` 输入打印转换后的 Fory IDL | `false` |
| `--emit-fdl-path` | 将转换后的 Fory IDL 写入文件或目录 | (stdout) |
@@ -108,7 +112,7 @@ foryc schema.fdl
**为指定语言编译:**
```bash
-foryc schema.fdl --lang java,python
+foryc schema.fdl --lang java,python,csharp,javascript,swift,dart
```
**指定输出目录:**
@@ -129,6 +133,12 @@ foryc schema.fdl --package com.myapp.models
foryc user.fdl order.fdl product.fdl --output ./generated
```
+**编译包含 service 定义的简单 schema(生成 Java + Python 模型):**
+
+```bash
+foryc compiler/examples/service.fdl --java_out=./generated/java --python_out=./generated/python
+```
+
**使用 import 搜索路径:**
```bash
@@ -155,7 +165,7 @@ foryc src/main.fdl -I libs/common,libs/types --proto_path third_party/
foryc schema.fdl --java_out=./src/main/java
# 多语言分别输出到不同目录
-foryc schema.fdl --java_out=./java/gen --python_out=./python/src --go_out=./go/gen
+foryc schema.fdl --java_out=./java/gen --python_out=./python/src --go_out=./go/gen --csharp_out=./csharp/gen --javascript_out=./javascript/src --swift_out=./swift/gen --dart_out=./dart/gen
# 结合 import 路径
foryc schema.fdl --java_out=./gen/java -I proto/ -I common/
@@ -224,13 +234,16 @@ Compiling src/main.fdl...
## 支持语言
-| 语言 | 标记 | 输出后缀 | 说明 |
-| ------ | -------- | -------- | ---------------------- |
-| Java | `java` | `.java` | 带 Fory 注解的 POJO |
-| Python | `python` | `.py` | 带类型提示的 dataclass |
-| Go | `go` | `.go` | 带 struct tag 的结构体 |
-| Rust | `rust` | `.rs` | 带 derive 宏的结构体 |
-| C++ | `cpp` | `.h` | 带 FORY 宏的结构体 |
+| 语言 | 标记 | 输出后缀 | 说明 |
+| ---------- | ------------ | -------- | ------------------------- |
+| Java | `java` | `.java` | 带 Fory 注解的 POJO |
+| Python | `python` | `.py` | 带类型提示的 dataclass |
+| Go | `go` | `.go` | 带 struct tag 的结构体 |
+| Rust | `rust` | `.rs` | 带 derive 宏的结构体 |
+| C++ | `cpp` | `.h` | 带 FORY 宏的结构体 |
+| JavaScript | `javascript` | `.ts` | 带注册函数的接口 |
+| Swift | `swift` | `.swift` | `@ForyObject` Swift 模型 |
+| Dart | `dart` | `.dart` | 带注解的 `@ForyStruct` 类 |
## 输出结构
@@ -300,6 +313,35 @@ generated/
- 命名空间与 package 对齐(点号转换为 `::`)
- 自动包含 header guard 与前向声明
+### JavaScript
+
+```
+generated/
+└── javascript/
+ └── example.ts
+```
+
+- 每个 schema 生成一个 `.ts` 文件
+- message 生成为 `export interface`
+- enum 生成为 `export enum`
+- union 生成为带 case enum 的判别联合
+- 文件内包含注册辅助函数
+
+### Dart
+
+```
+generated/
+└── dart/
+ └── package/
+ ├── package.dart
+ └── package.fory.dart
+```
+
+- 每个 schema 生成两个文件:带注解类型的主 `.dart` 文件,以及带序列化器的 `.fory.dart` part 文件
+- package 各段映射为目录层级(例如 `demo.foo` -> `demo/foo/`)
+- 注册辅助类位于 part 文件中
+- 非可空、非 `ref` 的基础类型列表会使用类型化数组(例如 `Int32List`)
+
## 构建系统集成
### Maven (Java)
@@ -488,6 +530,30 @@ cc_library(
)
```
+### Dart / Flutter
+
+在 `pubspec.yaml` 中加入 Fory 依赖:
+
+```yaml
+dependencies:
+ fory: ^0.1.0
+
+dev_dependencies:
+ build_runner: ^2.4.0
+```
+
+用编译器生成 schema 类型:
+
+```bash
+foryc schema.fdl --dart_out=lib/generated
+```
+
+随后运行 `build_runner` 生成序列化器:
+
+```bash
+dart run build_runner build
+```
+
## 错误处理
### 语法错误
@@ -496,6 +562,18 @@ cc_library(
Error: Line 5, Column 12: Expected ';' after field declaration
```
+### 未知类型引用
+
+```
+Error: Unknown type 'Address' in Customer.address
+```
+
+修复方式:先定义被引用的类型,或检查拼写是否正确。
+
+service RPC 的请求和响应类型也按同样规则校验。例如
+`rpc SayHello (HelloRequest) returns (HelloReply);`
+中的类型必须已定义;否则校验器会在 RPC 所在行报出 `Unknown type '...'` 错误。
+
修复方式:检查对应行是否缺少分号或存在语法问题。
### 类型名重复
@@ -653,3 +731,10 @@ fory = "x.y.z"
```
**C++:** 确保编译器 include 路径可找到 Fory 头文件。
+
+**Dart:** 确保 `pubspec.yaml` 中包含 fory 依赖:
+
+```yaml
+dependencies:
+ fory: ^0.1.0
+```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/generated-code.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/generated-code.md
index cadf241ab..024eb203c 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/generated-code.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/generated-code.md
@@ -685,6 +685,321 @@ if err := restored.FromBytes(data); err != nil {
}
```
+## C\#
+
+### 输出布局
+
+C# 输出通常是每个 schema 对应一个 `.cs` 文件,例如:
+
+- `<csharp_out>/addressbook/addressbook.cs`
+
+### 类型生成
+
+message 会生成带 `[ForyObject]` 的类、C# 属性以及字节辅助方法:
+
+```csharp
+[ForyObject]
+public sealed partial class Person
+{
+ public string Name { get; set; } = string.Empty;
+ public int Id { get; set; }
+ public List<Person.PhoneNumber> Phones { get; set; } = new();
+ public Animal Pet { get; set; } = null!;
+
+ public byte[] ToBytes() { ... }
+ public static Person FromBytes(byte[] data) { ... }
+}
+```
+
+union 会生成带类型化 case 辅助方法的 `Union` 子类:
+
+```csharp
+public sealed class Animal : Union
+{
+ public static Animal Dog(Dog value) { ... }
+ public static Animal Cat(Cat value) { ... }
+ public bool IsDog => ...;
+ public Dog DogValue() { ... }
+}
+```
+
+### 注册
+
+每个 schema 都会生成一个注册辅助类:
+
+```csharp
+public static class AddressbookForyRegistration
+{
+ public static void Register(Fory fory)
+ {
+ fory.Register<addressbook.Animal>((uint)106);
+ fory.Register<addressbook.Person>((uint)100);
+ // ...
+ }
+}
+```
+
+若未显式提供类型 ID,生成的注册代码会像其他目标语言一样使用计算得到的数值 ID。
+
+## JavaScript
+
+### 输出布局
+
+JavaScript 输出通常是每个 schema 对应一个 `.ts` 文件,例如:
+
+- `<javascript_out>/addressbook.ts`
+
+### 类型生成
+
+message 会生成使用 camelCase 字段名的 `export interface` 声明:
+
+```typescript
+export interface Person {
+ name: string;
+ id: number;
+ phones: PhoneNumber[];
+ pet?: Animal | null;
+}
+```
+
+enum 会生成 `export enum` 声明:
+
+```typescript
+export enum PhoneType {
+ MOBILE = 0,
+ HOME = 1,
+ WORK = 2,
+}
+```
+
+union 会生成带 case enum 的判别联合类型:
+
+```typescript
+export enum AnimalCase {
+ DOG = 1,
+ CAT = 2,
+}
+
+export type Animal =
+ | { case: AnimalCase.DOG; value: Dog }
+ | { case: AnimalCase.CAT; value: Cat };
+```
+
+## Swift
+
+### 输出布局
+
+Swift 输出通常是每个 schema 对应一个 `.swift` 文件,例如:
+
+- `<swift_out>/addressbook/addressbook.swift`
+
+### 类型生成
+
+生成器会创建带 `@ForyObject` 和字段 ID 的 Swift 模型。
+
+当 package/namespace 非空时,命名空间形态由 `swift_namespace_style` 控制:
+
+- `enum`(默认):生成嵌套 enum 命名空间包装
+- `flatten`:在顶层类型名上加上由 package 派生的前缀(例如 `Demo_Foo_User`)
+
+当 package/namespace 为空时,不会生成 enum 包装或 flatten 前缀。
+
+对于非空 package 且使用默认 `enum` 风格时:
+
+```swift
+public enum Addressbook {
+ @ForyObject
+ public enum Animal: Equatable {
+ @ForyField(id: 1)
+ case dog(Addressbook.Dog)
+ @ForyField(id: 2)
+ case cat(Addressbook.Cat)
+ }
+
+ @ForyObject
+ public struct Person: Equatable {
+ @ForyField(id: 1)
+ public var name: String = ""
+ @ForyField(id: 8)
+ public var pet: Addressbook.Animal = .foryDefault()
+ }
+}
+```
+
+对于非空 package 且使用 `flatten` 风格时:
+
+```swift
+@ForyObject
+public struct Addressbook_Person: Equatable { ... }
+```
+
+当命令行和 schema 选项同时设置时,CLI 参数 `--swift_namespace_style` 会覆盖 schema 中的 `swift_namespace_style`。
+
+union 会生成带关联值的标记 Swift enum。
+带 `ref`/`weak_ref` 字段的 message 会生成 `final class` 模型,以保留引用语义。
+
+### 注册
+
+每个 schema 都会生成带传递性 import 注册的辅助类:
+
+```swift
+public enum ForyRegistration {
+ public static func register(_ fory: Fory) throws {
+ try ComplexPb.ForyRegistration.register(fory)
+ fory.register(Addressbook.Person.self, id: 100)
+ fory.register(Addressbook.Animal.self, id: 106)
+ }
+}
+```
+
+对于非空 package 且使用 `flatten` 风格时,辅助类名称也会带前缀(例如 `Addressbook_ForyRegistration`)。
+
+若未显式提供 `[id=...]`,注册会使用计算得到的数值 ID。
+若设置 `option enable_auto_type_id = false;`,则生成代码会改用基于名称的注册 API。
+
+## Dart
+
+### 输出布局
+
+Dart 输出通常是每个 schema 对应两个文件:一个带注解类型的主 `.dart` 文件,以及一个包含生成序列化器和注册辅助逻辑的 `.fory.dart` part 文件。
+
+- `<dart_out>/package/package.dart`
+- `<dart_out>/package/package.fory.dart`
+
+### 类型生成
+
+message 会生成带 `@ForyStruct` 注解的 `final class`,并在每个字段上加 `@ForyField`:
+
+```dart
+@ForyStruct()
+final class Person {
+ Person();
+
+ @ForyField(id: 1)
+ String name = '';
+
+ @ForyField(id: 2)
+ Int32 id = Int32(0);
+
+ @ForyField(id: 7)
+ List<Person_PhoneNumber> phones = <Person_PhoneNumber>[];
+
+ @ForyField(id: 8)
+ Animal pet = Animal._empty();
+}
+```
+
+enum 会生成带 `rawValue` getter 和 `fromRawValue` factory 的 Dart `enum`:
+
+```dart
+enum Person_PhoneType {
+ mobile,
+ home,
+ work;
+
+ int get rawValue => switch (this) {
+ Person_PhoneType.mobile => 0,
+ Person_PhoneType.home => 1,
+ Person_PhoneType.work => 2,
+ };
+
+ static Person_PhoneType fromRawValue(int value) => switch (value) {
+ 0 => Person_PhoneType.mobile,
+ 1 => Person_PhoneType.home,
+ 2 => Person_PhoneType.work,
+ _ => throw StateError('Unknown Person_PhoneType raw value $value.'),
+ };
+}
+```
+
+union 会生成带 `@ForyUnion` 注解的类,包含工厂构造器、case enum 以及自定义序列化器:
+
+```dart
+enum AnimalCase {
+ dog,
+ cat;
+
+ int get id => switch (this) {
+ AnimalCase.dog => 1,
+ AnimalCase.cat => 2,
+ };
+}
+
+@ForyUnion()
+final class Animal {
+ final AnimalCase _case;
+ final Object? _value;
+
+ const Animal._(this._case, this._value);
+
+ factory Animal.dog(Dog value) => Animal._(AnimalCase.dog, value);
+ factory Animal.cat(Cat value) => Animal._(AnimalCase.cat, value);
+
+ bool get isDog => _case == AnimalCase.dog;
+ Dog get dogValue => _value as Dog;
+ // ...
+}
+```
+
+嵌套类型使用扁平下划线命名(例如 `Person_PhoneNumber`、`Person_PhoneType`)。
+
+非 optional、非 ref 的原始类型列表会使用 typed array 以获得零拷贝性能(例如 `list<int32>` -> `Int32List`)。
+
+列表元素或 map value 上的引用跟踪通过 `@ListType` / `@MapType` 注解表达:
+
+```dart
+@ListType(element: ValueType.ref())
+@ForyField(id: 3)
+List<Node> children = <Node>[];
+
+@MapType(value: ValueType.ref())
+@ForyField(id: 2)
+Map<String, Node> byName = <String, Node>{};
+```
+
+### 注册
+
+每个 schema 都会生成一个注册辅助类,负责处理该文件中的所有类型,并传递性注册 import 进来的类型:
+
+```dart
+abstract final class ForyRegistration {
+ static void register(
+ Fory fory,
+ Type type, {
+ int? id,
+ String? namespace,
+ String? typeName,
+ }) {
+ if (type == Person) {
+ registerGeneratedStruct(fory, _personForyRegistration, id: id, namespace: namespace, typeName: typeName);
+ return;
+ }
+ // ... other types
+ }
+}
+```
+
+### 使用示例
+
+```dart
+import 'package:fory/fory.dart';
+import 'generated/addressbook/addressbook.dart';
+
+void main() {
+ final fory = Fory();
+ ForyRegistration.register(fory, Person, id: 100);
+ ForyRegistration.register(fory, Dog, id: 104);
+ // ...
+
+ final person = Person()
+ ..name = 'Alice'
+ ..id = Int32(1);
+
+ final bytes = fory.serialize(person);
+ final roundTrip = fory.deserialize<Person>(bytes);
+}
+```
+
## 跨语言说明
### 类型 ID 行为
@@ -695,20 +1010,28 @@ if err := restored.FromBytes(data); err != nil {
### 嵌套类型形态
-| 语言 | 嵌套类型形式 |
-| ------ | ---------------------------- |
-| Java | `Person.PhoneNumber` |
-| Python | `Person.PhoneNumber` |
-| Rust | `person::PhoneNumber` |
-| C++ | `Person::PhoneNumber` |
-| Go | `Person_PhoneNumber`(默认) |
+| 语言 | 嵌套类型形式 |
+| ---------- | ---------------------------- |
+| Java | `Person.PhoneNumber` |
+| Python | `Person.PhoneNumber` |
+| Rust | `person::PhoneNumber` |
+| C++ | `Person::PhoneNumber` |
+| Go | `Person_PhoneNumber`(默认) |
+| C# | `Person.PhoneNumber` |
+| JavaScript | `Person.PhoneNumber` |
+| Swift | `Person.PhoneNumber` |
+| Dart | `Person_PhoneNumber` |
### 字节辅助方法命名
-| 语言 | 辅助方法名称 |
-| ------ | ------------------------- |
-| Java | `toBytes` / `fromBytes` |
-| Python | `to_bytes` / `from_bytes` |
-| Rust | `to_bytes` / `from_bytes` |
-| C++ | `to_bytes` / `from_bytes` |
-| Go | `ToBytes` / `FromBytes` |
+| 语言 | 辅助方法名称 |
+| ---------- | ------------------------- |
+| Java | `toBytes` / `fromBytes` |
+| Python | `to_bytes` / `from_bytes` |
+| Rust | `to_bytes` / `from_bytes` |
+| C++ | `to_bytes` / `from_bytes` |
+| Go | `ToBytes` / `FromBytes` |
+| C# | `ToBytes` / `FromBytes` |
+| JavaScript | (通过 `fory.serialize()`) |
+| Swift | `toBytes` / `fromBytes` |
+| Dart | (通过 `fory.serialize()`) |
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/index.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/index.md
index 8e26cdd38..73caa1018 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/index.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/index.md
@@ -20,7 +20,7 @@ license: |
---
Fory IDL 是 Apache Fory 的 Schema 定义语言,可实现类型安全的跨语言序列化。
-你只需定义一次数据结构,即可为 Java、Python、Go、Rust 和 C++ 生成原生数据结构代码。
+你只需定义一次数据结构,即可为 Java、Python、Go、Rust、C++、C#、Swift、JavaScript 和 Dart 生成原生数据结构代码。
## 示例 Schema
@@ -99,6 +99,10 @@ union Animal [id=106] {
- Go:带 struct tag 的结构体
- Rust:带 `#[derive(ForyObject)]` 的结构体
- C++:带 `FORY_STRUCT` 宏的结构体
+- C#:带 `[ForyObject]` 的类及注册辅助函数
+- JavaScript:带注册函数的接口
+- Swift:带 `@ForyObject` 模型、`@ForyField` 元数据和注册辅助函数
+- Dart:带 `@ForyStruct` 类、`@ForyField` 注解和注册辅助函数
## 快速开始
@@ -136,7 +140,7 @@ message Person {
foryc example.fdl --output ./generated
# 为指定语言生成
-foryc example.fdl --lang java,python --output ./generated
+foryc example.fdl --lang java,python,csharp,javascript,swift,dart --output ./generated
```
### 4. 使用生成代码
@@ -191,11 +195,11 @@ message Example {
Fory IDL 类型会映射为各语言原生类型:
-| Fory IDL 类型 | Java | Python | Go | Rust | C++ |
-| ------------- | --------- | -------------- | -------- | -------- | ------------- |
-| `int32` | `int` | `pyfory.int32` | `int32` | `i32` | `int32_t` |
-| `string` | `String` | `str` | `string` | `String` | `std::string` |
-| `bool` | `boolean` | `bool` | `bool` | `bool` | `bool` |
+| Fory IDL 类型 | Java | Python | Go | Rust | C++ | C# | JavaScript | Swift | Dart |
+| ------------- | --------- | -------------- | -------- | -------- | ------------- | -------- | ---------- | -------- | -------- |
+| `int32` | `int` | `pyfory.int32` | `int32` | `i32` | `int32_t` | `int` | `number` | `Int32` | `Int32` |
+| `string` | `String` | `str` | `string` | `String` | `std::string` | `string` | `string` | `String` | `String` |
+| `bool` | `boolean` | `bool` | `bool` | `bool` | `bool` | `bool` | `boolean` | `Bool` | `bool` |
完整映射请参见 [类型系统](schema-idl.md#type-system)。
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/schema-idl.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/schema-idl.md
index be6d5c6b2..8f56cbecd 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/schema-idl.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/compiler/schema-idl.md
@@ -91,13 +91,16 @@ package com.example.models alias models_v1;
语言映射:
-| 语言 | package 用法 |
-| ------ | ----------------------- |
-| Java | Java package |
-| Python | 模块名(`.` 转 `_`) |
-| Go | 包名(通常取最后一段) |
-| Rust | 模块名(`.` 转 `_`) |
-| C++ | 命名空间(`.` 转 `::`) |
+| 语言 | package 用法 |
+| ---------- | ------------------------- |
+| Java | Java package |
+| Python | 模块名(`.` 转 `_`) |
+| Go | 包名(通常取最后一段) |
+| Rust | 模块名(`.` 转 `_`) |
+| C++ | 命名空间(`.` 转 `::`) |
+| C# | 命名空间 |
+| JavaScript | 模块名(取最后一段) |
+| Dart | 库名(保留 package 各段) |
## 文件级选项
@@ -306,16 +309,30 @@ enum Status {
### 语言映射
-- Java:`enum`
-- Python:`IntEnum`
-- Go:`type + const`
-- Rust:`repr(i32)` 枚举
-- C++:`enum class`
+| 语言 | 实现形式 |
+| ---------- | -------------------------------------- |
+| Java | `enum Status { UNKNOWN, ACTIVE, ... }` |
+| Python | `class Status(IntEnum): UNKNOWN = 0` |
+| Go | `type Status int32` 配合常量 |
+| Rust | `#[repr(i32)] enum Status { Unknown }` |
+| C++ | `enum class Status : int32_t { ... }` |
+| JavaScript | `export enum Status { UNKNOWN, ... }` |
+| Dart | `enum Status { unknown, active, ... }` |
### 枚举前缀处理
针对 protobuf 风格 `TYPE_NAME_VALUE`,生成器通常会按语言习惯去除冗余前缀,使 API 更自然。
+| 语言 | 输出示例 | 风格 |
+| ---------- | ----------------------------------------- | ---------------- |
+| Java | `UNKNOWN, TIER1, TIER2` | 作用域枚举 |
+| Rust | `Unknown, Tier1, Tier2` | 作用域枚举 |
+| C++ | `UNKNOWN, TIER1, TIER2` | 作用域枚举 |
+| Python | `UNKNOWN, TIER1, TIER2` | 作用域 `IntEnum` |
+| Go | `DeviceTierUnknown, DeviceTierTier1, ...` | 非作用域常量 |
+| JavaScript | `UNKNOWN, TIER1, TIER2` | 作用域枚举 |
+| Dart | `unknown, tier1, tier2` | 作用域枚举 |
+
## Message 定义
### 基本语法
@@ -342,11 +359,15 @@ message User [id=100] {
### 语言映射
-- Java:类 / record(按选项)
-- Python:dataclass
-- Go:struct
-- Rust:struct
-- C++:class/struct + 宏元信息
+| 语言 | 实现形式 |
+| ---------- | --------------------------------- |
+| Java | 带 getter/setter 的 POJO |
+| Python | `@dataclass` 类 |
+| Go | 导出字段的 struct |
+| Rust | `#[derive(ForyObject)]` 的 struct |
+| C++ | 带 `FORY_STRUCT` 宏的 struct |
+| JavaScript | `export interface` 声明 |
+| Dart | `@ForyStruct` `final class` |
### 预留字段
@@ -397,13 +418,15 @@ message Person {
### 各语言生成形态
-| 语言 | 嵌套类型形态 |
-| ------ | --------------------- |
-| Java | `Outer.Inner` |
-| Python | `Outer.Inner` |
-| Rust | `outer::Inner` |
-| C++ | `Outer::Inner` |
-| Go | `Outer_Inner`(默认) |
+| 语言 | 嵌套类型形态 |
+| ---------- | ----------------------------------------------- |
+| Java | `Outer.Inner` |
+| Python | `Outer.Inner` |
+| Rust | `outer::Inner` |
+| C++ | `Outer::Inner` |
+| Go | `Outer_Inner`(默认,可配置为 camelcase) |
+| JavaScript | 扁平名称(如 `Result`) |
+| Dart | 带下划线的扁平类名(如 `SearchResponse_Result`) |
### 嵌套规则
@@ -466,6 +489,18 @@ message User {
建议在跨语言场景显式使用,以避免默认值差异。
+**生成代码:**
+
+| 语言 | 非 optional | optional |
+| ---------- | ------------------- | ----------------------------------------------- |
+| Java | `String name` | `String email` 配合 `@ForyField(nullable=true)` |
+| Python | `name: str` | `name: Optional[str]` |
+| Go | `Name string` | `Name *string` |
+| Rust | `name: String` | `name: Option<String>` |
+| C++ | `std::string name` | `std::optional<std::string> name` |
+| JavaScript | `name: string` | `name?: string \| null` |
+| Dart | `String name` | `String? email` |
+
#### `ref`
开启引用跟踪,用于共享对象与循环结构:
@@ -480,6 +515,18 @@ message Node {
当运行时全局 ref tracking 开启时,字段级 `ref` 才会生效。
+**生成代码:**
+
+| 语言 | 不使用 `ref` | 使用 `ref` |
+| ---------- | ---------------- | ------------------------------------------ |
+| Java | `Node parent` | `Node parent` 配合 `@ForyField(ref=true)` |
+| Python | `parent: Node` | `parent: Node = pyfory.field(ref=True)` |
+| Go | `Parent Node` | `Parent *Node` 配合 `fory:"ref"` |
+| Rust | `parent: Node` | `parent: Arc<Node>` |
+| C++ | `Node parent` | `std::shared_ptr<Node> parent` |
+| JavaScript | `parent: Node` | `parent: Node`(无额外 `ref` 区分) |
+| Dart | `Node parent` | `Node parent` 配合 `@ForyField(ref: true)` |
+
#### `list`
列表字段(`repeated` 为等价别名):
@@ -490,6 +537,18 @@ message Group {
}
```
+**生成代码:**
+
+| 语言 | 类型 |
+| ---------- | -------------------------- |
+| Java | `List<String>` |
+| Python | `List[str]` |
+| Go | `[]string` |
+| Rust | `Vec<String>` |
+| C++ | `std::vector<std::string>` |
+| JavaScript | `string[]` |
+| Dart | `List<String>` |
+
### 组合修饰符
可组合使用:
@@ -530,10 +589,38 @@ Fory IDL 类型系统包括基础类型、命名类型和集合类型。
`bool` 表示布尔值。
+| 语言 | 类型 | 说明 |
+| ---------- | --------- | ---- |
+| Java | `boolean` | |
+| Python | `bool` | |
+| Go | `bool` | |
+| Rust | `bool` | |
+| C++ | `bool` | |
+| JavaScript | `boolean` | |
+| Dart | `bool` | |
+
#### Integer Types
支持有符号/无符号与不同位宽。跨语言场景建议明确编码策略并保持字段语义稳定。
+**有符号整数映射:**
+
+| Fory IDL | Java | Python | Go | Rust | C++ | JavaScript | Dart |
+| -------- | ------- | -------------- | ------- | ----- | --------- | ------------------ | ------- |
+| `int8` | `byte` | `pyfory.int8` | `int8` | `i8` | `int8_t` | `number` | `Int8` |
+| `int16` | `short` | `pyfory.int16` | `int16` | `i16` | `int16_t` | `number` | `Int16` |
+| `int32` | `int` | `pyfory.int32` | `int32` | `i32` | `int32_t` | `number` | `Int32` |
+| `int64` | `long` | `pyfory.int64` | `int64` | `i64` | `int64_t` | `bigint \| number` | `int` |
+
+**无符号整数映射:**
+
+| Fory IDL | Java | Python | Go | Rust | C++ | JavaScript | Dart |
+| -------- | ------- | --------------- | -------- | ----- | ---------- | ------------------ | -------- |
+| `uint8` | `short` | `pyfory.uint8` | `uint8` | `u8` | `uint8_t` | `number` | `UInt8` |
+| `uint16` | `int` | `pyfory.uint16` | `uint16` | `u16` | `uint16_t` | `number` | `UInt16` |
+| `uint32` | `long` | `pyfory.uint32` | `uint32` | `u32` | `uint32_t` | `number` | `UInt32` |
+| `uint64` | `long` | `pyfory.uint64` | `uint64` | `u64` | `uint64_t` | `bigint \| number` | `int` |
+
#### Integer Encoding Variants
常见编码:
@@ -547,28 +634,83 @@ Fory IDL 类型系统包括基础类型、命名类型和集合类型。
- `float32`
- `float64`
+| Fory IDL | Java | Python | Go | Rust | C++ | JavaScript | Dart |
+| --------- | -------- | ---------------- | --------- | ----- | -------- | ---------- | --------- |
+| `float32` | `float` | `pyfory.float32` | `float32` | `f32` | `float` | `number` | `Float32` |
+| `float64` | `double` | `pyfory.float64` | `float64` | `f64` | `double` | `number` | `double` |
+
#### String Type
`string` 使用 UTF-8 文本语义。
+| 语言 | 类型 | 说明 |
+| ---------- | ------------- | -------------------- |
+| Java | `String` | 不可变 |
+| Python | `str` | |
+| Go | `string` | 不可变 |
+| Rust | `String` | 所有权字符串,堆分配 |
+| C++ | `std::string` | |
+| JavaScript | `string` | |
+| Dart | `String` | |
+
#### Bytes Type
`bytes` 用于原始二进制载荷。
+| 语言 | 类型 | 说明 |
+| ---------- | ---------------------- | ------ |
+| Java | `byte[]` | |
+| Python | `bytes` | 不可变 |
+| Go | `[]byte` | |
+| Rust | `Vec<u8>` | |
+| C++ | `std::vector<uint8_t>` | |
+| JavaScript | `Uint8Array` | |
+| Dart | `Uint8List` | |
+
#### Temporal Types
##### Date
`date` 表示日期(不含时区时间部分)。
+| 语言 | 类型 | 说明 |
+| ---------- | --------------------------- | ----------------------- |
+| Java | `java.time.LocalDate` | |
+| Python | `datetime.date` | |
+| Go | `time.Time` | 会忽略时间部分 |
+| Rust | `chrono::NaiveDate` | 需依赖 `chrono` crate |
+| C++ | `fory::serialization::Date` | |
+| JavaScript | `Date` | |
+| Dart | `LocalDate` | Fory package 提供的类型 |
+
##### Timestamp
`timestamp` 表示时间点(跨语言应统一时间语义与精度预期)。
+| 语言 | 类型 | 说明 |
+| ---------- | -------------------------------- | ----------------------- |
+| Java | `java.time.Instant` | 基于 UTC |
+| Python | `datetime.datetime` | |
+| Go | `time.Time` | |
+| Rust | `chrono::NaiveDateTime` | 需依赖 `chrono` crate |
+| C++ | `fory::serialization::Timestamp` | |
+| JavaScript | `Date` | |
+| Dart | `Timestamp` | Fory package 提供的类型 |
+
#### Any
`any` 允许存储动态类型值。使用 `any` 时建议配合清晰的业务约束,避免滥用导致模型不稳定。
+| 语言 | 类型 | 说明 |
+| ---------- | -------------- | -------------- |
+| Java | `Object` | 写入运行时类型 |
+| Python | `Any` | 写入运行时类型 |
+| Go | `any` | 写入运行时类型 |
+| Rust | `Box<dyn Any>` | 写入运行时类型 |
+| C++ | `std::any` | 写入运行时类型 |
+| JavaScript | `any` | 写入运行时类型 |
+| Dart | `Object?` | 写入运行时类型 |
+
### Named Types
命名类型包括:
@@ -600,6 +742,11 @@ map<K, V>
- `K` 一般应为可稳定比较的标量类型
- `V` 可为任意支持类型
+| Fory IDL | Java | Python | Go | Rust | C++ | JavaScript | Dart |
+| -------------------- | ---------------------- | ----------------- | ------------------ | ----------------------- | -------------------------------- | --------------------- | -------------------- |
+| `map<string, int32>` | `Map<String, Integer>` | `Dict[str, int]` | `map[string]int32` | `HashMap<String, i32>` | `std::map<std::string, int32_t>` | `Map<string, number>` | `Map<String, Int32>` |
+| `map<string, User>` | `Map<String, User>` | `Dict[str, User]` | `map[string]User` | `HashMap<String, User>` | `std::map<std::string, User>` | `Map<string, User>` | `Map<String, User>` |
+
### Type Compatibility Matrix
跨语言建议:
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/_category_.json b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/_category_.json
index c543ab138..9660bafa8 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/_category_.json
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/_category_.json
@@ -1,6 +1,6 @@
{
"label": "C++",
- "position": 3,
+ "position": 4,
"collapsible": true,
"collapsed": true
}
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/index.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/index.md
index cc2102a5e..12049c1a8 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/index.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/index.md
@@ -19,19 +19,19 @@ license: |
limitations under the License.
---
-**Apache Fory™** 是一个极速的多语言序列化框架,基于 **JIT 编译**和**零拷贝**技术,在保持易用性和安全性的同时提供**超高性能**。
+**Apache Fory™** 是一个高性能的多语言序列化框架,基于 **JIT 编译**与**零拷贝**技术,在保持易用性和安全性的同时提供出色性能。
-C++ 实现利用现代 C++17 特性和模板元编程,提供具有编译时类型安全的高性能序列化。
+C++ 实现基于现代 C++17 特性和模板元编程,提供具备编译时类型安全的高性能序列化能力。
## 为什么选择 Apache Fory™ C++?
-- **🔥 极速性能**:快速序列化和优化的二进制协议
-- **🌍 跨语言**:在 Java、Python、C++、Go、JavaScript 和 Rust 之间无缝序列化/反序列化数据
-- **🎯 类型安全**:基于宏的结构体注册实现编译时类型检查
-- **🔄 引用跟踪**:自动跟踪共享引用和循环引用
-- **📦 Schema 演化**:兼容模式支持独立的 schema 变更
-- **⚡ 双格式支持**:对象图序列化和零拷贝行格式
-- **🧵 线程安全**:同时提供单线程(最快)和线程安全两种变体
+- **高性能**:快速序列化与优化的二进制协议
+- **跨语言**:可在 Java、Python、C++、Go、JavaScript 和 Rust 之间无缝序列化与反序列化数据
+- **类型安全**:通过基于宏的结构体注册实现编译时类型检查
+- **引用跟踪**:自动跟踪共享引用和循环引用
+- **Schema 演进**:兼容模式支持独立的 Schema 变更
+- **双格式支持**:对象图序列化与零拷贝行格式
+- **线程安全**:同时提供单线程(最快)和线程安全两种变体
## 安装
@@ -40,11 +40,11 @@ C++ 实现同时支持 CMake 和 Bazel 构建系统。
### 前置条件
- CMake 3.16+(用于 CMake 构建)或 Bazel 8+(用于 Bazel 构建)
-- C++17 兼容的编译器(GCC 7+、Clang 5+、MSVC 2017+)
+- 支持 C++17 的编译器(GCC 7+、Clang 5+、MSVC 2017+)
### 使用 CMake(推荐)
-使用 CMake 的 `FetchContent` 模块是最简单的方式:
+最简单的集成方式是使用 CMake 的 `FetchContent` 模块:
```cmake
cmake_minimum_required(VERSION 3.16)
@@ -52,12 +52,14 @@ project(my_project LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
+if(MSVC)
+ add_compile_options(/Zc:preprocessor)
+endif()
include(FetchContent)
FetchContent_Declare(
fory
GIT_REPOSITORY https://github.com/apache/fory.git
- GIT_TAG v0.14.1
+ GIT_TAG v0.17.0
SOURCE_SUBDIR cpp
)
FetchContent_MakeAvailable(fory)
@@ -87,11 +89,11 @@ module(
bazel_dep(name = "rules_cc", version = "0.1.1")
-bazel_dep(name = "fory", version = "0.14.1")
+bazel_dep(name = "fory", version = "0.17.0")
git_override(
module_name = "fory",
remote = "https://github.com/apache/fory.git",
- commit = "v0.14.1", # 或使用特定的 commit hash 以确保可重现性
+ commit = "v0.17.0", # 或使用特定 commit hash 以确保可复现性
)
```
@@ -112,10 +114,10 @@ bazel build //:my_app
bazel run //:my_app
```
-对于本地开发,可以使用 `local_path_override`:
+对于本地开发,也可以改用 `local_path_override`:
```bazel
-bazel_dep(name = "fory", version = "0.14.1")
+bazel_dep(name = "fory", version = "0.17.0")
local_path_override(
module_name = "fory",
path = "/path/to/fory",
@@ -124,7 +126,7 @@ local_path_override(
### 示例
-请参阅 [examples/cpp](https://github.com/apache/fory/tree/main/examples/cpp) 目录获取完整的工作示例:
+完整可运行示例请参见 [examples/cpp](https://github.com/apache/fory/tree/main/examples/cpp) 目录:
- [hello_world](https://github.com/apache/fory/tree/main/examples/cpp/hello_world) - 对象图序列化
- [hello_row](https://github.com/apache/fory/tree/main/examples/cpp/hello_row) - 行格式编码
@@ -135,6 +137,8 @@ local_path_override(
```cpp
#include "fory/serialization/fory.h"
+#include <string>
+#include <vector>
using namespace fory::serialization;
@@ -148,8 +152,6 @@ struct Person {
return name == other.name && age == other.age && hobbies == other.hobbies;
}
};
-
-// 使用 Fory 注册结构体(必须在同一命名空间中)
FORY_STRUCT(Person, name, age, hobbies);
int main() {
@@ -159,7 +161,7 @@ int main() {
.track_ref(false) // 对简单类型禁用引用跟踪
.build();
- // 使用唯一 ID 注册类型
+ // 为类型注册唯一 ID
fory.register_struct<Person>(1);
// 创建对象
@@ -186,14 +188,30 @@ int main() {
}
```
+### 继承字段
+
+如果希望派生类型包含基类字段,请在 `FORY_STRUCT` 中写入 `FORY_BASE(Base)`。基类本身也必须定义自己的 `FORY_STRUCT`,这样其字段才能被引用。
+
+```cpp
+struct Base {
+ int32_t id;
+ FORY_STRUCT(Base, id);
+};
+
+struct Derived : Base {
+ std::string name;
+ FORY_STRUCT(Derived, FORY_BASE(Base), name);
+};
+```
+
## 线程安全
-Apache Fory™ C++ 为不同的线程需求提供两种变体:
+Apache Fory™ C++ 面向不同线程需求提供两种变体:
### 单线程(最快)
```cpp
-// 单线程 Fory - 最快,但非线程安全
+// 单线程 Fory:速度最快,但不是线程安全的
auto fory = Fory::builder()
.xlang(true)
.build();
@@ -202,12 +220,12 @@ auto fory = Fory::builder()
### 线程安全
```cpp
-// 线程安全 Fory - 使用上下文池
+// 线程安全 Fory:使用上下文池
auto fory = Fory::builder()
.xlang(true)
.build_thread_safe();
-// 可以从多个线程安全使用
+// 可安全用于多线程
std::thread t1([&]() {
auto result = fory.serialize(obj1);
});
@@ -216,30 +234,31 @@ std::thread t2([&]() {
});
```
-**提示:** 在生成线程之前完成类型注册,以确保每个工作线程看到相同的元数据。
+**提示:** 请在启动线程之前完成类型注册,以确保每个工作线程都能看到一致的元数据。
## 使用场景
### 对象序列化
-- 包含嵌套对象和引用的复杂数据结构
+- 含嵌套对象和引用的复杂数据结构
- 微服务中的跨语言通信
-- 具有完整类型安全的通用序列化
-- 使用兼容模式的 schema 演化
+- 具备完整类型安全的通用序列化
+- 使用兼容模式进行 Schema 演进
### 行格式序列化
-- 高吞吐量数据处理
-- 需要快速字段访问的分析工作负载
+- 高吞吐数据处理
+- 需要快速字段访问的分析型负载
- 内存受限环境
- 零拷贝场景
## 后续步骤
-- [配置](configuration.md) - 构建器选项和模式
+- [配置](configuration.md) - 构建器选项与模式
- [基础序列化](basic-serialization.md) - 对象图序列化
-- [Schema 演化](schema-evolution.md) - 兼容模式和 schema 变更
+- [Schema 演进](schema-evolution.md) - 兼容模式与 Schema 变更
- [类型注册](type-registration.md) - 注册类型
-- [支持的类型](supported-types.md) - 所有支持的类型
+- [字段配置](field-configuration.md) - 字段级元数据(可空、引用跟踪)
+- [支持的类型](supported-types.md) - 全部支持的类型
- [跨语言](cross-language.md) - XLANG 模式
- [行格式](row-format.md) - 零拷贝行格式
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/scala/_category_.json b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/_category_.json
similarity index 76%
copy from i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/scala/_category_.json
copy to i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/_category_.json
index 6cc51ddde..c5e03ee3c 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/scala/_category_.json
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/_category_.json
@@ -1,5 +1,5 @@
{
- "label": "Scala",
+ "label": "C#",
"position": 7,
"collapsible": true,
"collapsed": true
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/basic-serialization.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/basic-serialization.md
new file mode 100644
index 000000000..ce8cd2e59
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/basic-serialization.md
@@ -0,0 +1,131 @@
+---
+title: 基础序列化
+sidebar_position: 1
+id: basic_serialization
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页介绍 Apache Fory™ C# 的强类型序列化 API。
+
+## 对象图序列化
+
+在类或结构体上使用 `[ForyObject]`,并在使用前完成注册。
+
+```csharp
+using Apache.Fory;
+
+[ForyObject]
+public sealed class Address
+{
+ public string Street { get; set; } = string.Empty;
+ public int Zip { get; set; }
+}
+
+[ForyObject]
+public sealed class Person
+{
+ public long Id { get; set; }
+ public string Name { get; set; } = string.Empty;
+ public string? Nickname { get; set; }
+ public List<int> Scores { get; set; } = [];
+ public List<Address> Addresses { get; set; } = [];
+}
+
+Fory fory = Fory.Builder().Build();
+fory.Register<Address>(100);
+fory.Register<Person>(101);
+
+Person person = new()
+{
+ Id = 42,
+ Name = "Alice",
+ Nickname = null,
+ Scores = [10, 20, 30],
+ Addresses = [new Address { Street = "Main", Zip = 94107 }],
+};
+
+byte[] payload = fory.Serialize(person);
+Person decoded = fory.Deserialize<Person>(payload);
+```
+
+## 强类型 API
+
+### 使用字节数组进行 Serialize / Deserialize
+
+```csharp
+byte[] payload = fory.Serialize(value);
+MyType decoded = fory.Deserialize<MyType>(payload);
+```
+
+### 从 `ReadOnlySpan<byte>` 反序列化
+
+```csharp
+ReadOnlySpan<byte> span = payload;
+MyType decoded = fory.Deserialize<MyType>(span);
+```
+
+### 以流式方式消费帧
+
+```csharp
+using System.Buffers;
+
+ReadOnlySequence<byte> sequence = GetFramedSequence();
+MyType first = fory.Deserialize<MyType>(ref sequence);
+MyType second = fory.Deserialize<MyType>(ref sequence);
+```
+
+## 通过泛型对象 API 处理动态载荷
+
+当编译期类型未知或载荷包含异构对象时,可以配合 `object?` 使用泛型 API。
+
+```csharp
+Dictionary<object, object?> value = new()
+{
+ ["k1"] = 7,
+ [2] = "v2",
+ [true] = null,
+};
+
+byte[] payload = fory.Serialize<object?>(value);
+object? decoded = fory.Deserialize<object?>(payload);
+```
+
+## Buffer Writer API
+
+直接序列化到 `IBufferWriter<byte>` 目标。
+
+```csharp
+using System.Buffers;
+
+ArrayBufferWriter<byte> writer = new();
+fory.Serialize(writer, value);
+
+ArrayBufferWriter<byte> dynamicWriter = new();
+fory.Serialize<object?>(dynamicWriter, value);
+```
+
+## 说明
+
+- 复用同一个 `Fory` 或 `ThreadSafeFory` 实例可以获得更好的性能。
+- 基础类型和集合类型不需要用户手动注册。
+- 用户自定义的 `[ForyObject]` 类型和自定义序列化器类型应显式注册。
+
+## 相关主题
+
+- [类型注册](type-registration.md)
+- [支持的类型](supported-types.md)
+- [引用](references.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/configuration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/configuration.md
new file mode 100644
index 000000000..9af3ce18e
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/configuration.md
@@ -0,0 +1,124 @@
+---
+title: 配置
+sidebar_position: 2
+id: configuration
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页介绍 Apache Fory™ C# 的 `ForyBuilder` 选项和默认配置值。
+`Config` 是由 `ForyBuilder` 创建的不可变运行时快照。
+
+## 构建运行时
+
+```csharp
+using Apache.Fory;
+
+Fory fory = Fory.Builder().Build();
+ThreadSafeFory threadSafe = Fory.Builder().BuildThreadSafe();
+```
+
+## 默认配置
+
+`Fory.Builder().Build()` 使用以下默认值:
+
+| 选项 | 默认值 | 说明 |
+| -------------------- | -------- | ---------------------------------- |
+| `TrackRef` | `false` | 默认关闭引用跟踪 |
+| `Compatible` | `false` | Schema 一致模式,不写入演进元数据 |
+| `CheckStructVersion` | `false` | 默认关闭结构体 schema hash 校验 |
+| `MaxDepth` | `20` | 动态对象图的最大嵌套深度 |
+
+## 构建器选项
+
+C# 始终使用与 xlang 兼容的帧头,因此 `ForyBuilder` 不提供单独的 `Xlang(...)` 开关。
+
+### `TrackRef(bool enabled = false)`
+
+为共享对象图和循环对象图启用引用跟踪。
+
+```csharp
+Fory fory = Fory.Builder()
+ .TrackRef(true)
+ .Build();
+```
+
+### `Compatible(bool enabled = false)`
+
+启用 Schema 演进模式。
+
+```csharp
+Fory fory = Fory.Builder()
+ .Compatible(true)
+ .Build();
+```
+
+### `CheckStructVersion(bool enabled = false)`
+
+为生成的结构体序列化器启用严格的 schema hash 校验。
+
+```csharp
+Fory fory = Fory.Builder()
+ .CheckStructVersion(true)
+ .Build();
+```
+
+### `MaxDepth(int value)`
+
+设置动态对象图允许的最大嵌套深度。
+
+```csharp
+Fory fory = Fory.Builder()
+ .MaxDepth(32)
+ .Build();
+```
+
+`value` 必须大于 `0`。
+
+## 常见配置
+
+### 追求速度的 Schema 一致服务
+
+```csharp
+Fory fory = Fory.Builder()
+ .TrackRef(false)
+ .Compatible(false)
+ .Build();
+```
+
+### 兼容的跨语言服务
+
+```csharp
+Fory fory = Fory.Builder()
+ .Compatible(true)
+ .TrackRef(true)
+ .Build();
+```
+
+### 线程安全的服务实例
+
+```csharp
+ThreadSafeFory fory = Fory.Builder()
+ .Compatible(true)
+ .TrackRef(true)
+ .BuildThreadSafe();
+```
+
+## 相关主题
+
+- [基础序列化](basic_serialization)
+- [Schema 演进](schema_evolution)
+- [线程安全](thread_safety)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/cross-language.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/cross-language.md
new file mode 100644
index 000000000..1993b7112
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/cross-language.md
@@ -0,0 +1,105 @@
+---
+title: 跨语言序列化
+sidebar_position: 8
+id: cross_language
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Apache Fory™ C# 支持与其他 Fory 运行时进行跨语言序列化。
+
+## 跨语言运行时
+
+C# 始终会读写 xlang 帧头。它没有单独的 `Xlang(...)` 构建器选项,因此互操作代码只需要配置兼容模式、引用跟踪等其余运行时行为。
+
+```csharp
+Fory fory = Fory.Builder()
+ .Compatible(true)
+ .Build();
+```
+
+## 使用稳定 ID 注册
+
+```csharp
+[ForyObject]
+public sealed class Person
+{
+ public string Name { get; set; } = string.Empty;
+ public int Age { get; set; }
+}
+
+Fory fory = Fory.Builder()
+ .Compatible(true)
+ .Build();
+
+fory.Register<Person>(100);
+```
+
+请在所有语言中保持相同的 ID 映射。
+
+## 按命名空间和类型名注册
+
+```csharp
+fory.Register<Person>("com.example", "Person");
+```
+
+## 跨语言示例
+
+### C#(序列化端)
+
+```csharp
+Person person = new() { Name = "Alice", Age = 30 };
+byte[] payload = fory.Serialize(person);
+```
+
+### Java(反序列化端)
+
+```java
+Fory fory = Fory.builder()
+ .withLanguage(Language.XLANG)
+ .withRefTracking(true)
+ .build();
+
+fory.register(Person.class, 100);
+Person value = (Person) fory.deserialize(payloadFromCSharp);
+```
+
+### Python(反序列化端)
+
+```python
+import pyfory
+
+fory = pyfory.Fory(xlang=True, ref=True)
+fory.register_type(Person, type_id=100)
+value = fory.deserialize(payload_from_csharp)
+```
+
+## 类型映射参考
+
+完整映射请参见 [xlang 指南](../xlang/)。
+
+## 最佳实践
+
+1. 保持 type ID 稳定并做好文档记录。
+2. 在滚动升级时启用 `Compatible(true)`。
+3. 在读写两端都注册所有用户类型。
+4. 用真实载荷做端到端回环验证。
+
+## 相关主题
+
+- [类型注册](type_registration)
+- [Schema 演进](schema_evolution)
+- [支持的类型](supported_types)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/custom-serializers.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/custom-serializers.md
new file mode 100644
index 000000000..888b84d38
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/custom-serializers.md
@@ -0,0 +1,84 @@
+---
+title: 自定义序列化器
+sidebar_position: 4
+id: custom_serializers
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+当某个类型不是通过 `[ForyObject]` 生成,或者需要专门的编码方式时,可以使用自定义序列化器。
+
+## 实现 `Serializer<T>`
+
+```csharp
+using Apache.Fory;
+
+public sealed class Point
+{
+ public int X { get; set; }
+ public int Y { get; set; }
+}
+
+public sealed class PointSerializer : Serializer<Point>
+{
+ public override Point DefaultValue => new();
+
+ public override void WriteData(WriteContext context, in Point value, bool hasGenerics)
+ {
+ context.Writer.WriteVarInt32(value.X);
+ context.Writer.WriteVarInt32(value.Y);
+ }
+
+ public override Point ReadData(ReadContext context)
+ {
+ return new Point
+ {
+ X = context.Reader.ReadVarInt32(),
+ Y = context.Reader.ReadVarInt32(),
+ };
+ }
+}
+```
+
+## 注册序列化器
+
+```csharp
+Fory fory = Fory.Builder().Build();
+fory.Register<Point, PointSerializer>(200);
+
+Point value = new() { X = 10, Y = 20 };
+byte[] payload = fory.Serialize(value);
+Point decoded = fory.Deserialize<Point>(payload);
+```
+
+## 序列化器行为说明
+
+- `WriteData` / `ReadData` 只负责处理载荷内容。
+- 除非显式重写,否则引用标志和类型信息由基类 `Serializer<T>.Write` / `Read` 处理。
+- `DefaultValue` 用于空值或默认值回退路径。
+
+## 最佳实践
+
+1. 保持序列化器逻辑确定且读写对称。
+2. 对整数密集型载荷要有意识地选择 varint、fixed 或 tagged 编码。
+3. 在所有读写端都注册自定义序列化器。
+4. 对常规领域模型优先使用 `[ForyObject]` 生成的序列化器。
+
+## 相关主题
+
+- [类型注册](type-registration.md)
+- [字段配置](field-configuration.md)
+- [故障排查](troubleshooting.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/field-configuration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/field-configuration.md
new file mode 100644
index 000000000..0b31b65b1
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/field-configuration.md
@@ -0,0 +1,75 @@
+---
+title: 字段配置
+sidebar_position: 5
+id: field_configuration
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页介绍 C# 生成序列化器的字段级配置。
+
+## `[ForyObject]` 与 `[Field]`
+
+使用 `[ForyObject]` 启用 source generator 生成序列化器。使用 `[Field]` 可以为某个字段覆盖整数编码方式。
+
+```csharp
+using Apache.Fory;
+
+[ForyObject]
+public sealed class Metrics
+{
+ // 定长 32 位编码
+ [Field(Encoding = FieldEncoding.Fixed)]
+ public uint Count { get; set; }
+
+ // Tagged 64 位编码
+ [Field(Encoding = FieldEncoding.Tagged)]
+ public ulong TraceId { get; set; }
+
+ // 默认(varint)编码
+ public long LatencyMicros { get; set; }
+}
+```
+
+## 可用编码
+
+| 编码 | 含义 |
+| ---- | ---- |
+| `FieldEncoding.Varint` | 变长整数编码,默认值 |
+| `FieldEncoding.Fixed` | 定长整数编码 |
+| `FieldEncoding.Tagged` | Tagged 整数编码,仅支持 `long` / `ulong` |
+
+## 支持覆盖编码的字段类型
+
+`[Field(Encoding = ...)]` 当前可应用于:
+
+- `int`
+- `uint`
+- `long`
+- `ulong`
+
+可空值类型变体,例如 `long?`,也会由生成的序列化器处理。
+
+## 可空性与引用跟踪
+
+- 字段可空性来自 C# 类型的可空声明,例如 `string?`、可空值类型等。
+- 引用跟踪由运行时的 `ForyBuilder.TrackRef(...)` 控制。
+
+## 相关主题
+
+- [配置](configuration.md)
+- [Schema 演进](schema-evolution.md)
+- [支持的类型](supported-types.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/index.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/index.md
new file mode 100644
index 000000000..cf694ae62
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/index.md
@@ -0,0 +1,104 @@
+---
+title: C# 序列化指南
+sidebar_position: 0
+id: serialization_index
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Apache Fory™ C# 是面向 .NET 的高性能跨语言序列化运行时。它提供对象图序列化、Schema 演进、泛型对象载荷支持,以及面向并发负载的线程安全封装。
+
+## 为什么选择 Fory C#?
+
+- 面向 .NET 8+ 的高性能二进制序列化
+- 与 Java、Python、C++、Go、Rust 和 JavaScript 中的 Fory 实现保持跨语言兼容
+- 基于 source generator 的 `[ForyObject]` 类型序列化器
+- 可选引用跟踪,支持共享对象图和循环对象图
+- 面向 Schema 演进的兼容模式
+- 面向多线程服务的线程安全运行时 `ThreadSafeFory`
+
+## 快速开始
+
+### 要求
+
+- .NET SDK 8.0+
+- C# 语言版本 12+
+
+### 从 NuGet 安装
+
+引用单个 `Apache.Fory` 包即可。它同时包含运行时和 `[ForyObject]` 类型所需的 source generator。
+
+```xml
+<ItemGroup>
+ <PackageReference Include="Apache.Fory" Version="0.17.0" />
+</ItemGroup>
+```
+
+### 基础示例
+
+```csharp
+using Apache.Fory;
+
+[ForyObject]
+public sealed class User
+{
+ public long Id { get; set; }
+ public string Name { get; set; } = string.Empty;
+ public string? Email { get; set; }
+}
+
+Fory fory = Fory.Builder().Build();
+fory.Register<User>(1);
+
+User user = new()
+{
+ Id = 1,
+ Name = "Alice",
+ Email = "alice@example.com",
+};
+
+byte[] payload = fory.Serialize(user);
+User decoded = fory.Deserialize<User>(payload);
+```
+
+## 核心 API
+
+- `Serialize<T>(in T value)` / `Deserialize<T>(...)`
+- `Serialize<object?>(...)` / `Deserialize<object?>(...)`,用于动态载荷
+- `Register<T>(uint typeId)` 以及基于命名空间和名称的注册 API
+- `Register<T, TSerializer>(...)`,用于自定义序列化器
+
+## 文档
+
+| 主题 | 说明 |
+| --------------------------------------------- | ---------------------------------- |
+| [配置](configuration.md) | 构建器选项与运行时模式 |
+| [基础序列化](basic-serialization.md) | 强类型和动态序列化 API |
+| [类型注册](type-registration.md) | 注册用户类型和自定义序列化器 |
+| [自定义序列化器](custom-serializers.md) | 实现 `Serializer<T>` |
+| [字段配置](field-configuration.md) | `[Field]` 特性与整数编码选项 |
+| [引用](references.md) | 共享引用与循环引用处理 |
+| [Schema 演进](schema-evolution.md) | 兼容模式行为 |
+| [跨语言](cross-language.md) | 互操作性指导 |
+| [支持的类型](supported-types.md) | 内置类型与生成类型支持 |
+| [线程安全](thread-safety.md) | `Fory` 与 `ThreadSafeFory` 的用法 |
+| [故障排查](troubleshooting.md) | 常见错误与调试步骤 |
+
+## 相关资源
+
+- [跨语言序列化规范](../../specification/xlang_serialization_spec.md)
+- [跨语言指南](../xlang/index.md)
+- [C# 源码目录](https://github.com/apache/fory/tree/main/csharp)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/references.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/references.md
new file mode 100644
index 000000000..bdbf56d28
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/references.md
@@ -0,0 +1,72 @@
+---
+title: 引用
+sidebar_position: 6
+id: references
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+当启用 `TrackRef(true)` 时,Apache Fory™ C# 可以保留共享引用和循环引用。
+
+## 启用引用跟踪
+
+```csharp
+Fory fory = Fory.Builder()
+ .TrackRef(true)
+ .Build();
+```
+
+启用后:
+
+- 共享对象身份会被保留。
+- 循环对象图可以安全地序列化和反序列化。
+
+## 循环引用示例
+
+```csharp
+using Apache.Fory;
+
+[ForyObject]
+public sealed class Node
+{
+ public int Value { get; set; }
+ public Node? Next { get; set; }
+}
+
+Fory fory = Fory.Builder()
+ .TrackRef(true)
+ .Build();
+fory.Register<Node>(200);
+
+Node node = new() { Value = 7 };
+node.Next = node;
+
+byte[] payload = fory.Serialize(node);
+Node decoded = fory.Deserialize<Node>(payload);
+
+// The cycle is preserved.
+System.Diagnostics.Debug.Assert(object.ReferenceEquals(decoded, decoded.Next));
+```
+
+## 何时使用 `TrackRef(false)`
+
+对于树状、无环且不关心引用身份的数据,`TrackRef(false)` 往往更快。
+
+## 相关主题
+
+- [配置](configuration.md)
+- [基础序列化](basic-serialization.md)
+- [线程安全](thread-safety.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/schema-evolution.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/schema-evolution.md
new file mode 100644
index 000000000..6531eb540
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/schema-evolution.md
@@ -0,0 +1,90 @@
+---
+title: Schema 演进
+sidebar_position: 7
+id: schema_evolution
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Apache Fory™ C# 在 `Compatible(true)` 模式下支持 Schema 演进。
+
+## 兼容模式
+
+```csharp
+Fory fory = Fory.Builder()
+ .Compatible(true)
+ .Build();
+```
+
+兼容模式会写入类型元信息,使结构体定义不同的读写端也能互操作。
+
+## 示例:新增一个字段
+
+```csharp
+using Apache.Fory;
+
+[ForyObject]
+public sealed class OneStringField
+{
+ public string? F1 { get; set; }
+}
+
+[ForyObject]
+public sealed class TwoStringField
+{
+ public string F1 { get; set; } = string.Empty;
+ public string F2 { get; set; } = string.Empty;
+}
+
+Fory fory1 = Fory.Builder().Compatible(true).Build();
+fory1.Register<OneStringField>(200);
+
+Fory fory2 = Fory.Builder().Compatible(true).Build();
+fory2.Register<TwoStringField>(200);
+
+byte[] payload = fory1.Serialize(new OneStringField { F1 = "hello" });
+TwoStringField evolved = fory2.Deserialize<TwoStringField>(payload);
+
+// F2 falls back to default value on reader side.
+System.Diagnostics.Debug.Assert(evolved.F1 == "hello");
+System.Diagnostics.Debug.Assert(evolved.F2 == string.Empty);
+```
+
+## 带版本校验的 Schema 一致模式
+
+如果你需要严格的 Schema 身份校验,而不是演进行为:
+
+```csharp
+Fory strict = Fory.Builder()
+ .Compatible(false)
+ .CheckStructVersion(true)
+ .Build();
+```
+
+这种模式会在 schema hash 不匹配时抛出异常。
+
+## 最佳实践
+
+1. 对独立部署的服务启用 `Compatible(true)`。
+2. 在不同版本之间保持稳定的 type ID。
+3. 新增字段时提供安全的默认值。
+4. 如果要求严格匹配,使用 `CheckStructVersion(true)`。
+
+## 相关主题
+
+- [配置](configuration.md)
+- [类型注册](type-registration.md)
+- [故障排查](troubleshooting.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/supported-types.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/supported-types.md
new file mode 100644
index 000000000..20baf0b41
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/supported-types.md
@@ -0,0 +1,97 @@
+---
+title: 支持的类型
+sidebar_position: 9
+id: supported_types
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页汇总 Apache Fory™ C# 的内置类型支持和生成类型支持。
+
+## 基础类型
+
+| C# 类型 | 说明 |
+| ------- | ---- |
+| `bool` | 支持 |
+| `sbyte`, `short`, `int`, `long` | 支持 |
+| `byte`, `ushort`, `uint`, `ulong` | 支持 |
+| `float`, `double` | 支持 |
+| `string` | 支持 |
+| `byte[]` | 支持 |
+| 可空基础类型,例如 `int?` | 支持 |
+
+## 数组
+
+- 基础数值数组,例如 `bool[]`、`int[]`、`ulong[]`
+- `byte[]`
+- 通过集合序列化器支持的一般数组 `T[]`
+
+## 集合
+
+### 类 List
+
+- `List<T>`
+- `LinkedList<T>`
+- `Queue<T>`
+- `Stack<T>`
+
+### 类 Set
+
+- `HashSet<T>`
+- `SortedSet<T>`
+- `ImmutableHashSet<T>`
+
+### 类 Map
+
+- `Dictionary<TKey, TValue>`
+- `SortedDictionary<TKey, TValue>`
+- `SortedList<TKey, TValue>`
+- `ConcurrentDictionary<TKey, TValue>`
+- `NullableKeyDictionary<TKey, TValue>`
+
+## 时间类型
+
+| C# 类型 | 编码类型 |
+| ------- | -------- |
+| `DateOnly` | `Date` |
+| `DateTime` | `Timestamp` |
+| `DateTimeOffset` | `Timestamp` |
+| `TimeSpan` | `Duration` |
+
+## 用户类型
+
+- 通过 source generator 生成序列化器的 `[ForyObject]` 类、结构体、枚举
+- 通过 `Register<T, TSerializer>(...)` 注册的自定义序列化器类型
+- `Union` / `Union2<...>` 强类型联合支持
+
+## 动态类型
+
+通过 `Serialize<object?>` / `Deserialize<object?>` 处理动态对象载荷时,支持:
+
+- 基础值和对象值
+- 动态列表、集合、映射
+- 嵌套的动态结构
+
+## 说明
+
+- 用户自定义类型应显式注册。
+- 跨语言使用时,请遵循 [xlang 指南](../xlang/index.md)。
+
+## 相关主题
+
+- [基础序列化](basic-serialization.md)
+- [类型注册](type-registration.md)
+- [跨语言](cross-language.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/thread-safety.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/thread-safety.md
new file mode 100644
index 000000000..5c2a33917
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/thread-safety.md
@@ -0,0 +1,73 @@
+---
+title: 线程安全
+sidebar_position: 10
+id: thread_safety
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Apache Fory™ C# 提供两种运行时形态,它们的线程保证不同。
+
+## `Fory`(单线程运行时)
+
+`Fory` 针对单线程复用做了优化,不能被多个线程并发使用。
+
+```csharp
+Fory fory = Fory.Builder().Build();
+```
+
+如果你显式管理线程亲和性,可以为每个线程分配一个 `Fory` 实例。
+
+## `ThreadSafeFory`(并发封装)
+
+`ThreadSafeFory` 为每个线程封装一个 `Fory` 实例,并对外提供线程安全 API。
+
+```csharp
+using Apache.Fory;
+
+using ThreadSafeFory fory = Fory.Builder()
+ .Compatible(true)
+ .TrackRef(true)
+ .BuildThreadSafe();
+
+fory.Register<MyType>(100);
+
+Parallel.For(0, 64, i =>
+{
+ byte[] payload = fory.Serialize(i);
+ int decoded = fory.Deserialize<int>(payload);
+});
+```
+
+## 注册行为
+
+- `ThreadSafeFory.Register(...)` 会集中保存注册信息。
+- 已存在的线程内运行时会被更新。
+- 新线程会自动收到此前所有注册信息。
+
+## 释放资源
+
+`ThreadSafeFory` 实现了 `IDisposable`,在不再使用时应及时释放。
+
+```csharp
+using ThreadSafeFory fory = Fory.Builder().BuildThreadSafe();
+```
+
+## 相关主题
+
+- [配置](configuration.md)
+- [类型注册](type-registration.md)
+- [引用](references.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/troubleshooting.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/troubleshooting.md
new file mode 100644
index 000000000..0a9212b3d
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/troubleshooting.md
@@ -0,0 +1,92 @@
+---
+title: 故障排查
+sidebar_position: 11
+id: troubleshooting
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页介绍常见的 C# 运行时问题及其解决方法。
+
+## `TypeNotRegisteredException`
+
+**现象**:`Type not registered: ...`
+
+**原因**:用户类型在没有注册的情况下被序列化或反序列化。
+
+**修复方式**:
+
+```csharp
+Fory fory = Fory.Builder().Build();
+fory.Register<MyType>(100);
+```
+
+请确保读写两端使用相同的 type-ID 或名称映射。
+
+## `InvalidDataException: xlang bitmap mismatch`
+
+**原因**:载荷不是 xlang Fory 帧,或者它来自不输出 C# 所要求 xlang 头的对端或运行时模式。
+
+**修复方式**:确保载荷由与 xlang 兼容的 Fory 运行时生成。C# 始终要求 xlang 头,并且不提供单独的 `Xlang(...)` 构建器选项。
+
+```csharp
+Fory writer = Fory.Builder().Compatible(true).Build();
+Fory reader = Fory.Builder().Compatible(true).Build();
+```
+
+## 严格模式下的 Schema 版本不匹配
+
+**现象**:反序列化生成的结构体类型时抛出 `InvalidDataException`。
+
+**原因**:`Compatible(false)` 配合 `CheckStructVersion(true)` 时会要求 schema hash 完全一致。
+
+**可选修复方式**:
+
+- 启用 `Compatible(true)` 以支持 Schema 演进。
+- 保持写端和读端的模型定义同步。
+
+## 循环引用失败
+
+**现象**:类似栈溢出的递归问题,或者对象图重建异常。
+
+**原因**:循环对象图在 `TrackRef(false)` 下运行。
+
+**修复方式**:
+
+```csharp
+Fory fory = Fory.Builder().TrackRef(true).Build();
+```
+
+## 并发问题
+
+**原因**:在多个线程之间共享同一个 `Fory` 实例。
+
+**修复方式**:改用 `BuildThreadSafe()`。
+
+## 验证命令
+
+从仓库根目录运行 C# 测试:
+
+```bash
+cd csharp
+dotnet test Fory.sln -c Release
+```
+
+## 相关主题
+
+- [配置](configuration)
+- [Schema 演进](schema_evolution)
+- [线程安全](thread_safety)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/type-registration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/type-registration.md
new file mode 100644
index 000000000..1afbf05c6
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/csharp/type-registration.md
@@ -0,0 +1,82 @@
+---
+title: 类型注册
+sidebar_position: 3
+id: type_registration
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页介绍如何在 Apache Fory™ C# 中注册用户类型。
+
+## 按数字 type ID 注册
+
+显式 ID 可以提供紧凑且稳定的跨服务映射。
+
+```csharp
+Fory fory = Fory.Builder().Build();
+fory.Register<User>(100);
+fory.Register<Order>(101);
+```
+
+## 按类型名注册
+
+如果你更倾向于使用符号化映射,可以按命名空间和类型名注册。
+
+```csharp
+Fory fory = Fory.Builder().Build();
+fory.Register<User>("com.example", "User");
+```
+
+也可以使用简写重载:
+
+```csharp
+fory.Register<User>("User");
+```
+
+## 注册自定义序列化器
+
+```csharp
+Fory fory = Fory.Builder().Build();
+fory.Register<MyType, MyTypeSerializer>(200);
+```
+
+同样支持基于命名空间的自定义序列化器注册:
+
+```csharp
+fory.Register<MyType, MyTypeSerializer>("com.example", "MyType");
+```
+
+## 线程安全注册
+
+`ThreadSafeFory` 提供相同的注册 API。注册信息会传播到各个线程内运行时。
+
+```csharp
+using ThreadSafeFory fory = Fory.Builder().BuildThreadSafe();
+fory.Register<User>(100);
+fory.Register<Order>(101);
+```
+
+## 注册规则
+
+- 在写端和读端都要注册用户定义类型。
+- 在服务和语言之间保持 ID 或名称映射一致。
+- 在高频序列化负载开始前完成注册,避免运行时缺失。
+
+## 相关主题
+
+- [基础序列化](basic-serialization.md)
+- [自定义序列化器](custom-serializers.md)
+- [跨语言](cross-language.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/xlang/_category_.json b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/_category_.json
similarity index 68%
copy from i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/xlang/_category_.json
copy to i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/_category_.json
index bd191529c..b2d06cfcd 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/xlang/_category_.json
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/_category_.json
@@ -1,5 +1,5 @@
{
- "label": "Cross Language",
+ "label": "Dart",
"position": 9,
"collapsible": true,
"collapsed": true
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/basic-serialization.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/basic-serialization.md
new file mode 100644
index 000000000..59aaed47a
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/basic-serialization.md
@@ -0,0 +1,144 @@
+---
+title: 基础序列化
+sidebar_position: 2
+id: dart_basic_serialization
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页介绍如何使用 Apache Fory™ Dart 对值进行序列化和反序列化。
+
+## 创建 `Fory` 实例
+
+创建一个实例并复用它。每次调用都新建 `Fory` 只会浪费资源。
+
+```dart
+import 'package:fory/fory.dart';
+
+final fory = Fory();
+```
+
+## 序列化和反序列化带注解的类型
+
+```dart
+import 'package:fory/fory.dart';
+
+part 'person.fory.dart';
+
+@ForyStruct()
+class Person {
+ Person();
+
+ String name = '';
+ Int32 age = Int32(0);
+}
+
+void main() {
+ final fory = Fory();
+ PersonFory.register(
+ fory,
+ Person,
+ namespace: 'example',
+ typeName: 'Person',
+ );
+
+ final person = Person()
+ ..name = 'Ada'
+ ..age = Int32(36);
+
+ final bytes = fory.serialize(person);
+ final roundTrip = fory.deserialize<Person>(bytes);
+ print(roundTrip.name);
+}
+```
+
+`deserialize<T>` 会返回并转换为 `T` 的解码结果。如果载荷描述的类型与 `T` 不一致,就会抛出异常。
+
+## Null 值
+
+支持直接序列化 `null`:
+
+```dart
+final fory = Fory();
+final bytes = fory.serialize(null);
+final value = fory.deserialize<Object?>(bytes);
+```
+
+## 序列化集合和动态载荷
+
+你可以直接序列化集合值:
+
+```dart
+final fory = Fory();
+final bytes = fory.serialize(<Object?>[
+ 'hello',
+ Int32(42),
+ true,
+]);
+final value = fory.deserialize<List<Object?>>(bytes);
+```
+
+对于异构集合,请反序列化为 `Object?`、`List<Object?>` 或 `Map<Object?, Object?>`。
+
+## 引用跟踪
+
+默认情况下,Fory 不会跟踪对象标识。如果同一个对象在列表中出现两次,它会被序列化两次。当数据包含共享引用或循环结构时,请启用引用跟踪。
+
+对于顶层集合:
+
+```dart
+final fory = Fory();
+final shared = String.fromCharCodes('shared'.codeUnits);
+final bytes = fory.serialize(<Object?>[shared, shared], trackRef: true);
+final roundTrip = fory.deserialize<List<Object?>>(bytes);
+print(identical(roundTrip[0], roundTrip[1])); // true
+```
+
+对于生成结构体中的字段,请改用该字段上的 `@ForyField(ref: true)`。
+
+## 复用缓冲区
+
+如果你想避免每次调用都分配新的 `Uint8List`,可以配合显式 `Buffer` 使用 `serializeTo` 和 `deserializeFrom`:
+
+```dart
+final fory = Fory();
+final buffer = Buffer();
+
+fory.serializeTo(Int32(42), buffer);
+final value = fory.deserializeFrom<Int32>(buffer);
+```
+
+这是性能优化手段。对大多数应用来说,默认的 `serialize` / `deserialize` 就足够了。
+
+## 在序列化前注册类型
+
+在序列化自定义类或枚举之前,必须先把它注册到 `Fory` 中。生成代码会让这件事变得很简单:
+
+```dart
+PersonFory.register(
+ fory,
+ Person,
+ id: 100,
+);
+```
+
+如果跳过注册,运行时会得到 `Type ... is not registered` 错误。参见 [类型注册](type-registration.md) 和 [代码生成](code-generation.md)。
+
+## 相关主题
+
+- [配置](configuration.md)
+- [类型注册](type-registration.md)
+- [字段配置](field-configuration.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/code-generation.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/code-generation.md
new file mode 100644
index 000000000..53b760eb5
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/code-generation.md
@@ -0,0 +1,113 @@
+---
+title: 代码生成
+sidebar_position: 3
+id: dart_code_generation
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Fory 会在构建阶段为你的 Dart 类生成高性能序列化代码。你只需要给模型加注解、运行 `build_runner`,剩下的由 Fory 处理。
+
+## 第一步:给模型加注解
+
+为每个需要序列化的类添加 `@ForyStruct()`。同时在文件顶部加入生成的 `part` 指令。
+
+```dart
+import 'package:fory/fory.dart';
+
+part 'models.fory.dart';
+
+@ForyStruct()
+class Address {
+ Address();
+
+ String city = '';
+ String street = '';
+}
+
+@ForyStruct()
+class User {
+ User();
+
+ String name = '';
+ Int32 age = Int32(0);
+ Address address = Address();
+}
+```
+
+定义在同一文件中的枚举会自动包含到生成的注册代码里。
+
+## 第二步:运行生成器
+
+在包含 `pubspec.yaml` 的目录下运行:
+
+```bash
+dart run build_runner build --delete-conflicting-outputs
+```
+
+这会在源文件旁边生成一个 `.fory.dart` 文件。每当你新增或重命名带注解的类型时,都需要重新运行这个命令。
+
+## 第三步:注册并使用
+
+生成器会创建一个以源文件命名的命名空间,并提供 `register` 函数。请在序列化前调用它:
+
+```dart
+final fory = Fory();
+ModelsFory.register(fory, Address, id: 1);
+ModelsFory.register(fory, User, id: 2);
+```
+
+也可以用稳定名称代替数字 ID,这在跨语言场景中更有用:
+
+```dart
+ModelsFory.register(
+ fory,
+ User,
+ namespace: 'example',
+ typeName: 'User',
+);
+```
+
+关于如何在 ID 和名称之间做选择,见 [类型注册](type-registration.md)。
+
+## Schema 演进:`evolving`
+
+`@ForyStruct()` 默认使用 `evolving: true`,这对大多数应用都是正确选择。
+
+- `evolving: true`:Fory 会保存足够的元信息,因此当你之后新增或删除字段时,旧代码与新代码仍然可以交换消息。只要你的应用或服务可能存在多个版本同时运行,就应该启用它。
+- `evolving: false`:不写入额外元信息,载荷会略小一些。只有在写端和读端总是一起升级时才安全。
+
+```dart
+// evolving: true 是默认值,可以省略
+@ForyStruct(evolving: true)
+class Event {
+ Event();
+
+ String name = '';
+}
+```
+
+使用 evolving 结构体时,也要在首次对外发送载荷之前通过 `@ForyField(id: ...)` 为字段分配稳定 ID,因为 Fory 会依赖这些 ID 在 Schema 变化后匹配字段。
+
+## 什么时候不要使用代码生成
+
+如果你无法给某个类型加注解,例如它来自一个你无法修改的第三方包,那就改用 [自定义序列化器](custom-serializers.md)。
+
+## 相关主题
+
+- [类型注册](type-registration.md)
+- [字段配置](field-configuration.md)
+- [Schema 演进](schema-evolution.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/configuration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/configuration.md
new file mode 100644
index 000000000..0f53ceb69
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/configuration.md
@@ -0,0 +1,121 @@
+---
+title: 配置
+sidebar_position: 1
+id: dart_configuration
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页介绍 `Fory` 构造函数的可选项。
+
+## 创建 `Fory` 实例
+
+直接把选项传给构造函数:
+
+```dart
+import 'package:fory/fory.dart';
+
+// 默认配置,适合大多数单服务场景
+final fory = Fory();
+
+// 需要 Schema 演进的跨语言服务
+final fory = Fory(
+ compatible: true,
+ maxDepth: 512,
+);
+```
+
+每个应用创建一个实例并复用即可。按请求新建 `Fory` 没有任何收益。
+
+## 选项
+
+### `compatible`
+
+当你的服务需要处理来自另一份模型版本代码的载荷时,请设置为 `true`。例如各服务独立发布,无法保证通信双方同时升级。
+
+```dart
+final fory = Fory(compatible: true);
+```
+
+当 `compatible: true` 时:
+
+- 一侧新增或删除字段不会破坏另一侧。
+- 各端仍然必须使用相同的 `namespace` + `typeName`,或者相同的数字 `id` 来标识类型。
+
+当 `compatible: false`(默认)时:
+
+- 双方必须拥有完全相同的 Schema。这样会略快一些,适合仅有 Dart 服务或始终一起升级的场景。
+
+### `checkStructVersion`
+
+仅在 `compatible: false` 时相关。当它为 `true` 时,Fory 会校验载荷中的 Schema 版本是否与接收端已知版本一致,从而在运行时尽早发现误用的 Schema。
+
+```dart
+final fory = Fory(
+ compatible: false,
+ checkStructVersion: true, // default
+);
+```
+
+当 `compatible: true` 时,这个选项不起作用。
+
+### `maxDepth`
+
+限制对象图的最大嵌套深度。如果你的数据确实有很深的树形结构,可以增大它;如果你想快速拒绝异常深的载荷,可以减小它。
+
+```dart
+final fory = Fory(maxDepth: 128);
+```
+
+### `maxCollectionSize`
+
+任意单个 list、set 或 map 字段可接受的最大元素数。用于防止畸形消息触发失控的内存分配。
+
+```dart
+final fory = Fory(maxCollectionSize: 100000);
+```
+
+### `maxBinarySize`
+
+任意单个二进制 blob 字段允许接受的最大字节数。
+
+```dart
+final fory = Fory(maxBinarySize: 8 * 1024 * 1024);
+```
+
+## 默认值
+
+| 选项 | 默认值 |
+| -------------------- | --------- |
+| `compatible` | `false` |
+| `checkStructVersion` | `true` |
+| `maxDepth` | 256 |
+| `maxCollectionSize` | 1 048 576 |
+| `maxBinarySize` | 64 MiB |
+
+## 跨语言说明
+
+当 Fory 用于不同语言实现的服务之间通信时:
+
+- 如果任意一端需要 Schema 演进,则**所有**端都应设置 `compatible: true`。
+- 每一端都要使用相同的数字 ID,或者相同的 `namespace + typeName` 组合。
+- 写端和读端的 `compatible` 设置必须一致,模式不匹配会直接失败。
+
+## 相关主题
+
+- [基础序列化](basic-serialization.md)
+- [Schema 演进](schema-evolution.md)
+- [跨语言](cross-language.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/cross-language.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/cross-language.md
new file mode 100644
index 000000000..08560d943
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/cross-language.md
@@ -0,0 +1,193 @@
+---
+title: 跨语言序列化
+sidebar_position: 9
+id: dart_cross_language
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Apache Fory™ Dart 生成的二进制格式与 Java、Go、C#、Python、Rust 和 Swift 的 Fory 运行时保持一致。你可以在 Dart 中写消息,在 Java 中读取,或者反过来,整个过程都不需要额外的转换层。
+
+## 设置
+
+像平常一样创建 `Fory` 实例即可。Dart 中不需要单独开启“跨语言模式”:
+
+```dart
+final fory = Fory(); // 或者在需要 Schema 演进时使用 Fory(compatible: true)
+```
+
+关键要求是:通信两端必须用同一身份注册同一个类型。
+
+## 注册身份
+
+最重要的规则是:**每一端都要使用相同的类型身份**。你有两种选择:
+
+### 数字 ID
+
+更适合小团队、强协同的场景:
+
+```dart
+// Dart
+ModelsFory.register(fory, Person, id: 100);
+```
+
+### Namespace + Type Name
+
+更适合多个团队分别定义类型的场景:
+
+```dart
+// Dart
+ModelsFory.register(
+ fory,
+ Person,
+ namespace: 'example',
+ typeName: 'Person',
+);
+```
+
+不要在不同运行时上对同一个类型混用这两种策略。
+
+## Dart 到 Java 示例
+
+### Dart
+
+```dart
+import 'package:fory/fory.dart';
+
+part 'person.fory.dart';
+
+@ForyStruct()
+class Person {
+ Person();
+
+ String name = '';
+ Int32 age = Int32(0);
+}
+
+final fory = Fory();
+PersonFory.register(fory, Person, id: 100);
+final bytes = fory.serialize(Person()
+ ..name = 'Alice'
+ ..age = Int32(30));
+```
+
+### Java
+
+```java
+Fory fory = Fory.builder()
+ .withLanguage(Language.XLANG)
+ .build();
+
+fory.register(Person.class, 100);
+Person value = (Person) fory.deserialize(bytesFromDart);
+```
+
+## Dart 到 C# 示例
+
+### Dart
+
+```dart
+final fory = Fory(compatible: true);
+PersonFory.register(fory, Person, id: 100);
+final bytes = fory.serialize(Person()
+ ..name = 'Alice'
+ ..age = Int32(30));
+```
+
+### CSharp
+
+```csharp
+[ForyObject]
+public sealed class Person
+{
+ public string Name { get; set; } = string.Empty;
+ public int Age { get; set; }
+}
+
+Fory fory = Fory.Builder()
+ .Compatible(true)
+ .Build();
+
+fory.Register<Person>(100);
+Person person = fory.Deserialize<Person>(payloadFromDart);
+```
+
+## Dart 到 Go 示例
+
+### Dart
+
+```dart
+final fory = Fory();
+PersonFory.register(fory, Person, id: 100);
+final bytes = fory.serialize(Person()
+ ..name = 'Alice'
+ ..age = Int32(30));
+```
+
+### Go
+
+```go
+type Person struct {
+ Name string
+ Age int32
+}
+
+f := fory.New(fory.WithXlang(true))
+_ = f.RegisterStruct(Person{}, 100)
+
+var person Person
+_ = f.Deserialize(bytesFromDart, &person)
+```
+
+## 字段匹配规则
+
+Fory 会按字段名或稳定字段 ID 匹配字段。为了获得稳健的跨语言互操作性:
+
+1. 各端对同一类型使用相同的类型身份,即相同的数字 ID 或相同的 `namespace + typeName`。
+2. 在首次对外发送载荷之前,为所有字段分配稳定的 `@ForyField(id: ...)`。
+3. 保持字段名一致,或者依赖字段 ID,因为 Dart 通常使用 `lowerCamelCase`,Go 为导出字段使用 `PascalCase`,C# 也常用 `PascalCase` 属性。
+4. 使用兼容的数字类型:当对端为 Java `int`、Go `int32` 或 C# `int` 时,在 Dart 中使用 `Int32`;Dart 的 `double` 对应 64 位浮点;32 位浮点请使用 `Float32`。
+5. 日期时间字段优先使用 `Timestamp` 和 `LocalDate`,不要直接用原始 `DateTime`。
+6. 发布前一定要在所有目标语言间完成真实 round trip 验证。
+
+## Dart 的类型映射说明
+
+由于 Dart `int` 本身并不承诺精确的跨语言编码宽度,所以一旦跨语言解释需要精确定义,就应优先使用包装类型或数字字段注解:
+
+- `Int32` 对应 xlang `int32`
+- `UInt32` 对应 xlang `uint32`
+- `Float16` 和 `Float32` 对应用于较小宽度的浮点数
+- `Timestamp` 和 `LocalDate` 用于显式的时间语义
+
+参见 [支持的类型](supported-types.md) 和 [xlang type mapping](../../specification/xlang_type_mapping.md)。
+
+## 验证
+
+在生产环境依赖跨语言契约之前,请让每一种支持的运行时都完成端到端验证。
+
+运行 Dart 端:
+
+```bash
+dart run build_runner build --delete-conflicting-outputs
+dart analyze
+dart test
+```
+
+## 相关主题
+
+- [类型注册](type-registration.md)
+- [Schema 演进](schema-evolution.md)
+- [跨语言指南](../xlang/index.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/custom-serializers.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/custom-serializers.md
new file mode 100644
index 000000000..43052efd7
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/custom-serializers.md
@@ -0,0 +1,139 @@
+---
+title: 自定义序列化器
+sidebar_position: 5
+id: dart_custom_serializers
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+自定义序列化器让你可以完全控制某个类型如何编码和解码。通常只有在以下情况才需要使用它:
+
+- 类型来自你无法修改的第三方包,无法添加 `@ForyStruct()`
+- 你需要完全自定义的二进制布局
+- 你要实现 union / discriminated type
+
+对于你自己的模型,`@ForyStruct()` 配合代码生成几乎总是更好的选择。
+
+## 实现 `Serializer<T>`
+
+继承 `Serializer<T>` 并实现 `write` 和 `read`。通过 `context.buffer` 直接读写原始字节:
+
+```dart
+import 'package:fory/fory.dart';
+
+final class Person {
+ Person(this.name, this.age);
+
+ final String name;
+ final int age;
+}
+
+final class PersonSerializer extends Serializer<Person> {
+ const PersonSerializer();
+
+ @override
+ void write(WriteContext context, Person value) {
+ final buffer = context.buffer;
+ buffer.writeUtf8(value.name);
+ buffer.writeInt64(value.age);
+ }
+
+ @override
+ Person read(ReadContext context) {
+ final buffer = context.buffer;
+ return Person(buffer.readUtf8(), buffer.readInt64());
+ }
+}
+```
+
+在使用前先注册这个序列化器:
+
+```dart
+final fory = Fory();
+fory.registerSerializer(
+ Person,
+ const PersonSerializer(),
+ namespace: 'example',
+ typeName: 'Person',
+);
+```
+
+## 写入嵌套对象
+
+如果自定义序列化器中的某个字段本身也是由 Fory 管理的类型,请使用 `context.writeRef` 和 `context.readRef`,而不是递归调用 `fory.serialize`。这样才能保持引用跟踪正确,也避免在嵌套载荷里再写入完整根帧。
+
+```dart
+@override
+void write(WriteContext context, Wrapper value) {
+ context.writeRef(value.child);
+}
+
+@override
+Wrapper read(ReadContext context) {
+ return Wrapper(context.readRef() as Child);
+}
+```
+
+如果你明确知道某个嵌套值永远不会在对象图中重复出现,也不需要保持引用标识,可以用 `writeNonRef`:
+
+```dart
+context.writeNonRef(value.child);
+```
+
+## Union
+
+对于带判别标签的 union,请继承 `UnionSerializer<T>` 而不是 `Serializer<T>`。先写入判别值,再写入当前激活的变体;读取时先解析判别值,再分派到正确分支。
+
+```dart
+final class ShapeSerializer extends UnionSerializer<Shape> {
+ const ShapeSerializer();
+
+ @override
+ void write(WriteContext context, Shape value) {
+ // write active variant
+ }
+
+ @override
+ Shape read(ReadContext context) {
+ // read discriminant, return correct variant
+ throw UnimplementedError();
+ }
+}
+```
+
+## 自定义序列化器中的循环引用
+
+如果你的序列化器会遇到循环对象图,那么在读取嵌套字段之前,必须先把对象绑定到引用跟踪器中:
+
+```dart
+final value = Node.empty();
+context.reference(value); // register the object first
+value.next = context.readRef() as Node?; // now nested reads can refer back to it
+return value;
+```
+
+跳过这一步会导致指向该对象的回溯引用解析成 `null`。
+
+## 提示
+
+- 在热点路径中,优先使用 `context.buffer` 直接读写字节。
+- 在所有端上,都用相同的身份注册该序列化器,即相同的 `id` 或相同的 `namespace + typeName`。
+
+## 相关主题
+
+- [类型注册](type-registration.md)
+- [跨语言](cross-language.md)
+- [故障排查](troubleshooting.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/field-configuration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/field-configuration.md
new file mode 100644
index 000000000..a5a414cd4
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/field-configuration.md
@@ -0,0 +1,127 @@
+---
+title: 字段配置
+sidebar_position: 6
+id: dart_field_configuration
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+在 `@ForyStruct()` 类中的字段上添加 `@ForyField(...)`,即可改变该字段的序列化方式。
+
+## 快速参考
+
+```dart
+@ForyField(
+ skip: false, // exclude the field from serialization
+ id: 10, // stable field ID for schema evolution
+ nullable: true, // override nullability detection
+ ref: true, // enable reference tracking for this field
+ dynamic: false, // control whether the runtime type is written
+)
+```
+
+## `skip`
+
+完全把该字段排除在序列化之外。适合缓存值、计算值或仅用于 UI 的值,这些值不应该进入持久化或传输消息。
+
+```dart
+@ForyField(skip: true)
+String cachedDisplayName = '';
+```
+
+## `id`
+
+为字段分配稳定身份,这样在 Schema 变化后,例如字段重命名或重排时,Fory 仍然可以通过 ID 匹配它。**如果你未来可能新增、删除或重命名字段,请现在就为所有字段分配 ID**,而且要在第一份载荷发出之前完成。
+
+```dart
+@ForyField(id: 1)
+String name = '';
+```
+
+一旦载荷已经在服务之间共享,就永远不要把某个 `id` 复用到另一个不同字段上。
+
+## `nullable`
+
+显式声明字段是可空还是非可空,从而覆盖 Fory 根据 Dart 类型做出的推断。当 Dart 类型是非可空,但你仍希望 Fory 在线路上接受 `null` 时,可以使用它,例如为了读取旧生产者生成、可能省略该字段的消息。
+
+```dart
+@ForyField(nullable: true)
+String nickname = '';
+```
+
+在跨语言场景下,也要确保可空性契约与对端运行时的预期一致。
+
+## `ref`
+
+为某个字段启用引用跟踪。当对象图中的多个对象可能引用同一个实例,或该字段类型本身可能形成循环时,请使用这个选项。没有 `ref: true` 时,如果同一个对象出现在两个字段里,Fory 会把它的值序列化两次。
+
+```dart
+@ForyField(ref: true)
+List<Object?> sharedNodes = <Object?>[];
+```
+
+注意:即使设置了 `ref: true`,像 `int`、`double`、`bool` 这样的标量类型也不会从引用跟踪中受益。
+
+## `dynamic`
+
+控制 Fory 是否把字段值的具体运行时类型写入载荷。
+
+- `null`(默认):Fory 根据声明类型自动决定。
+- `false`:始终使用字段的声明类型,载荷更紧凑,但反序列化端必须知道精确类型。
+- `true`:始终写入实际运行时类型;当字段声明为 `Object?` 或基类,但运行时可能持有多种具体类型时,这是必需的。
+
+```dart
+@ForyField(dynamic: true)
+Object? payload; // can hold any registered type at runtime
+```
+
+## 数字字段注解
+
+Dart `int` 在运行时是 64 位值。当你与 Java、Go 或 C# 交换消息时,对端可能期望更窄的整数类型。可以使用数字注解来固定精确的编码格式:
+
+```dart
+@ForyStruct()
+class Sample {
+ Sample();
+
+ @Int32Type(compress: false) // always writes 4 bytes
+ int fixedWidthInt = 0;
+
+ @Int64Type(encoding: LongEncoding.tagged) // variable-length encoding
+ int compactLong = 0;
+
+ @Uint32Type(compress: true) // variable-length unsigned
+ int smallUnsigned = 0;
+}
+```
+
+可用注解包括:`@Int32Type`、`@Int64Type`、`@Uint8Type`、`@Uint16Type`、`@Uint32Type`、`@Uint64Type`。
+
+或者,也可以使用 [支持的类型](supported-types.md) 中介绍的显式包装类型,例如 `Int32`、`UInt32` 等。
+
+## 跨语言字段对齐
+
+当同一个模型在多种语言中分别定义时:
+
+- 为所有未来可能变化的字段分配稳定 `id`。
+- 对真正具备多态性的字段使用 `dynamic: true`。
+- 保持字段的逻辑含义在各语言之间一致。Fory 可以按名称或 ID 匹配字段,但无法替你弥合语义上的差异。
+
+## 相关主题
+
+- [代码生成](code-generation.md)
+- [Schema 演进](schema-evolution.md)
+- [跨语言](cross-language.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/index.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/index.md
new file mode 100644
index 000000000..fab52fbba
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/index.md
@@ -0,0 +1,141 @@
+---
+title: Dart 序列化指南
+sidebar_position: 0
+id: dart_serialization_index
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Apache Fory™ Dart 可以把 Dart 对象序列化为字节,再从字节反序列化回来,并且支持与 Java、Go、C#、Python 以及其他 Fory 支持语言编写的服务进行互通。
+
+## 为什么选择 Fory Dart?
+
+- **跨语言**:在 Dart 中序列化,在 Java、Go、C# 等语言中反序列化,无需额外胶水代码
+- **高性能**:生成的序列化代码会替代运行时反射
+- **Schema 演进**:可以新增或删除字段,而不破坏已有消息
+- **循环引用**:可选的引用跟踪可处理共享或递归对象图
+- **逃生口**:对任何无法加注解的类型,你都可以手写序列化器
+
+## 快速开始
+
+### 要求
+
+- Dart SDK 3.6 或更高版本
+- `build_runner`,用于生成序列化代码
+
+### 安装
+
+把依赖加入你的 `pubspec.yaml`:
+
+```yaml
+dependencies:
+ fory: ^0.17.0
+
+dev_dependencies:
+ build_runner: ^2.4.0
+```
+
+### 基础示例
+
+定义模型,先运行一次生成器,然后进行序列化:
+
+```dart
+import 'package:fory/fory.dart';
+
+part 'person.fory.dart';
+
+enum Color {
+ red,
+ blue,
+}
+
+@ForyStruct()
+class Person {
+ Person();
+
+ String name = '';
+ Int32 age = Int32(0);
+ Color favoriteColor = Color.red;
+ List<String> tags = <String>[];
+}
+
+void main() {
+ final fory = Fory();
+ PersonFory.register(
+ fory,
+ Color,
+ namespace: 'example',
+ typeName: 'Color',
+ );
+ PersonFory.register(
+ fory,
+ Person,
+ namespace: 'example',
+ typeName: 'Person',
+ );
+
+ final person = Person()
+ ..name = 'Ada'
+ ..age = Int32(36)
+ ..favoriteColor = Color.blue
+ ..tags = <String>['engineer', 'mathematician'];
+
+ final bytes = fory.serialize(person);
+ final roundTrip = fory.deserialize<Person>(bytes);
+ print(roundTrip.name);
+}
+```
+
+在运行程序之前,先生成配套文件:
+
+```bash
+dart run build_runner build --delete-conflicting-outputs
+```
+
+`PersonFory` 由 `build_runner` 生成。`namespace` 和 `typeName` 是其他语言中的对端识别同一类型的方式,一旦服务进入生产环境,就应保持稳定。
+
+## API 概览
+
+- `Fory(...)`:创建序列化实例;创建一次并复用
+- `fory.serialize(value)`:返回 `Uint8List` 字节
+- `fory.deserialize<T>(bytes)`:返回一个 `T`
+- `@ForyStruct()`:标记需要生成代码的类
+- `@ForyField(...)`:字段级选项,例如跳过、ID、可空性、引用
+- 整数包装类型:`Int8`、`Int16`、`Int32`、`UInt8`、`UInt16`、`UInt32`
+- 浮点包装类型:`Float16`、`Float32`
+- 时间包装类型:`LocalDate`、`Timestamp`
+
+## 文档
+
+| 主题 | 说明 |
+| --------------------------------------------- | ------------------------------------ |
+| [配置](configuration.md) | 运行时选项、兼容模式和安全限制 |
+| [基础序列化](basic-serialization.md) | `serialize`、`deserialize`、生成注册、根对象图 |
+| [代码生成](code-generation.md) | `@ForyStruct`、build runner 和生成命名空间 |
+| [类型注册](type-registration.md) | 基于 ID 与基于名称的注册,以及注册规则 |
+| [自定义序列化器](custom-serializers.md) | 手写 `Serializer<T>` 实现与 union |
+| [字段配置](field-configuration.md) | `@ForyField`、字段 ID、可空性、引用、多态 |
+| [支持的类型](supported-types.md) | 内置 xlang 值、包装类型、集合和结构体 |
+| [Schema 演进](schema-evolution.md) | 兼容结构体与可演进 Schema |
+| [跨语言](cross-language.md) | 互操作规则与字段对齐 |
+| [故障排查](troubleshooting.md) | 常见错误、诊断方法和验证步骤 |
+
+## 相关资源
+
+- [Xlang 序列化规范](../../specification/xlang_serialization_spec.md)
+- [Xlang 实现指南](../../specification/xlang_implementation_guide.md)
+- [跨语言指南](../xlang/index.md)
+- [Dart 运行时源码目录](https://github.com/apache/fory/tree/main/dart)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/schema-evolution.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/schema-evolution.md
new file mode 100644
index 000000000..267cd63f3
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/schema-evolution.md
@@ -0,0 +1,92 @@
+---
+title: Schema 演进
+sidebar_position: 8
+id: dart_schema_evolution
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Schema 演进让应用的不同版本之间也能安全交换消息。例如,v2 写出的消息仍然可以被 v1 读取,反过来也一样。
+
+## 两种模式
+
+### 兼容模式(推荐给会演进的服务)
+
+当服务可能同时运行不同版本时启用它,例如滚动发布期间,或者客户端无法立即升级时。
+
+```dart
+final fory = Fory(compatible: true);
+```
+
+在兼容模式下,Fory 会在每条消息中写入足够的字段元信息,使读端能够跳过未知字段,并为缺失字段使用默认值。请用稳定字段 ID 来锚定跨版本 Schema。
+
+### Schema 一致模式(默认)
+
+通信双方必须拥有同一个模型。Fory 会校验双方 Schema 是否一致,并拒绝来自其他 Schema 版本的消息。适用于所有服务总是一起升级,并且你希望尽早把 Schema 不匹配直接报错的场景。
+
+```dart
+final fory = Fory(); // compatible: false by default
+```
+
+## 为演进做好准备
+
+为了安全地使用兼容模式,请给结构体添加 `@ForyStruct(evolving: true)`(默认值),并在第一次对外发送载荷之前,为每个字段都分配稳定的 `@ForyField(id: ...)`:
+
+```dart
+@ForyStruct(evolving: true)
+class UserProfile {
+ UserProfile();
+
+ @ForyField(id: 1)
+ String name = '';
+
+ @ForyField(id: 2, nullable: true)
+ String? nickname;
+}
+```
+
+如果载荷已经在生产环境中存在之后你才补加字段 ID,那么旧消息里不会包含这些 ID,Schema 演进也就无法正确工作。
+
+## 哪些变更是安全的
+
+**安全变更**(双方兼容):
+
+- 新增一个带新字段 ID 的可选字段
+- 重命名字段,只要 `@ForyField(id: ...)` 保持不变
+- 删除字段,对端会忽略缺失值并使用 Dart 默认值
+
+**危险变更**(可能破坏已有消息):
+
+- 把一个已有字段 ID 复用给另一个不同字段
+- 将字段类型改为不兼容类型,例如 `Int32` 改成 `String`
+- 在消息进入生产环境后修改某个类型的注册身份,即 `id`、`namespace` 或 `typeName`
+- 不改字段 ID,却改变字段的逻辑含义
+
+## 跨语言说明
+
+只有在**所有**交换消息的运行时都一致满足以下条件时,Schema 演进才会生效:
+
+1. 使用相同的 `compatible` 设置。
+2. 使用相同的类型注册身份,即相同的数字 ID,或者相同的 `namespace + typeName`。
+3. 对字段 ID 的逻辑含义有相同理解。
+
+部署前请用真实 round trip 覆盖滚动升级场景。
+
+## 相关主题
+
+- [配置](configuration.md)
+- [字段配置](field-configuration.md)
+- [跨语言](cross-language.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/supported-types.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/supported-types.md
new file mode 100644
index 000000000..a6d996ce4
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/supported-types.md
@@ -0,0 +1,102 @@
+---
+title: 支持的类型
+sidebar_position: 7
+id: dart_supported_types
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页列出可在 Fory 消息中使用的 Dart 类型,并标出哪些地方在跨语言兼容性上需要特别小心。
+
+## 内置原始类型
+
+以下 Dart 类型可以直接序列化,不需要特殊处理:
+
+| Dart 类型 | 跨语言说明 |
+| -------------------- | ------------------------------------------------------------------------------------------------------------ |
+| `bool` | 直接映射 |
+| `int` | 默认按 64 位序列化。如果对端期望更窄的整数,请使用包装类型或 `@Int32Type` 等注解 |
+| `double` | 映射为 64 位浮点数。如果对端期望 32 位浮点,请使用 `Float32` 包装类型 |
+| `String` | 直接映射 |
+| `Uint8List` | 二进制 blob |
+| `List`, `Set`, `Map` | 支持,但元素类型也必须是受支持类型 |
+| `DateTime` | 如需明确语义,请使用 `Timestamp` 或 `LocalDate` 包装类型 |
+
+## 整数包装类型
+
+Dart `int` 在运行时是 64 位值。如果对端语言期望 32 位整数,例如 Java `int`、Go `int32`、C# `int`,而你发送的是 Dart `int`,反序列化可能失败,或者静默截断。
+
+使用整数包装类型可以固定精确的编码宽度:
+
+```dart
+final Int8 tiny = Int8(-1); // 8-bit signed
+final Int16 shortValue = Int16(7); // 16-bit signed
+final Int32 age = Int32(36); // 32-bit signed — matches Java int, C# int, Go int32
+final UInt8 flags = UInt8(255); // 8-bit unsigned
+final UInt16 port = UInt16(65535); // 16-bit unsigned
+final UInt32 count = UInt32(4000000000); // 32-bit unsigned
+```
+
+每个包装类型都会把存储值限制在目标位宽内。
+
+## 浮点包装类型
+
+Dart `double` 对应 64 位浮点。如果对端使用 32 位浮点,请改用包装类型:
+
+- `Float32`:32 位浮点,对应 Java `float`、C# `float`、Go `float32`
+- `Float16`:半精度浮点,适用于专门的数值载荷
+
+## 时间和日期类型
+
+不要直接把原始 `DateTime` 跨语言发送。时区处理和 epoch 差异在不同语言间并不完全一致。请改用下面这些显式包装类型:
+
+- `Timestamp`:带纳秒精度的 UTC 时间点,即秒数加纳秒数
+- `LocalDate`:不带时间和时区的日历日期
+
+```dart
+final now = Timestamp.fromDateTime(DateTime.now().toUtc());
+final birthday = LocalDate(1990, 12, 1);
+```
+
+## Struct 和 Enum
+
+给类添加 `@ForyStruct()`,然后运行 `build_runner`,它们就能序列化。定义在同一文件中的枚举会自动包含进去。
+
+```dart
+@ForyStruct()
+class User {
+ User();
+
+ String name = '';
+ Int32 age = Int32(0); // use Int32 when peers expect a 32-bit integer
+}
+```
+
+参见 [代码生成](code-generation.md)。
+
+## 集合
+
+Fory 支持 `List<T>`、`Set<T>` 和 `Map<K, V>`。元素类型和键类型本身也必须可序列化。请避免使用可变对象作为 map 键。
+
+## 兼容性提示
+
+一旦不确定某个 Dart 类型是否与对端预期一致,就优先使用显式包装类型。数字宽度选错,是跨语言场景里最常见的 bug 之一。
+
+## 相关主题
+
+- [字段配置](field-configuration.md)
+- [跨语言](cross-language.md)
+- [Schema 演进](schema-evolution.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/troubleshooting.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/troubleshooting.md
new file mode 100644
index 000000000..5be8b796a
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/troubleshooting.md
@@ -0,0 +1,103 @@
+---
+title: 故障排查
+sidebar_position: 10
+id: dart_troubleshooting
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页汇总 Dart 运行时中常见的问题及其修复方式。
+
+## `Only xlang payloads are supported by the Dart runtime.`
+
+写端发送的是 native-mode(非 xlang)载荷。请确保每个服务都走跨语言兼容路径:
+
+- **Java**:在 Fory builder 上添加 `.withLanguage(Language.XLANG)`。
+- **Go**:在 Fory 选项中使用 `WithXlang(true)`。
+- **其他运行时**:查看各自文档,确认如何启用跨语言模式。
+
+## `Type ... is not registered.`
+
+Fory 不知道如何序列化或反序列化这个类型。可按以下方式修复:
+
+1. 如果还没生成代码,先运行:`dart run build_runner build --delete-conflicting-outputs`
+2. 在调用 `serialize` 或 `deserialize` **之前**,先调用生成的 `register` 函数,或者 `registerSerializer`
+3. 注册消息中可能出现的**所有**类型,而不仅仅是根类型。例如,如果 `Order` 包含 `Address`,那两者都要注册
+
+## 生成的 part 文件缺失或已过期
+
+重新生成代码:
+
+```bash
+cd dart/packages/fory
+dart run build_runner build --delete-conflicting-outputs
+```
+
+如果你移动了文件或重命名了类型,请在重新执行分析或测试前先重新构建。
+
+## `Deserialized value has type ..., expected ...`
+
+载荷描述的类型与 `deserialize<T>` 中的 `T` 不一致。常见原因包括:
+
+- 写端注册该类型时使用的 ID 或名称,与读端不一致
+- 载荷来自另一条代码路径,根对象类型不同
+- 你正在反序列化异构容器。应先按 `Object?` 或 `List<Object?>` 解码,再做类型转换
+
+## 反序列化后对象不再是同一个实例
+
+默认情况下,Fory 不会跟踪对象标识,因此两个字段如果指向同一个对象,round trip 后会变成两个独立副本。
+
+如果需要保留对象标识:
+
+- 对 `@ForyStruct` 内部字段,在对应字段上加 `@ForyField(ref: true)`
+- 对顶层集合,调用 `fory.serialize(...)` 时传入 `trackRef: true`
+- 在自定义序列化器中,使用 `context.writeRef` / `context.readRef`,并在读取嵌套字段之前先调用 `context.reference(obj)`
+
+## 跨语言字段不匹配(数据缺失或值错误)
+
+典型症状:往返另一种语言后,字段变成默认值,或者类型错误。
+
+检查清单:
+
+1. 双方使用相同的注册身份,即相同数字 ID,**或**相同的 `namespace + typeName`
+2. 在第一份载荷发送前,就已经分配了稳定 `@ForyField(id: ...)`
+3. 数字宽度兼容。当对端字段是 Java `int`、Go `int32` 或 C# `int` 时,在 Dart 端使用 `Int32`
+4. 日期时间字段使用 `Timestamp` / `LocalDate`,而不是原始 `DateTime`
+5. 如果用到 Schema 演进,则**双方**都要开启 `compatible: true`
+
+## 本地运行测试
+
+主 Dart 包:
+
+```bash
+dart run build_runner build --delete-conflicting-outputs
+dart analyze
+dart test
+```
+
+集成测试包:
+
+```bash
+cd dart/packages/fory-test
+dart run build_runner build --delete-conflicting-outputs
+dart test
+```
+
+## 相关主题
+
+- [跨语言](cross-language.md)
+- [代码生成](code-generation.md)
+- [自定义序列化器](custom-serializers.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/type-registration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/type-registration.md
new file mode 100644
index 000000000..bd5f7e097
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/dart/type-registration.md
@@ -0,0 +1,98 @@
+---
+title: 类型注册
+sidebar_position: 4
+id: dart_type_registration
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Fory 需要知道序列化消息中的某个类型对应哪个类。你要做的,就是在序列化或反序列化之前注册每个类。
+
+## 选择注册策略
+
+Fory 提供两种策略。选定一种后,就要在所有读写该类型的语言里保持一致。
+
+### 策略一:数字 ID
+
+更紧凑,也更快。适合小团队在服务间统一协调 ID。
+
+```dart
+ModelsFory.register(fory, User, id: 100);
+```
+
+其他语言里也必须使用相同的数字:
+
+```java
+// Java side
+fory.register(User.class, 100);
+```
+
+### 策略二:Namespace + Type Name
+
+自描述性更强。适合多个团队或多个包独立定义类型,而协调数字 ID 不现实的场景。
+
+```dart
+ModelsFory.register(
+ fory,
+ User,
+ namespace: 'example',
+ typeName: 'User',
+);
+```
+
+每个读写该类型的运行时都必须使用相同的 `namespace` 和 `typeName`。
+
+> **不要对同一个类型混用策略。** 如果一侧使用数字 ID,另一侧使用名称,反序列化会失败。
+
+## 注册生成类型
+
+调用 `.fory.dart` 文件中生成的 `register` 函数,它会为你安装好所需的全部序列化元信息:
+
+```dart
+UserModelsFory.register(fory, User, id: 100);
+```
+
+## 注册自定义序列化器
+
+对于无法添加 `@ForyStruct()` 的类型,可以直接传入序列化器实例:
+
+```dart
+fory.registerSerializer(
+ ExternalType,
+ const ExternalTypeSerializer(),
+ namespace: 'example',
+ typeName: 'ExternalType',
+);
+```
+
+关于如何实现序列化器,见 [自定义序列化器](custom-serializers.md)。
+
+## 必须遵守的规则
+
+- 在第一次调用 `serialize` 或 `deserialize` **之前**完成注册
+- 注册消息中可能出现的**每一个**类,而不仅是根类型
+- 一旦载荷已经持久化,或已经在服务间交换,就必须保持 ID 或名称**稳定**
+- 对同一个类型,不要一侧用数字 ID,另一侧用名称
+
+## 跨语言要求
+
+所有读写该类型的运行时都必须使用相同的数字 ID,或者相同的 `namespace + typeName` 组合。示例见 [跨语言](cross-language.md)。
+
+## 相关主题
+
+- [代码生成](code-generation.md)
+- [跨语言](cross-language.md)
+- [自定义序列化器](custom-serializers.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/_category_.json b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/_category_.json
index 796c0a4dd..e4d176a76 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/_category_.json
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/_category_.json
@@ -1,6 +1,6 @@
{
"label": "Go",
- "position": 4,
+ "position": 5,
"collapsible": true,
"collapsed": true
}
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/codegen.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/codegen.md
index 67c338e52..e9e7a2748 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/codegen.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/codegen.md
@@ -20,36 +20,36 @@ license: |
---
:::warning Experimental Feature
-Code generation is an **experimental** feature in Fory Go. The API and behavior may change in future releases. The reflection-based path remains the stable, recommended approach for most use cases.
+代码生成是 Fory Go 中的**实验性**特性。其 API 和行为可能会在后续版本中发生变化。标准运行时路径仍是大多数场景下稳定且推荐的做法。
:::
-Fory Go 为性能关键路径提供可选的 AOT 代码生成,可消除反射开销并提升编译期类型安全。
+Fory Go 为性能关键路径提供可选的 AOT 代码生成。它会提前生成专用序列化器,并增加编译期 shape 校验。
## 为什么使用代码生成?
-| Aspect | Reflection-Based | Code Generation |
-| ----------- | ------------------ | ---------------------- |
-| Setup | Zero configuration | Requires `go generate` |
-| Performance | Good | Better (no reflection) |
-| Type Safety | Runtime | Compile-time |
-| Maintenance | Automatic | Requires regeneration |
+| 方面 | 标准路径 | 代码生成 |
+| -------- | ---------------- | ---------------------- |
+| 接入成本 | 零配置 | 需要 `go generate` |
+| 性能 | 已经很优秀 | 热路径上更快 |
+| 类型安全 | 运行时校验 | 编译期校验 |
+| 维护成本 | 自动完成 | 需要重新生成 |
-**Use code generation when**:
+**适合使用代码生成的场景:**
-- Maximum performance is required
-- Compile-time type safety is important
-- Hot paths are performance-critical
+- 需要极致性能
+- 很看重编译期类型安全
+- 热路径对性能非常敏感
-**Use reflection when**:
+**适合继续使用标准路径的场景:**
-- Simple setup is preferred
-- Types change frequently
-- Dynamic typing is needed
-- Code generation complexity is undesirable
+- 更偏好简单接入
+- 类型经常变化
+- 需要动态类型
+- 不希望引入代码生成复杂度
## 安装
-Install the `fory` generator binary:
+安装 `fory` 生成器二进制:
```bash
go install github.com/apache/fory/go/fory/cmd/fory@latest
@@ -57,13 +57,13 @@ go install github.com/apache/fory/go/fory/cmd/fory@latest
GO111MODULE=on go get -u github.com/apache/fory/go/fory/cmd/fory
```
-Ensure `$GOBIN` or `$GOPATH/bin` is in your `PATH`.
+确保 `$GOBIN` 或 `$GOPATH/bin` 已加入 `PATH`。
## 基本用法
-### Step 1: Annotate Structs
+### 步骤 1:标注结构体
-Add the `//fory:generate` comment above structs:
+在结构体上方添加 `//fory:generate` 注释:
```go
package models
@@ -82,35 +82,35 @@ type Order struct {
}
```
-### Step 2: Add Go Generate Directive
+### 步骤 2:添加 Go Generate 指令
-Add a `go:generate` directive (once per file or package):
+添加 `go:generate` 指令(每个文件或每个包一次即可):
```go
//go:generate fory -file models.go
```
-Or for the entire package:
+或者针对整个包:
```go
//go:generate fory -pkg .
```
-### Step 3: Run Code Generation
+### 步骤 3:执行代码生成
```bash
go generate ./...
```
-This creates `models_fory_gen.go` with generated serializers.
+这会生成包含序列化器代码的 `models_fory_gen.go` 文件。
-## 生成代码结构
+## 生成代码的结构
-The generator creates:
+生成器会输出以下内容:
-### Type Snapshot
+### 类型快照
-A compile-time check to detect struct changes:
+用于检测结构体变化的编译期检查:
```go
// Snapshot of User's underlying type at generation time
@@ -123,111 +123,121 @@ type _User_expected struct {
var _ = func(x User) { _ = _User_expected(x) }
```
-### Serializer Implementation
+### 序列化器实现
-Strongly-typed serialization methods:
+强类型的序列化方法:
```go
type User_ForyGenSerializer struct{}
-func (User_ForyGenSerializer) WriteTyped(f *fory.Fory, buf *fory.ByteBuffer, v *User) error {
+func NewSerializerFor_User() fory.Serializer {
+ return &User_ForyGenSerializer{}
+}
+
+func (User_ForyGenSerializer) WriteTyped(ctx *fory.WriteContext, v *User) error {
+ buf := ctx.Buffer()
buf.WriteInt64(v.ID)
- fory.WriteString(buf, v.Name)
+ ctx.WriteString(v.Name)
return nil
}
-func (User_ForyGenSerializer) ReadTyped(f *fory.Fory, buf *fory.ByteBuffer, v *User) error {
- v.ID = buf.ReadInt64()
- v.Name = fory.ReadString(buf)
+func (User_ForyGenSerializer) ReadTyped(ctx *fory.ReadContext, v *User) error {
+ err := ctx.Err()
+ buf := ctx.Buffer()
+ v.ID = buf.ReadInt64(err)
+ v.Name = ctx.ReadString()
+ if ctx.HasError() {
+ return ctx.TakeError()
+ }
return nil
}
```
-### Auto-Registration
+### 自动注册
-Serializers are registered in `init()`:
+序列化器会在 `init()` 中注册:
```go
func init() {
- fory.RegisterGenSerializer(User{}, User_ForyGenSerializer{})
+ fory.RegisterSerializerFactory((*User)(nil), NewSerializerFor_User)
}
```
-## Command-Line Options
+## 命令行选项
-### File-Based Generation
+### 按文件生成
-Generate for a specific file:
+为某个文件生成:
```bash
fory -file models.go
```
-### Package-Based Generation
+### 按包生成
-Generate for a package:
+为整个包生成:
```bash
fory -pkg ./models
```
-### Explicit Types (Legacy)
+### 显式指定类型(旧用法)
-Specify types explicitly:
+显式指定类型:
```bash
fory -pkg ./models -type "User,Order"
```
-### Force Regeneration
+### 强制重新生成
-Force regeneration even if up-to-date:
+即使看起来已经是最新,也强制重新生成:
```bash
fory --force -file models.go
```
-## When to Regenerate
+## 何时需要重新生成
-Regenerate when any of these change:
+出现以下任意变化时,都应重新生成:
-- Field additions, removals, or renames
-- Field type changes
-- Struct tag changes
-- New structs with `//fory:generate`
+- 字段新增、删除或重命名
+- 字段类型变化
+- 结构体 tag 变化
+- 新增带 `//fory:generate` 的结构体
-### Automatic Detection
+### 自动检测
-Fory includes a compile-time guard:
+Fory 内置了编译期守卫:
```go
// If struct changed, this fails to compile
var _ = func(x User) { _ = _User_expected(x) }
```
-If you forget to regenerate, the build fails with a clear message.
+如果忘记重新生成,构建会失败,并给出明确提示。
-### Auto-Retry
+### 自动重试
-When invoked via `go generate`, the generator detects stale code and retries:
+当通过 `go generate` 调用时,生成器会检测陈旧代码并自动重试:
-1. Detects compile error from guard
-2. Removes stale generated file
-3. Regenerates fresh code
+1. 发现守卫触发的编译错误
+2. 删除旧的生成文件
+3. 重新生成最新代码
-## Supported Types
+## 支持的类型
-Code generation supports:
+代码生成支持:
-- All primitive types (`bool`, `int*`, `uint*`, `float*`, `string`)
-- Slices of primitives and structs
-- Maps with supported key/value types
-- Nested structs (must also be generated)
-- Pointers to structs
+- 所有原始类型(`bool`、`int*`、`uint*`、`float*`、`string`)
+- 原始类型和结构体的 slice
+- 键和值类型受支持的 map
+- 嵌套结构体(这些结构体也必须生成)
+- 指向结构体的指针
-### Nested Structs
+### 嵌套结构体
-All nested structs must also have `//fory:generate`:
+所有嵌套结构体也必须带有 `//fory:generate`:
```go
//fory:generate
@@ -243,11 +253,11 @@ type Person struct {
}
```
-## CI/CD Integration
+## CI/CD 集成
-### Check In Generated Code
+### 提交生成代码
-**Recommended for libraries**:
+**推荐用于库项目:**
```bash
go generate ./...
@@ -255,12 +265,12 @@ git add *_fory_gen.go
git commit -m "Regenerate Fory serializers"
```
-**Pros**: Consumers can build without generator; reproducible builds
-**Cons**: Larger diffs; must remember to regenerate
+**优点**:使用者无需安装生成器即可构建;构建更可复现
+**缺点**:diff 更大;需要记得重新生成
-### Generate in Pipeline
+### 在流水线中生成
-**Recommended for applications**:
+**推荐用于应用项目:**
```yaml
steps:
@@ -269,9 +279,9 @@ steps:
- run: go build ./...
```
-## Usage with Generated Code
+## 与生成代码配合使用
-Generated code integrates transparently:
+生成代码可以透明接入:
```go
f := fory.New()
@@ -284,11 +294,11 @@ var result User
f.Deserialize(data, &result)
```
-No code changes needed - registration happens in `init()`.
+无需修改业务代码,注册会在 `init()` 中自动完成。
-## Mixing Generated and Non-Generated
+## 混用生成与非生成方式
-You can mix approaches:
+你可以混合使用两种方式:
```go
//fory:generate
@@ -297,69 +307,69 @@ type HotPathStruct struct {
}
type ColdPathStruct struct {
- // Not annotated, uses reflection
+ // Not annotated, uses the standard runtime serializer
}
```
-## Limitations
+## 限制
-### Experimental Status
+### 实验性状态
-- API may change
-- Not all edge cases tested
-- May have undiscovered bugs
+- API 可能变化
+- 尚未覆盖所有边界场景
+- 可能仍有未发现的缺陷
-### Not Supported
+### 暂不支持
-- Interface fields (dynamic types)
-- Recursive types without pointers
-- Private (unexported) fields
-- Custom serializers
+- 接口字段(动态类型)
+- 无指针的递归类型
+- 私有(未导出)字段
+- 自定义序列化器
-### Reflection Fallback
+### 标准路径回退
-If codegen fails, Fory falls back to reflection:
+如果生成的序列化器不可用,Fory 会自动回退到标准序列化路径:
```go
-// If User_ForyGenSerializer not found, uses reflection
+// If User_ForyGenSerializer is not linked in, Fory uses the standard path
f.Serialize(&User{})
```
-## Troubleshooting
+## 故障排查
-### "fory: command not found"
+### `"fory: command not found"`
-Ensure the binary is in PATH:
+确保二进制已经加入 `PATH`:
```bash
export PATH=$PATH:$(go env GOPATH)/bin
```
-### Compile Error After Struct Change
+### 结构体变更后出现编译错误
-Regenerate:
+重新生成:
```bash
go generate ./...
```
-Or force:
+或强制重新生成:
```bash
fory --force -file yourfile.go
```
-### Generated Code Out of Sync
+### 生成代码不同步
-The compile-time guard catches this:
+编译期守卫会捕获这种情况:
```
cannot use x (variable of type User) as type _User_expected in argument
```
-Run `go generate` to fix.
+运行 `go generate` 即可修复。
-## Example Project Structure
+## 示例项目结构
```
myproject/
@@ -371,7 +381,7 @@ myproject/
└── go.mod
```
-**models/generate.go**:
+**models/generate.go**:
```go
package models
@@ -379,7 +389,7 @@ package models
//go:generate fory -pkg .
```
-**models/models.go**:
+**models/models.go**:
```go
package models
@@ -393,28 +403,28 @@ type User struct {
## FAQ
-### Is codegen required?
+### 代码生成是必须的吗?
-No. Reflection-based serialization works without code generation.
+不是。标准序列化路径在不使用代码生成时也能正常工作。
-### Does generated code work across Go versions?
+### 生成代码能跨 Go 版本使用吗?
-Yes. Generated code is plain Go with no version-specific features.
+可以。生成代码就是普通 Go 代码,不依赖某个特定版本的语言特性。
-### Can I mix generated and non-generated types?
+### 可以混用生成和非生成类型吗?
-Yes. Fory automatically uses generated serializers when available.
+可以。只要生成的序列化器可用,Fory 会自动优先使用它。
-### How do I update generated code?
+### 如何更新生成代码?
-Run `go generate ./...` after struct changes.
+结构体变更后运行 `go generate ./...`。
-### Should I commit generated files?
+### 应该提交生成文件吗?
-For libraries: yes. For applications: either works.
+对于库项目:建议提交。对于应用项目:两种做法都可以。
## 相关主题
-- [Basic Serialization](basic-serialization.md)
-- [Configuration](configuration.md)
-- [Troubleshooting](troubleshooting.md)
+- [基础序列化](basic-serialization.md)
+- [配置](configuration.md)
+- [故障排查](troubleshooting.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/index.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/index.md
index a161c8360..759da6a16 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/index.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/go/index.md
@@ -27,7 +27,7 @@ Apache Fory Go 是一个面向 Go 的高性能跨语言序列化库。它支持
- **跨语言**:可与 Java、Python、C++、Rust、JavaScript 无缝交换数据
- **自动序列化**:无需 IDL 定义或 schema 编译
- **引用跟踪**:内置循环引用和共享对象支持
-- **类型安全**:强类型能力,并可选用代码生成实现编译期校验
+- **类型安全**:具备基于 schema 感知序列化器的强类型能力
- **Schema 演进**:兼容模式支持前向/后向兼容
- **线程安全选项**:提供基于池化的线程安全封装,适用于并发场景
@@ -84,23 +84,15 @@ func main() {
}
```
-## 架构
+## 默认序列化路径
-Fory Go 提供两条序列化路径:
-
-### 基于反射(默认)
-
-默认路径使用 Go 反射在运行时检查类型。它开箱即用,可处理任意结构体。虽然该模式依赖反射,但通过类型缓存和热点路径内联优化,在绝大多数场景下都能提供优秀性能:
+Fory Go 可直接作用于普通 Go 结构体。标准运行时路径会缓存类型元数据,并对热点序列化路径做优化,因此大多数应用都可以直接使用,而不需要额外的构建步骤:
```go
f := fory.New()
data, _ := f.Serialize(myStruct)
```
-### 代码生成(实验特性)
-
-对性能极其敏感的路径,可以使用可选的预编译代码生成,消除反射开销。详见 [代码生成](codegen.md)。
-
## 配置
Fory Go 使用函数式选项模式进行配置:
@@ -153,7 +145,6 @@ data, _ := f.Serialize(&User{ID: 1, Name: "Alice"})
| [Struct 标签](struct-tags.md) | 字段级配置 |
| [Schema 演进](schema-evolution.md) | 前向/后向兼容策略 |
| [跨语言](cross-language.md) | 多语言序列化 |
-| [代码生成](codegen.md) | 实验性的 AOT 代码生成 |
| [线程安全](thread-safety.md) | 并发使用模式 |
| [故障排查](troubleshooting.md) | 常见问题与解决方案 |
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/graalvm_guide.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/graalvm_guide.md
index 56a1dc7b1..cd466b6bf 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/graalvm_guide.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/graalvm_guide.md
@@ -40,6 +40,20 @@ Apache Fory™ 通过**使用代码生成而非反射**,可以完美地与 Gra
## 基础用法
+### 步骤 0:添加 GraalVM 支持依赖
+
+在构建 native image 时,请将 `fory-graalvm-feature` 添加到应用依赖中:
+
+```xml
+<dependency>
+ <groupId>org.apache.fory</groupId>
+ <artifactId>fory-graalvm-feature</artifactId>
+ <version>${fory.version}</version>
+</dependency>
+```
+
+该依赖已经在 `META-INF/native-image` 中携带 GraalVM feature 元数据,因此只要将它加入依赖,就会在 `native-image` 构建期间自动启用 `org.apache.fory.graalvm.feature.ForyGraalVMFeature`。
+
### 步骤 1:创建 Fory 并注册类
```java
@@ -72,37 +86,20 @@ public class Example {
Args = --initialize-at-build-time=com.example.Example
```
-## ForyGraalVMFeature(可选)
+## `fory-graalvm-feature` 会处理什么
-对于大多数具有公共构造函数的类型,上述基本设置就足够了。但是,一些高级情况需要反射注册:
+加入 `fory-graalvm-feature` 依赖后,Fory 会自动注册这些高级场景所需的额外 GraalVM 元数据:
- **私有构造函数**(没有可访问的无参构造函数的类)
- **私有内部类/记录**
- **动态代理序列化**
-`fory-graalvm-feature` 模块会自动处理这些情况,无需手动配置 `reflect-config.json`。
-
-### 添加依赖
-
-```xml
-<dependency>
- <groupId>org.apache.fory</groupId>
- <artifactId>fory-graalvm-feature</artifactId>
- <version>${fory.version}</version>
-</dependency>
-```
-
-### 启用功能
-
-将以下内容添加到您的 `native-image.properties`:
+这意味着在大多数应用中都不再需要手工维护 `reflect-config.json`。你自己的 `native-image.properties` 仍只需要配置在构建时初始化的引导类,例如:
```properties
-Args = --initialize-at-build-time=com.example.Example \
- --features=org.apache.fory.graalvm.feature.ForyGraalVMFeature
+Args = --initialize-at-build-time=com.example.Example
```
-### ForyGraalVMFeature 处理的内容
-
| 场景 | 不使用 Feature | 使用 Feature |
| ------------------------ | --------------------------- | ------------ |
| 具有无参构造函数的公共类 | ✅ 可工作 | ✅ 可工作 |
@@ -137,17 +134,23 @@ public class ProxyExample {
String execute();
}
+ public interface Audited {
+ String traceId();
+ }
+
static Fory fory;
static {
fory = Fory.builder().build();
- // 为序列化注册代理接口
- GraalvmSupport.registerProxySupport(MyService.class);
+ // 按照 Proxy.newProxyInstance(...) 的接口顺序精确注册
+ GraalvmSupport.registerProxySupport(MyService.class, Audited.class);
fory.ensureSerializersCompiled();
}
}
```
+对于只实现单个接口的代理,可以使用 `registerProxySupport(MyService.class)`。如果代理实现了多个接口,则应按创建代理时使用的相同顺序传入完整接口列表。只要 classpath 中包含 `fory-graalvm-feature`,这就可以替代这些代理形状对应的手工 `proxy-config.json` 配置。
+
## 线程安全的 Fory
对于多线程应用程序,使用 `ThreadLocalFory`:
@@ -163,8 +166,8 @@ public class ThreadSafeExample {
static ThreadSafeFory fory;
static {
- fory = new ThreadLocalFory(classLoader -> {
- Fory f = Fory.builder().build();
+ fory = new ThreadLocalFory(builder -> {
+ Fory f = builder.build();
f.register(Foo.class);
f.ensureSerializersCompiled();
return f;
@@ -198,7 +201,7 @@ fory.ensureSerializersCompiled();
如果该类具有私有构造函数,可以:
-1. 添加 `fory-graalvm-feature` 依赖,或
+1. 确保 `fory-graalvm-feature` 已经位于 native-image classpath 中,或
2. 为该特定类创建 `reflect-config.json`
## 框架集成
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/_category_.json b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/_category_.json
index 3cb119d37..3508cf900 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/_category_.json
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/_category_.json
@@ -1,6 +1,6 @@
{
"label": "Java",
- "position": 0,
+ "position": 1,
"collapsible": true,
"collapsed": true
}
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/advanced-features.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/advanced-features.md
index f7104ebf5..c98720d71 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/advanced-features.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/advanced-features.md
@@ -1,6 +1,6 @@
---
title: 高级特性
-sidebar_position: 7
+sidebar_position: 10
id: advanced_features
license: |
Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/compression.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/compression.md
index 3594eee55..5447dd9ed 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/compression.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/compression.md
@@ -1,6 +1,6 @@
---
title: 压缩
-sidebar_position: 6
+sidebar_position: 7
id: compression
license: |
Licensed to the Apache Software Foundation (ASF) under one or more
@@ -19,49 +19,49 @@ license: |
limitations under the License.
---
-本页介绍用于减少序列化数据大小的压缩选项。
+本页介绍用于减小序列化数据体积的压缩选项。
## 整数压缩
-`ForyBuilder#withIntCompressed`/`ForyBuilder#withLongCompressed` 可用于压缩 int/long 以获得更小的大小。通常压缩 int 就足够了。
+可使用 `ForyBuilder#withIntCompressed` / `ForyBuilder#withLongCompressed` 对 int / long 进行压缩以减小体积。通常压缩 int 就足够了。
-这两个压缩选项默认都是启用的。如果序列化大小不重要(例如,你之前使用 FlatBuffers 进行序列化,它不压缩任何东西),那么你应该禁用压缩。如果你的数据全是数字,压缩可能会带来 80% 的性能回退。
+这两个压缩选项默认都已启用。如果序列化体积并不重要,例如你之前使用的是不会做压缩的 FlatBuffers,那么应考虑关闭压缩。如果你的数据几乎全是数字,压缩可能带来 80% 的性能回退。
### Int 压缩
-对于 int 压缩,Fory 使用 1~5 个字节进行编码。每个字节中的第一位表示是否有下一个字节。如果设置了第一位,则将读取下一个字节,直到下一个字节的第一位未设置。
+对于 int 压缩,Fory 使用 1 到 5 个字节进行编码。每个字节的第一位表示后面是否还有下一个字节。如果第一位被置位,就继续读取下一个字节,直到某个字节的第一位未置位为止。
### Long 压缩
-对于 long 压缩,Fory 支持两种编码:
+对于 long 压缩,Fory 支持两种编码方式:
-#### SLI(Small Long as Int)编码(默认)
+#### SLI(Small Long as Int)编码,默认
-- 如果 long 在 `[-1073741824, 1073741823]` 范围内,编码为 4 字节 int:`| little-endian: ((int) value) << 1 |`
-- 否则写为 9 字节:`| 0b1 | little-endian 8bytes long |`
+- 如果 long 落在 `[-1073741824, 1073741823]` 范围内,则按 4 字节 int 编码:`| little-endian: ((int) value) << 1 |`
+- 否则写成 9 字节:`| 0b1 | little-endian 8bytes long |`
#### PVL(Progressive Variable-length Long)编码
-- 每个字节中的第一位表示是否有下一个字节。如果设置了第一位,则将读取下一个字节,直到下一个字节的第一位未设置。
-- 负数将通过 `(v << 1) ^ (v >> 63)` 转换为正数,以减少小负数的成本。
+- 每个字节的第一位表示后面是否还有下一个字节。如果第一位被置位,就继续读取下一个字节,直到某个字节的第一位未置位为止。
+- 负数会通过 `(v << 1) ^ (v >> 63)` 转换为正数,以降低小负数的编码成本。
-如果数字是 `long` 类型,但大多数情况下不能用较小的字节表示,压缩不会得到足够好的结果——与性能成本相比不值得。如果你发现它没有带来太多空间节省,也许你应该尝试禁用 long 压缩。
+如果一个数字虽然是 `long` 类型,但多数情况下并不能用更小字节数表示,那么压缩效果就不会理想,不值得承担对应的性能成本。如果你发现它没有带来明显的空间收益,可以考虑关闭 long 压缩。
## 数组压缩
-当数组值可以适配较小的数据类型时,Fory 支持原始数组(`int[]` 和 `long[]`)的 SIMD 加速压缩。此功能在 Java 16+ 上可用,并使用 Vector API 以获得最佳性能。
+当原始数组(`int[]` 和 `long[]`)中的值可以放入更小的数据类型时,Fory 支持使用 SIMD 加速的数组压缩。该特性要求 Java 16+,并借助 Vector API 获得最佳性能。
-### 数组压缩工作原理
+### 数组压缩如何工作
-数组压缩分析数组以确定值是否可以使用更少的字节存储:
+数组压缩会分析数组,判断这些值是否可以用更少字节存储:
-- **`int[]` → `byte[]`**:当所有值都在范围 [-128, 127] 内时(减少 75% 大小)
-- **`int[]` → `short[]`**:当所有值都在范围 [-32768, 32767] 内时(减少 50% 大小)
-- **`long[]` → `int[]`**:当所有值都适合整数范围时(减少 50% 大小)
+- **`int[]` → `byte[]`**:当所有值都落在 [-128, 127] 范围内时,体积减少 75%
+- **`int[]` → `short[]`**:当所有值都落在 [-32768, 32767] 范围内时,体积减少 50%
+- **`long[]` → `int[]`**:当所有值都可落入 int 范围时,体积减少 50%
-### 配置和注册
+### 配置与注册
-要启用数组压缩,你必须显式注册序列化器:
+要启用数组压缩,你必须显式注册对应的序列化器:
```java
Fory fory = Fory.builder()
@@ -76,7 +76,7 @@ Fory fory = Fory.builder()
CompressedArraySerializers.registerSerializers(fory);
```
-**注意**:必须在依赖项中包含 `fory-simd` 模块,压缩数组序列化器才可用。
+**注意**:要让压缩数组序列化器可用,依赖中必须包含 `fory-simd` 模块。
### Maven 依赖
@@ -84,13 +84,13 @@ CompressedArraySerializers.registerSerializers(fory);
<dependency>
<groupId>org.apache.fory</groupId>
<artifactId>fory-simd</artifactId>
- <version>0.14.1</version>
+ <version>0.17.0</version>
</dependency>
```
## 字符串压缩
-字符串压缩可以通过 `ForyBuilder#withStringCompressed(true)` 启用。这默认是禁用的。
+字符串压缩可通过 `ForyBuilder#withStringCompressed(true)` 启用。该选项默认关闭。
## 配置摘要
@@ -98,28 +98,28 @@ CompressedArraySerializers.registerSerializers(fory);
| ------------------- | ----------------------------------- | ------- |
| `compressInt` | 启用 int 压缩 | `true` |
| `compressLong` | 启用 long 压缩 | `true` |
-| `compressIntArray` | 启用 SIMD int 数组压缩(Java 16+) | `true` |
-| `compressLongArray` | 启用 SIMD long 数组压缩(Java 16+) | `true` |
+| `compressIntArray` | 启用 SIMD int 数组压缩(Java 16+) | `false` |
+| `compressLongArray` | 启用 SIMD long 数组压缩(Java 16+) | `false` |
| `compressString` | 启用字符串压缩 | `false` |
-## 性能考虑
+## 性能注意事项
-1. **对数字密集型数据禁用压缩**:如果你的数据主要是数字,压缩开销可能不值得
-2. **数组压缩需要 Java 16+**:使用 Vector API 进行 SIMD 加速
-3. **Long 压缩可能对大值无用**:如果大多数 long 不能适配较小的表示,请禁用它
-4. **字符串压缩有开销**:仅在字符串高度可压缩时启用
+1. **数字密集型数据建议关闭压缩**:如果你的数据大多是数字,压缩开销可能并不划算。
+2. **数组压缩要求 Java 16+**:它依赖 Vector API 实现 SIMD 加速。
+3. **Long 压缩未必适合大数值**:如果多数 long 无法放进更小表示,请关闭它。
+4. **字符串压缩存在开销**:仅在字符串高度可压缩时启用。
## 示例配置
```java
-// 对于主要是数字的数据 - 禁用压缩
+// 主要是数字的数据:关闭压缩
Fory fory = Fory.builder()
.withLanguage(Language.JAVA)
.withIntCompressed(false)
.withLongCompressed(false)
.build();
-// 对于包含数组的混合数据 - 启用数组压缩
+// 包含数组的混合数据:启用数组压缩
Fory fory = Fory.builder()
.withLanguage(Language.JAVA)
.withIntCompressed(true)
@@ -132,5 +132,5 @@ CompressedArraySerializers.registerSerializers(fory);
## 相关主题
-- [配置选项](configuration.md) - 所有 ForyBuilder 选项
+- [配置](configuration.md) - 所有 ForyBuilder 选项
- [高级特性](advanced-features.md) - 内存管理
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/configuration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/configuration.md
index 12ab5c9f4..e1e34fd24 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/configuration.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/configuration.md
@@ -19,35 +19,35 @@ license: |
limitations under the License.
---
-本页记录通过 `ForyBuilder` 提供的所有配置选项。
+本页记录通过 `ForyBuilder` 提供的全部配置选项。
## ForyBuilder 选项
-| 选项名称 | 描述 | 默认值 |
-| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------ |
-| `timeRefIgnored` | 当启用引用跟踪时,是否忽略在 `TimeSerializers` 中注册的所有时间类型及其子类的引用跟踪。如果忽略,可以通过调用 `Fory#registerSerializer(Class, Serializer)` 为每个时间类型启用引用跟踪。例如,`fory.registerSerializer(Date.class, new DateSerializer(fory, true))`。注意,启用引用跟踪应该在包含时间字段的任何类型的序列化器代码生成之前进行。否则,这些字段仍将跳过引用跟踪。 | `true` |
-| `compressInt` | 启用或禁用 int 压缩以获得更小的大小。 | `true` |
-| `compressLong` | 启用或禁用 long 压缩以获得更小的大小。 | `true` |
-| `compressIntArray` | 当值可以适配较小数据类型时,启用或禁用 int 数组的 SIMD 加速压缩。需要 Java 16+。 | `true` |
-| `compressLongArray` | 当值可以适配较小数据类型时,启用或禁用 long 数组的 SIMD 加速压缩。需要 Java 16+。 | `true` |
-| `compressString` | 启用或禁用字符串压缩以获得更小的大小。 | `false` |
-| `classLoader` | 不应更新类加载器;Fory 缓存类元数据。对于类加载器更新,请使用 `LoaderBinding` 或 `ThreadSafeFory`。 | `Thread.currentThread().getContextClassLoader()` |
-| `compatibleMode` | 类型前向/后向兼容性配置。也与 `checkClassVersion` 配置相关。`SCHEMA_CONSISTENT`:序列化端和反序列化端之间的类 schema 必须一致。`COMPATIBLE`:序列化端和反序列化端之间的类 schema 可以不同。它们可以独立添加/删除字段。[查看更多](schema-evolution.md)。 | `CompatibleMode.SCHEMA_CONSISTENT` |
-| `checkClassVersion` | 确定是否检查类 schema 的一致性。如果启用,Fory 会使用 `classVersionHash` 检查、写入和检查一致性。当启用 `CompatibleMode#COMPATIBLE` 时,它将自动禁用。除非你能确保类不会演化,否则不建议禁用。 | `false` |
-| `checkJdkClassSerializable` | 启用或禁用对 `java.*` 下的类的 `Serializable` 接口检查。如果 `java.*` 下的类不是 `Serializable`,Fory 将抛出 `UnsupportedOperationException`。 | `true` |
-| `registerGuavaTypes` | 是否预注册 Guava 类型,如 `RegularImmutableMap`/`RegularImmutableList`。这些类型不是公共 API,但似乎相当稳定。 | `true` |
-| `requireClassRegistration` | 禁用可能允许未知类被反序列化,可能导致安全风险。 | `true` |
-| `maxDepth` | 设置反序列化的最大深度,当深度超过时,将抛出异常。这可用于拒绝反序列化 DDOS 攻击。 | `50` |
-| `suppressClassRegistrationWarnings` | 是否抑制类注册警告。这些警告可用于安全审计,但可能很烦人,默认情况下将启用此抑制。 | `true` |
-| `metaShareEnabled` | 启用或禁用元数据共享模式。 | 如果设置了 `CompatibleMode.Compatible` 则为 `true`,否则为 false。 |
-| `scopedMetaShareEnabled` | 作用域元数据共享专注于单个序列化过程。在此过程中创建或识别的元数据是它专有的,不会与其他序列化共享。 | 如果设置了 `CompatibleMode.Compatible` 则为 `true`,否则为 false。 |
-| `metaCompressor` | 为元数据压缩设置压缩器。注意传递的 MetaCompressor 应该是线程安全的。默认情况下,将使用基于 `Deflater` 的压缩器 `DeflaterMetaCompressor`。用户可以传递其他压缩器,如 `zstd` 以获得更好的压缩率。 | `DeflaterMetaCompressor` |
-| `deserializeNonexistentClass` | 启用或禁用对不存在类的数据的反序列化/跳过。 | 如果设置了 `CompatibleMode.Compatible` 则为 `true`,否则为 false。 |
-| `codeGenEnabled` | 禁用可能导致更快的初始序列化,但后续序列化会更慢。 | `true` |
-| `asyncCompilationEnabled` | 如果启用,序列化首先使用解释器模式,在类的异步序列化器 JIT 完成后切换到 JIT 序列化。 | `false` |
-| `scalaOptimizationEnabled` | 启用或禁用 Scala 特定的序列化优化。 | `false` |
-| `copyRef` | 禁用时,拷贝性能会更好。但 Fory 深拷贝将忽略循环引用和共享引用。对象图的相同引用将在一次 `Fory#copy` 中被复制为不同的对象。 | `true` |
-| `serializeEnumByName` | 启用时,Fory 按名称而不是序数序列化枚举。 | `false` |
+| 选项名称 | 描述 | 默认值 |
+| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
+| `timeRefIgnored` | 当启用引用跟踪时,是否忽略 `TimeSerializers` 中已注册的所有时间类型及其子类的引用跟踪。如果忽略,也可以通过调用 `Fory#registerSerializer(Class, Serializer)` 为某个时间类型重新启用引用跟踪。例如:`fory.registerSerializer(Date.class, new DateSerializer(fory.getConfig(), true))`。注意,对包含时间字段的类型而言,启用引用跟踪必须发生在相应序列化器代码生成之前,否则这些字段仍会跳过引用跟踪。 | `true` |
+| `compressInt` | 启用或禁用 int 压缩以减小体积。 | `true` |
+| `compressLong` | 启用或禁用 long 压缩以减小体积。 | `true` |
+| `compressIntArray` | 当值可以装入更小数据类型时,启用或禁用对 int 数组的 SIMD 加速压缩。需要 Java 16+。 | `false` |
+| `compressLongArray` | 当值可以装入更小数据类型时,启用或禁用对 long 数组的 SIMD 加速压缩。需要 Java 16+。 | `false` |
+| `compressString` | 启用或禁用字符串压缩以减小体积。 | `false` |
+| `classLoader` | 每个 `Fory` 实例的类加载器在首次解析类之后就固定下来,因为 Fory 会缓存类元数据。若要使用不同的类加载器,请创建一个配置了该类加载器的新 `Fory` 或 `ThreadSafeFory`,或者在首次类解析前依赖线程上下文类加载器。 | `Thread.currentThread().getContextClassLoader()` |
+| `compatibleMode` | 类型前向/后向兼容性配置,也与 `checkClassVersion` 相关。`SCHEMA_CONSISTENT` 表示序列化端和反序列化端的类 schema 必须一致;`COMPATIBLE` 表示两端的类 schema 可以不同,可独立新增或删除字段。[查看更多](schema-evolution.md)。 | `CompatibleMode.SCHEMA_CONSISTENT` |
+| `checkClassVersion` | 是否检查类 schema 的一致性。启用后,Fory 会基于 `classVersionHash` 写入并校验一致性。当启用 `CompatibleMode#COMPATIBLE` 时,该选项会自动关闭。除非你能确保类不会演进,否则不建议关闭。 | `false` |
+| `checkJdkClassSerializable` | 启用或禁用对 `java.*` 下类型的 `Serializable` 接口检查。如果某个 `java.*` 类型未实现 `Serializable`,Fory 会抛出 `UnsupportedOperationException`。 | `true` |
+| `registerGuavaTypes` | 是否预注册 Guava 类型,例如 `RegularImmutableMap` / `RegularImmutableList`。这些类型不是公共 API,但看起来相当稳定。 | `true` |
+| `requireClassRegistration` | 关闭后可能允许未知类被反序列化,从而带来安全风险。 | `true` |
+| `maxDepth` | 设置反序列化的最大深度,超过时会抛出异常。可用于阻止反序列化 DDOS 攻击。 | `50` |
+| `suppressClassRegistrationWarnings` | 是否抑制类注册警告。这些警告可用于安全审计,但可能较为烦人,因此默认启用抑制。 | `true` |
+| `metaShareEnabled` | 启用或禁用元数据共享模式。 | 如果设置了 `CompatibleMode.COMPATIBLE` 则为 `true`,否则为 false。 |
+| `scopedMetaShareEnabled` | 作用域元数据共享只关注单次序列化过程。在该过程中创建或识别的元数据只归属于这次序列化,不会与其他序列化共享。 | 如果设置了 `CompatibleMode.COMPATIBLE` 则为 `true`,否则为 false。 |
+| `metaCompressor` | 设置元数据压缩器。注意传入的 `MetaCompressor` 必须是线程安全的。默认使用基于 `Deflater` 的 `DeflaterMetaCompressor`。用户也可以传入 `zstd` 等其他压缩器以获得更好的压缩率。 | `DeflaterMetaCompressor` |
+| `deserializeUnknownClass` | 启用或禁用对不存在或未知类数据的反序列化/跳过。 | 如果设置了 `CompatibleMode.COMPATIBLE` 则为 `true`,否则为 false。 |
+| `codeGenEnabled` | 关闭后可能让首次序列化更快,但后续序列化会变慢。 | `true` |
+| `asyncCompilationEnabled` | 如果启用,序列化会先使用解释执行模式,在某个类的异步序列化器 JIT 完成后切换到 JIT 序列化。 | `false` |
+| `scalaOptimizationEnabled` | 启用或禁用 Scala 专用序列化优化。 | `false` |
+| `copyRef` | 关闭后,拷贝性能会更好;但 Fory 深拷贝将忽略循环引用和共享引用。对象图中的同一个引用会在一次 `Fory#copy` 中被复制成不同对象。 | `false` |
+| `serializeEnumByName` | 启用后,Fory 会序列化枚举名称,而不是数值枚举 tag。未启用时,Fory 默认写入声明顺序对应的 ordinal,或者在枚举配置了 `@ForyEnumId` 时写入显式稳定 ID。 | `false` |
## 示例配置
@@ -55,23 +55,25 @@ license: |
Fory fory = Fory.builder()
.withLanguage(Language.JAVA)
// 启用引用跟踪以支持共享/循环引用。
- // 如果没有重复引用,禁用它会有更好的性能。
+ // 如果没有重复引用,关闭它通常会有更好的性能。
.withRefTracking(false)
- // 压缩 int 以获得更小的大小
+ // 压缩 int 以减小体积
.withIntCompressed(true)
- // 压缩 long 以获得更小的大小
+ // 压缩 long 以减小体积
.withLongCompressed(true)
.withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
// 启用类型前向/后向兼容性
- // 禁用它以获得更小的大小和更好的性能。
+ // 关闭它通常能得到更小体积和更好性能。
// .withCompatibleMode(CompatibleMode.COMPATIBLE)
- // 启用异步多线程编译。
+ // 启用异步多线程编译
.withAsyncCompilation(true)
.build();
```
## 相关主题
-- [Schema 演化](schema-evolution.md) - 兼容模式和元数据共享
+- [字段配置](field-configuration.md) - `@ForyField`、`@Ignore` 与整数编码注解
+- [枚举配置](enum-configuration.md) - `serializeEnumByName` 与 `@ForyEnumId`
+- [Schema 演进](schema-evolution.md) - 兼容模式与元数据共享
- [压缩](compression.md) - Int、long 和数组压缩详情
- [类型注册](type-registration.md) - 类注册选项
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/custom-serializers.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/custom-serializers.md
index 12c4e42e4..e18e0ac20 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/custom-serializers.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/custom-serializers.md
@@ -19,641 +19,202 @@ license: |
limitations under the License.
---
-本页介绍如何为你的类型实现自定义序列化器。
+本页介绍当前 Java 自定义序列化器 API。
-## 基本自定义序列化器
+## 构造函数输入
-在某些情况下,你可能想为你的类型实现序列化器,特别是对于使用 JDK `writeObject/writeReplace/readObject/readResolve` 自定义序列化的类,这非常低效。
+自定义序列化器不应该持有 `Fory`。
-例如,如果你不想调用以下 `Foo#writeObject`,你可以实现自定义序列化器:
+- 当序列化器只依赖不可变配置、并且可共享时,使用 `Config`。
+- 当序列化器需要类型元信息、泛型或嵌套动态分派时,使用 `TypeResolver`。
+- 如果序列化器持有 `TypeResolver`,它通常就不可共享,也不应实现 `Shareable`。
-```java
-class Foo {
- public long f1;
+## 基础序列化器
- private void writeObject(ObjectOutputStream s) throws IOException {
- System.out.println(f1);
- s.defaultWriteObject();
- }
-}
+运行时状态应通过 `WriteContext` 和 `ReadContext` 传递。只有在确实要做多次读写时,才把 buffer 提取到局部变量中。
-class FooSerializer extends Serializer<Foo> {
- public FooSerializer(Fory fory) {
- super(fory, Foo.class);
+```java
+import org.apache.fory.config.Config;
+import org.apache.fory.context.ReadContext;
+import org.apache.fory.context.WriteContext;
+import org.apache.fory.memory.MemoryBuffer;
+import org.apache.fory.serializer.Serializer;
+import org.apache.fory.serializer.Shareable;
+
+public final class FooSerializer extends Serializer<Foo> implements Shareable {
+ public FooSerializer(Config config) {
+ super(config, Foo.class);
}
@Override
- public void write(MemoryBuffer buffer, Foo value) {
- buffer.writeInt64(value.f1);
+ public void write(WriteContext writeContext, Foo value) {
+ writeContext.getBuffer().writeInt64(value.f1);
+ writeContext.writeString(value.f2);
}
@Override
- public Foo read(MemoryBuffer buffer) {
+ public Foo read(ReadContext readContext) {
+ MemoryBuffer buffer = readContext.getBuffer();
Foo foo = new Foo();
foo.f1 = buffer.readInt64();
+ foo.f2 = readContext.readString(buffer);
return foo;
}
}
```
-### 注册序列化器
+如果序列化器可共享,就使用基于 `Config` 的构造方式注册:
```java
-Fory fory = getFory();
-fory.registerSerializer(Foo.class, new FooSerializer(fory));
+Fory fory = Fory.builder().build();
+fory.registerSerializer(Foo.class, new FooSerializer(fory.getConfig()));
```
-除了注册序列化器,你还可以为类实现 `java.io.Externalizable` 来自定义序列化逻辑。这种类型将由 Fory 的 `ExternalizableSerializer` 序列化。
-
-## 集合序列化器
-
-在为自定义集合类型实现序列化器时,你必须扩展 `CollectionSerializer` 或 `CollectionLikeSerializer`。主要区别是 `CollectionLikeSerializer` 可以序列化具有类似集合结构但不是 Java Collection 子类型的类。
-
-### supportCodegenHook 参数
+## 嵌套对象
-这个特殊参数控制序列化行为:
-
-**当为 `true` 时:**
-
-- 启用对集合元素的优化访问和 JIT 编译以获得更好的性能
-- 直接序列化调用和内联集合项,无需动态序列化器分派成本
-- 对标准集合类型有更好的性能
-- 对大多数集合推荐
-
-**当为 `false` 时:**
-
-- 使用基于接口的元素访问和元素的动态序列化器分派(成本更高)
-- 对自定义集合类型更灵活
-- 当集合有特殊序列化需求时需要
-- 处理复杂的集合实现
-
-### 带 JIT 支持的集合序列化器
-
-在实现带 JIT 支持的集合序列化器时,利用 Fory 现有的二进制格式和集合序列化基础设施:
+如果序列化器需要写入或读取嵌套对象,请使用 context helper,而不要持有 `Fory`:
```java
-public class CustomCollectionSerializer<T extends Collection> extends CollectionSerializer<T> {
- public CustomCollectionSerializer(Fory fory, Class<T> cls) {
- // supportCodegenHook 控制是否使用 JIT 编译
- super(fory, cls, true);
- }
-
- @Override
- public Collection onCollectionWrite(MemoryBuffer buffer, T value) {
- // 写入集合大小
- buffer.writeVarUint32Small7(value.size());
- // 写入任何额外的集合元数据
- return value;
- }
-
- @Override
- public Collection newCollection(MemoryBuffer buffer) {
- // 创建新的集合实例
- Collection collection = super.newCollection(buffer);
- // 读取并设置集合大小
- int numElements = getAndClearNumElements();
- setNumElements(numElements);
- return collection;
- }
-}
-```
-
-注意:在实现 `newCollection` 时调用 `setNumElements`,让 Fory 知道要反序列化多少元素。
-
-### 不带 JIT 的自定义集合序列化器
-
-对于使用原始数组或有特殊要求的集合,实现禁用 JIT 的序列化器:
+import org.apache.fory.config.Config;
+import org.apache.fory.context.ReadContext;
+import org.apache.fory.context.WriteContext;
+import org.apache.fory.serializer.Serializer;
+
+public final class EnvelopeSerializer extends Serializer<Envelope> {
+ public EnvelopeSerializer(Config config) {
+ super(config, Envelope.class);
+ }
-```java
-class IntList extends AbstractCollection<Integer> {
- private final int[] elements;
- private final int size;
-
- public IntList(int size) {
- this.elements = new int[size];
- this.size = size;
- }
-
- public IntList(int[] elements, int size) {
- this.elements = elements;
- this.size = size;
- }
-
- @Override
- public Iterator<Integer> iterator() {
- return new Iterator<Integer>() {
- private int index = 0;
-
- @Override
- public boolean hasNext() {
- return index < size;
- }
-
- @Override
- public Integer next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- }
- return elements[index++];
- }
- };
- }
-
- @Override
- public int size() {
- return size;
- }
-
- public int get(int index) {
- if (index >= size) {
- throw new IndexOutOfBoundsException();
- }
- return elements[index];
- }
-
- public void set(int index, int value) {
- if (index >= size) {
- throw new IndexOutOfBoundsException();
- }
- elements[index] = value;
- }
-
- public int[] getElements() {
- return elements;
- }
-}
+ @Override
+ public void write(WriteContext writeContext, Envelope value) {
+ writeContext.writeRef(value.header);
+ writeContext.writeRef(value.payload);
+ }
-class IntListSerializer extends CollectionLikeSerializer<IntList> {
- public IntListSerializer(Fory fory) {
- // 禁用 JIT,因为我们直接处理序列化
- super(fory, IntList.class, false);
- }
-
- @Override
- public void write(MemoryBuffer buffer, IntList value) {
- // 写入大小
- buffer.writeVarUint32Small7(value.size());
-
- // 直接将元素写为原始 int
- int[] elements = value.getElements();
- for (int i = 0; i < value.size(); i++) {
- buffer.writeVarInt32(elements[i]);
- }
- }
-
- @Override
- public IntList read(MemoryBuffer buffer) {
- // 读取大小
- int size = buffer.readVarUint32Small7();
-
- // 创建数组并读取元素
- int[] elements = new int[size];
- for (int i = 0; i < size; i++) {
- elements[i] = buffer.readVarInt32();
- }
-
- return new IntList(elements, size);
- }
-
- // 当禁用 JIT 时不使用这些方法
- @Override
- public Collection onCollectionWrite(MemoryBuffer buffer, IntList value) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Collection newCollection(MemoryBuffer buffer) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public IntList onCollectionRead(Collection collection) {
- throw new UnsupportedOperationException();
- }
+ @Override
+ public Envelope read(ReadContext readContext) {
+ Envelope envelope = new Envelope();
+ envelope.header = (Header) readContext.readRef();
+ envelope.payload = readContext.readRef();
+ return envelope;
+ }
}
```
-**何时使用此方法:**
+由于它不保留任何运行时局部可变状态,因此该序列化器可以实现 `Shareable`。
+
+## 集合序列化器
-- 处理原始类型
-- 需要最大性能
-- 想要最小化内存开销
-- 有特殊的序列化需求
+对于 Java 集合,请继承 `CollectionSerializer` 或 `CollectionLikeSerializer`。
-### 类集合类型序列化器
+- `CollectionSerializer` 用于真正的 `Collection` 实现。
+- `CollectionLikeSerializer` 用于形态像集合、但并未实现 `Collection` 的类型。
+- 当集合可以使用标准元素代码生成路径时,保持 `supportCodegenHook == true`。
+- 只有在你需要完全控制元素 IO 时,才把 `supportCodegenHook` 设为 `false`。
-对于行为类似集合但不是标准 Java 集合的类型:
+示例:
```java
-class CustomCollectionLike {
- private final Object[] elements;
- private final int size;
-
- public CustomCollectionLike(int size) {
- this.elements = new Object[size];
- this.size = 0;
- }
-
- public CustomCollectionLike(Object[] elements, int size) {
- this.elements = elements;
- this.size = size;
- }
-
- public Object get(int index) {
- if (index >= size) {
- throw new IndexOutOfBoundsException();
- }
- return elements[index];
- }
-
- public int size() {
- return size;
- }
-
- public Object[] getElements() {
- return elements;
- }
-}
+import java.util.ArrayList;
+import java.util.Collection;
+import org.apache.fory.context.ReadContext;
+import org.apache.fory.context.WriteContext;
+import org.apache.fory.memory.MemoryBuffer;
+import org.apache.fory.resolver.TypeResolver;
+import org.apache.fory.serializer.collection.CollectionSerializer;
+
+public final class CustomCollectionSerializer<T extends Collection<?>>
+ extends CollectionSerializer<T> {
+ public CustomCollectionSerializer(TypeResolver typeResolver, Class<T> type) {
+ super(typeResolver, type, true);
+ }
-class CollectionView extends AbstractCollection<Object> {
- private final Object[] elements;
- private final int size;
- private int writeIndex;
-
- public CollectionView(CustomCollectionLike collection) {
- this.elements = collection.getElements();
- this.size = collection.size();
- }
-
- public CollectionView(int size) {
- this.size = size;
- this.elements = new Object[size];
- }
-
- @Override
- public Iterator<Object> iterator() {
- return new Iterator<Object>() {
- private int index = 0;
-
- @Override
- public boolean hasNext() {
- return index < size;
- }
-
- @Override
- public Object next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- }
- return elements[index++];
- }
- };
- }
-
- @Override
- public boolean add(Object element) {
- if (writeIndex >= size) {
- throw new IllegalStateException("Collection is full");
- }
- elements[writeIndex++] = element;
- return true;
- }
-
- @Override
- public int size() {
- return size;
- }
-
- public Object[] getElements() {
- return elements;
- }
-}
+ @Override
+ public Collection onCollectionWrite(WriteContext writeContext, T value) {
+ writeContext.getBuffer().writeVarUint32Small7(value.size());
+ return value;
+ }
+
+ @Override
+ public T onCollectionRead(Collection collection) {
+ return (T) collection;
+ }
-class CustomCollectionSerializer extends CollectionLikeSerializer<CustomCollectionLike> {
- public CustomCollectionSerializer(Fory fory) {
- super(fory, CustomCollectionLike.class, true);
- }
-
- @Override
- public Collection onCollectionWrite(MemoryBuffer buffer, CustomCollectionLike value) {
- buffer.writeVarUint32Small7(value.size());
- return new CollectionView(value);
- }
-
- @Override
- public Collection newCollection(MemoryBuffer buffer) {
- int numElements = buffer.readVarUint32Small7();
- setNumElements(numElements);
- return new CollectionView(numElements);
- }
-
- @Override
- public CustomCollectionLike onCollectionRead(Collection collection) {
- CollectionView view = (CollectionView) collection;
- return new CustomCollectionLike(view.getElements(), view.size());
- }
+ @Override
+ public Collection newCollection(ReadContext readContext) {
+ MemoryBuffer buffer = readContext.getBuffer();
+ int numElements = buffer.readVarUint32Small7();
+ setNumElements(numElements);
+ return new ArrayList(numElements);
+ }
}
```
## Map 序列化器
-在为自定义 Map 类型实现序列化器时,扩展 `MapSerializer` 或 `MapLikeSerializer`。主要区别是 `MapLikeSerializer` 可以序列化具有类似 map 结构但不是 Java Map 子类型的类。
-
-### 带 JIT 支持的 Map 序列化器
+对于 Java map,请继承 `MapSerializer` 或 `MapLikeSerializer`。
```java
-public class CustomMapSerializer<T extends Map> extends MapSerializer<T> {
- public CustomMapSerializer(Fory fory, Class<T> cls) {
- // supportCodegenHook 是决定序列化行为的关键参数
- super(fory, cls, true);
- }
-
- @Override
- public Map onMapWrite(MemoryBuffer buffer, T value) {
- // 写入 map 大小
- buffer.writeVarUint32Small7(value.size());
- // 在这里写入任何额外的 map 元数据
- return value;
- }
-
- @Override
- public Map newMap(MemoryBuffer buffer) {
- // 读取 map 大小
- int numElements = buffer.readVarUint32Small7();
- setNumElements(numElements);
- // 创建并返回新的 map 实例
- T map = (T) new HashMap(numElements);
- fory.getRefResolver().reference(map);
- return map;
- }
-}
-```
-
-注意:在实现 `newMap` 时调用 `setNumElements`,让 Fory 知道要反序列化多少元素。
-
-### 不带 JIT 的自定义 Map 序列化器
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.apache.fory.memory.MemoryBuffer;
+import org.apache.fory.context.ReadContext;
+import org.apache.fory.context.WriteContext;
+import org.apache.fory.resolver.TypeResolver;
+import org.apache.fory.serializer.collection.MapSerializer;
+
+public final class CustomMapSerializer<T extends Map<?, ?>> extends MapSerializer<T> {
+ public CustomMapSerializer(TypeResolver typeResolver, Class<T> type) {
+ super(typeResolver, type, true);
+ }
-对于完全控制序列化过程:
+ @Override
+ public Map onMapWrite(WriteContext writeContext, T value) {
+ writeContext.getBuffer().writeVarUint32Small7(value.size());
+ return value;
+ }
-```java
-class FixedValueMap extends AbstractMap<String, Integer> {
- private final Set<String> keys;
- private final int fixedValue;
-
- public FixedValueMap(Set<String> keys, int fixedValue) {
- this.keys = keys;
- this.fixedValue = fixedValue;
- }
-
- @Override
- public Set<Entry<String, Integer>> entrySet() {
- Set<Entry<String, Integer>> entries = new HashSet<>();
- for (String key : keys) {
- entries.add(new SimpleEntry<>(key, fixedValue));
- }
- return entries;
- }
-
- @Override
- public Integer get(Object key) {
- return keys.contains(key) ? fixedValue : null;
- }
-
- public Set<String> getKeys() {
- return keys;
- }
-
- public int getFixedValue() {
- return fixedValue;
- }
-}
+ @Override
+ public T onMapRead(Map map) {
+ return (T) map;
+ }
-class FixedValueMapSerializer extends MapLikeSerializer<FixedValueMap> {
- public FixedValueMapSerializer(Fory fory) {
- // 禁用 codegen,因为我们直接处理序列化
- super(fory, FixedValueMap.class, false);
- }
-
- @Override
- public void write(MemoryBuffer buffer, FixedValueMap value) {
- // 写入固定值
- buffer.writeInt32(value.getFixedValue());
- // 写入键的数量
- buffer.writeVarUint32Small7(value.getKeys().size());
- // 写入每个键
- for (String key : value.getKeys()) {
- buffer.writeString(key);
- }
- }
-
- @Override
- public FixedValueMap read(MemoryBuffer buffer) {
- // 读取固定值
- int fixedValue = buffer.readInt32();
- // 读取键的数量
- int size = buffer.readVarUint32Small7();
- Set<String> keys = new HashSet<>(size);
- for (int i = 0; i < size; i++) {
- keys.add(buffer.readString());
- }
- return new FixedValueMap(keys, fixedValue);
- }
-
- // 当 supportCodegenHook 为 false 时不使用这些方法
- @Override
- public Map onMapWrite(MemoryBuffer buffer, FixedValueMap value) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public FixedValueMap onMapRead(Map map) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public FixedValueMap onMapCopy(Map map) {
- throw new UnsupportedOperationException();
- }
+ @Override
+ public Map newMap(ReadContext readContext) {
+ MemoryBuffer buffer = readContext.getBuffer();
+ int numElements = buffer.readVarUint32Small7();
+ setNumElements(numElements);
+ return new LinkedHashMap(numElements);
+ }
}
```
-### 类 Map 类型序列化器
-
-对于行为类似 map 但不是标准 Java Map 的类型:
+## 注册
```java
-class CustomMapLike {
- private final Object[] keyArray;
- private final Object[] valueArray;
- private final int size;
-
- public CustomMapLike(int initialCapacity) {
- this.keyArray = new Object[initialCapacity];
- this.valueArray = new Object[initialCapacity];
- this.size = 0;
- }
-
- public CustomMapLike(Object[] keyArray, Object[] valueArray, int size) {
- this.keyArray = keyArray;
- this.valueArray = valueArray;
- this.size = size;
- }
-
- public Integer get(String key) {
- for (int i = 0; i < size; i++) {
- if (key.equals(keyArray[i])) {
- return (Integer) valueArray[i];
- }
- }
- return null;
- }
-
- public int size() {
- return size;
- }
-
- public Object[] getKeyArray() {
- return keyArray;
- }
-
- public Object[] getValueArray() {
- return valueArray;
- }
-}
-
-class MapView extends AbstractMap<Object, Object> {
- private final Object[] keyArray;
- private final Object[] valueArray;
- private final int size;
- private int writeIndex;
-
- public MapView(CustomMapLike mapLike) {
- this.size = mapLike.size();
- this.keyArray = mapLike.getKeyArray();
- this.valueArray = mapLike.getValueArray();
- }
-
- public MapView(int size) {
- this.size = size;
- this.keyArray = new Object[size];
- this.valueArray = new Object[size];
- }
-
- @Override
- public Set<Entry<Object, Object>> entrySet() {
- return new AbstractSet<Entry<Object, Object>>() {
- @Override
- public Iterator<Entry<Object, Object>> iterator() {
- return new Iterator<Entry<Object, Object>>() {
- private int index = 0;
-
- @Override
- public boolean hasNext() {
- return index < size;
- }
-
- @Override
- public Entry<Object, Object> next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- }
- final int currentIndex = index++;
- return new SimpleEntry<>(
- keyArray[currentIndex],
- valueArray[currentIndex]
- );
- }
- };
- }
-
- @Override
- public int size() {
- return size;
- }
- };
- }
-
- @Override
- public Object put(Object key, Object value) {
- if (writeIndex >= size) {
- throw new IllegalStateException("Map is full");
- }
- keyArray[writeIndex] = key;
- valueArray[writeIndex] = value;
- writeIndex++;
- return null;
- }
-
- public Object[] getKeyArray() {
- return keyArray;
- }
-
- public Object[] getValueArray() {
- return valueArray;
- }
-
- public int size() {
- return size;
- }
-}
-
-class CustomMapLikeSerializer extends MapLikeSerializer<CustomMapLike> {
- public CustomMapLikeSerializer(Fory fory) {
- super(fory, CustomMapLike.class, true);
- }
-
- @Override
- public Map onMapWrite(MemoryBuffer buffer, CustomMapLike value) {
- buffer.writeVarUint32Small7(value.size());
- return new MapView(value);
- }
-
- @Override
- public Map newMap(MemoryBuffer buffer) {
- int numElements = buffer.readVarUint32Small7();
- setNumElements(numElements);
- return new MapView(numElements);
- }
-
- @Override
- public CustomMapLike onMapRead(Map map) {
- MapView view = (MapView) map;
- return new CustomMapLike(view.getKeyArray(), view.getValueArray(), view.size());
- }
-
- @Override
- public CustomMapLike onMapCopy(Map map) {
- MapView view = (MapView) map;
- return new CustomMapLike(view.getKeyArray(), view.getValueArray(), view.size());
- }
-}
+Fory fory = Fory.builder().build();
+
+fory.registerSerializer(Foo.class, new FooSerializer(fory.getConfig()));
+fory.registerSerializer(
+ CustomMap.class, new CustomMapSerializer<>(fory.getTypeResolver(), CustomMap.class));
+fory.registerSerializer(
+ CustomCollection.class,
+ new CustomCollectionSerializer<>(fory.getTypeResolver(), CustomCollection.class));
```
-## 注册自定义序列化器
+如果希望 Fory 按需懒加载地构造序列化器,可以注册工厂:
```java
-Fory fory = Fory.builder()
- .withLanguage(Language.JAVA)
- .build();
-
-// 注册 map 序列化器
-fory.registerSerializer(CustomMap.class, new CustomMapSerializer<>(fory, CustomMap.class));
-
-// 注册集合序列化器
-fory.registerSerializer(CustomCollection.class, new CustomCollectionSerializer<>(fory, CustomCollection.class));
+fory.registerSerializer(
+ CustomMap.class, resolver -> new CustomMapSerializer<>(resolver, CustomMap.class));
```
-## 关键点
-
-实现自定义 map 或集合序列化器时:
+## 可共享性
-1. 始终扩展适当的基类(map 使用 `MapSerializer`/`MapLikeSerializer`,集合使用 `CollectionSerializer`/`CollectionLikeSerializer`)
-2. 考虑 `supportCodegenHook` 对性能和功能的影响
-3. 如果需要,适当处理引用跟踪
-4. 当 `supportCodegenHook` 为 `true` 时,使用 `setNumElements` 和 `getAndClearNumElements` 实现适当的大小管理
+当某个序列化器能够在等价运行时之间以及并发操作中安全复用时,就应实现 `Shareable` 标记接口。可共享序列化器不能保留操作状态、运行时局部可变状态,也不能在多次调用之间复用可变 scratch buffer。使用者可以通过 `serializer instanceof Shareable` 来判断其是否可共享。
-## 相关主题
+在实践中:
-- [类型注册](type-registration.md) - 注册序列化器
-- [Schema 演化](schema-evolution.md) - 兼容模式考虑
-- [配置选项](configuration.md) - 序列化选项
+- 只依赖 `Config` 的序列化器通常是可共享的。
+- 基于 `TypeResolver` 的序列化器通常不可共享。
+- 操作状态应放在 `WriteContext`、`ReadContext` 和 `CopyContext` 中,而不是放在序列化器字段里。
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/enum-configuration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/enum-configuration.md
new file mode 100644
index 000000000..0b168034e
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/enum-configuration.md
@@ -0,0 +1,104 @@
+---
+title: 枚举配置
+sidebar_position: 6
+id: enum_configuration
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页说明如何在 Apache Fory 中配置 Java 枚举的序列化方式。
+
+## 默认枚举行为
+
+Java 枚举可以通过两种模式进行序列化:
+
+1. **按数值 tag**:默认行为
+2. **按枚举名称**:通过 `serializeEnumByName(true)` 启用
+
+在 xlang 模式下,始终使用数值 tag。在原生 Java 模式下,`serializeEnumByName(true)` 会把枚举序列化方式切换为按名称,而不是按数值 tag。
+
+## 按名称序列化枚举
+
+当原生 Java 对端应按名称而不是按数值 tag 匹配枚举常量时,请使用 `serializeEnumByName(true)`。
+
+```java
+Fory fory = Fory.builder()
+ .withLanguage(Language.JAVA)
+ .serializeEnumByName(true)
+ .build();
+```
+
+当声明顺序可能不稳定,但枚举名称保持固定时,这种模式很有用。它只影响原生 Java 模式;xlang 仍然使用数值 tag。
+
+## 稳定的数值枚举 ID
+
+如果未启用 `serializeEnumByName(true)`,Java 枚举会按数值 tag 序列化。默认的 tag 是声明顺序对应的 ordinal。如果枚举需要与声明顺序无关的稳定 ID,请只使用一种 `@ForyEnumId` 来源:要么标注唯一一个 ID 来源,要么为每个枚举常量都显式标注 tag 值。
+
+```java
+import org.apache.fory.annotation.ForyEnumId;
+
+enum Status {
+ Unknown(10),
+ Running(20),
+ Finished(30);
+
+ private final int id;
+
+ Status(int id) {
+ this.id = id;
+ }
+
+ @ForyEnumId
+ public int getId() {
+ return id;
+ }
+}
+```
+
+Java 也支持在某个枚举实例字段上标注 `@ForyEnumId`,或者直接在每个枚举常量上标注,例如 `@ForyEnumId(10) Unknown`。
+
+### `@ForyEnumId` 的三种样式
+
+`@ForyEnumId` 只支持以下三种配置方式:
+
+1. 标注一个枚举实例字段,并在该字段中保存数值 ID
+2. 标注一个无参 public 实例方法,例如 `getId()`
+3. 为每个枚举常量都直接标注显式值,例如 `@ForyEnumId(10) Unknown`
+
+### 校验规则
+
+1. 对于同一个枚举,只能使用上述三种方式中的一种
+2. 字段和方法上的注解必须保持 `value()` 为默认值 `-1`
+3. 一旦有任意一个枚举常量使用 `@ForyEnumId`,所有枚举常量都必须标注
+4. 所有 ID 都必须非负、唯一,并且能放入 Java `int`
+
+### 查找行为
+
+1. 没有 `@ForyEnumId` 时,Fory 写入声明顺序对应的 ordinal
+2. 使用 `@ForyEnumId` 时,Fory 会改为写入配置好的稳定数值 tag
+3. 对于较小且稠密的 tag,内部会使用数组查找;对稀疏且较大的 tag,则退回到 map 查找
+
+## 如何在名称模式和数值模式之间选择
+
+- 当枚举只在 Java 内部使用,且常量名才是兼容性主键时,使用**枚举名称**
+- 当需要处理跨语言载荷,或需要稳定的显式 ID 时,使用**数值 tag**
+- 当声明顺序可能变化,但编码格式中的数值 ID 必须保持稳定时,使用 **`@ForyEnumId`**
+
+## 相关主题
+
+- [配置选项](configuration.md) - `serializeEnumByName` 及其他运行时选项
+- [字段配置](field-configuration.md) - `@ForyField`、`@Ignore` 和整数编码注解
+- [跨语言序列化](cross-language.md) - Xlang 枚举互操作
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/field-configuration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/field-configuration.md
index 2f21ab6c6..62251bb8b 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/field-configuration.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/field-configuration.md
@@ -600,6 +600,7 @@ public class User {
## 相关主题
-- [基础序列化](basic_serialization) - 快速上手 Fory 序列化
-- [Schema 演进](schema_evolution) - 兼容模式与 schema 演进
-- [跨语言](cross_language) - 与 Python、Rust、C++、Go 互操作
+- [基础序列化](basic-serialization.md) - 快速上手 Fory 序列化
+- [配置选项](configuration.md) - 运行时构建器选项
+- [枚举配置](enum-configuration.md) - `@ForyEnumId` 以及按名称/按 tag 的枚举行为
+- [Schema 演进](schema-evolution.md) - 兼容模式与 Schema 演进
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/index.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/index.md
index ce0300cce..4888dee0e 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/index.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/index.md
@@ -82,22 +82,16 @@ public class Example {
### 多线程使用
```java
-import java.util.List;
-import java.util.Arrays;
-
import org.apache.fory.*;
import org.apache.fory.config.*;
public class Example {
public static void main(String[] args) {
SomeClass object = new SomeClass();
- // 注意 Fory 实例应该在多次不同对象的序列化之间复用。
- ThreadSafeFory fory = new ThreadLocalFory(classLoader -> {
- Fory f = Fory.builder().withLanguage(Language.JAVA)
- .withClassLoader(classLoader).build();
- f.register(SomeClass.class, 1);
- return f;
- });
+ ThreadSafeFory fory = Fory.builder()
+ .withLanguage(Language.JAVA)
+ .buildThreadSafeFory();
+ fory.register(SomeClass.class, 1);
byte[] bytes = fory.serialize(object);
System.out.println(fory.deserialize(bytes));
}
@@ -107,20 +101,17 @@ public class Example {
### Fory 实例复用模式
```java
-import java.util.List;
-import java.util.Arrays;
-
import org.apache.fory.*;
import org.apache.fory.config.*;
public class Example {
- // 复用 fory。
- private static final ThreadSafeFory fory = new ThreadLocalFory(classLoader -> {
- Fory f = Fory.builder().withLanguage(Language.JAVA)
- .withClassLoader(classLoader).build();
- f.register(SomeClass.class, 1);
- return f;
- });
+ private static final ThreadSafeFory fory = Fory.builder()
+ .withLanguage(Language.JAVA)
+ .buildThreadSafeFory();
+
+ static {
+ fory.register(SomeClass.class, 1);
+ }
public static void main(String[] args) {
SomeClass object = new SomeClass();
@@ -132,26 +123,39 @@ public class Example {
## 线程安全
-Fory 提供多种线程安全序列化选项:
+Fory 提供两种线程安全运行时风格:
+
+### `buildThreadSafeFory`
+
+这是默认选择。它会构建一个固定大小的共享 `ThreadPoolFory`,其大小为 `4 * availableProcessors()`,也是虚拟线程工作负载下的首选运行时:
+
+```java
+ThreadSafeFory fory = Fory.builder()
+ .withLanguage(Language.JAVA)
+ .withRefTracking(false)
+ .withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
+ .withAsyncCompilation(true)
+ .buildThreadSafeFory();
+```
+
+更多细节请参见 [虚拟线程](virtual-threads.md)。
### ThreadLocalFory
-使用线程本地存储为每个线程维护独立的 Fory 实例:
+仅当你明确希望为每个长期存在的平台线程分配一个 `Fory` 实例,或者无论 JDK 版本如何都要固定采用这种方式时,才使用 `buildThreadLocalFory()`:
```java
-ThreadSafeFory fory = new ThreadLocalFory(classLoader -> {
- Fory f = Fory.builder().withLanguage(Language.JAVA)
- .withClassLoader(classLoader).build();
- f.register(SomeClass.class, 1);
- return f;
-});
+ThreadSafeFory fory = Fory.builder()
+ .withLanguage(Language.JAVA)
+ .buildThreadLocalFory();
+fory.register(SomeClass.class, 1);
byte[] bytes = fory.serialize(object);
System.out.println(fory.deserialize(bytes));
```
-### ThreadSafeForyPool
+### `buildThreadSafeForyPool`
-对于虚拟线程或不适合使用线程本地存储的环境,使用 `buildThreadSafeForyPool`:
+如果你希望显式指定固定共享池大小,请使用 `buildThreadSafeForyPool(poolSize)`。它会预先创建 `poolSize` 个 `Fory` 实例,把它们放在共享固定槽位中,然后让任意调用方通过与线程无关的快速路径借用实例。只有当池中所有实例都在使用时,调用才会阻塞;运行时不会按照线程身份缓存实例:
```java
ThreadSafeFory fory = Fory.builder()
@@ -159,11 +163,9 @@ ThreadSafeFory fory = Fory.builder()
.withRefTracking(false)
.withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
.withAsyncCompilation(true)
- .buildThreadSafeForyPool(minPoolSize, maxPoolSize);
+ .buildThreadSafeForyPool(poolSize);
```
-注意,在 `ForyBuilder` 上调用 `buildThreadSafeFory()` 将创建 `ThreadLocalFory` 实例。这在使用虚拟线程的环境中可能不合适,因为每个线程都会创建自己的 Fory 实例,这是一个相对昂贵的操作。对于虚拟线程,另一种选择是使用 `buildThreadSafeForyPool`。
-
### Builder 方法
```java
@@ -175,19 +177,28 @@ Fory fory = Fory.builder()
.withAsyncCompilation(true)
.build();
-// 线程安全 Fory (ThreadLocalFory)
+// 线程安全 Fory(由 Fory 实例池支撑)
ThreadSafeFory fory = Fory.builder()
.withLanguage(Language.JAVA)
.withRefTracking(false)
.withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
.withAsyncCompilation(true)
.buildThreadSafeFory();
+
+// 显式线程本地运行时
+ThreadSafeFory threadLocalFory = Fory.builder()
+ .withLanguage(Language.JAVA)
+ .buildThreadLocalFory();
```
## 后续步骤
- [配置选项](configuration.md) - 了解 ForyBuilder 选项
+- [字段配置](field-configuration.md) - `@ForyField`、`@Ignore` 和整数编码注解
+- [枚举配置](enum-configuration.md) - `serializeEnumByName` 与 `@ForyEnumId`
- [基础序列化](basic-serialization.md) - 详细的序列化模式
+- [压缩](compression.md) - 整数、long 和数组压缩选项
+- [虚拟线程](virtual-threads.md) - 虚拟线程使用方式与池大小建议
- [类型注册](type-registration.md) - 类注册和安全性
- [自定义序列化器](custom-serializers.md) - 实现自定义序列化器
- [跨语言序列化](cross-language.md) - 为其他语言序列化数据
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/migration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/migration.md
index d794ab848..f1510c7ac 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/migration.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/migration.md
@@ -1,6 +1,6 @@
---
title: 迁移指南
-sidebar_position: 10
+sidebar_position: 13
id: migration
license: |
Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/schema-evolution.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/schema-evolution.md
index 4ec49c718..bff6bd0e4 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/schema-evolution.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/schema-evolution.md
@@ -1,6 +1,6 @@
---
-title: Schema 演化
-sidebar_position: 5
+title: Schema 演进
+sidebar_position: 9
id: schema_evolution
license: |
Licensed to the Apache Software Foundation (ASF) under one or more
@@ -62,13 +62,13 @@ Fory 支持在上下文(例如 TCP 连接)中的多次序列化之间共享
// .withMetaContextShare(true)
// 非线程安全 fory。
-MetaContext context = xxx;
-fory.getSerializationContext().setMetaContext(context);
+MetaWriteContext writeContext = xxx;
+fory.setMetaWriteContext(writeContext);
byte[] bytes = fory.serialize(o);
// 非线程安全 fory。
-MetaContext context = xxx;
-fory.getSerializationContext().setMetaContext(context);
+MetaReadContext readContext = xxx;
+fory.setMetaReadContext(readContext);
fory.deserialize(bytes);
```
@@ -76,37 +76,35 @@ fory.deserialize(bytes);
```java
// 线程安全 fory
-fory.setClassLoader(beanA.getClass().getClassLoader());
byte[] serialized = fory.execute(
f -> {
- f.getSerializationContext().setMetaContext(context);
+ f.setMetaWriteContext(writeContext);
return f.serialize(beanA);
}
);
// 线程安全 fory
-fory.setClassLoader(beanA.getClass().getClassLoader());
Object newObj = fory.execute(
f -> {
- f.getSerializationContext().setMetaContext(context);
+ f.setMetaReadContext(readContext);
return f.deserialize(serialized);
}
);
```
-**注意**:`MetaContext` 不是线程安全的,不能在 Fory 实例或多个线程之间重用。在多线程情况下,必须为每个 Fory 实例创建单独的 `MetaContext`。
+**注意**:`MetaWriteContext` 和 `MetaReadContext` 都不是线程安全的,不能在多个 Fory 实例或多个线程之间重用。在多线程场景下,必须为每个 Fory 实例创建一对独立的 meta context。如果你需要不同的类加载器,请创建一个配置了该类加载器的独立 `Fory` 或 `ThreadSafeFory`,而不是在已有实例上切换类加载器。
有关更多详细信息,请参阅 [元数据共享规范](https://fory.apache.org/docs/specification/fory_java_serialization_spec#meta-share)。
-## 反序列化不存在的类
+## 反序列化未知类
-Fory 支持反序列化不存在的类。此功能可以通过 `ForyBuilder#deserializeNonexistentClass(true)` 启用。
+Fory 支持反序列化不存在或未知的类。此功能可通过 `ForyBuilder#deserializeUnknownClass(true)` 启用。
-启用时,如果启用了元数据共享,Fory 将把此类型的反序列化数据存储在 Map 的延迟子类中。通过使用 Fory 实现的延迟映射,可以避免反序列化期间填充映射的重新平衡成本,从而进一步提高性能。
+启用后,如果同时启用了元数据共享,Fory 会把这类数据存放在 `Map` 的惰性子类中。通过使用 Fory 实现的惰性 map,可以避免反序列化过程中填充 map 的重平衡成本,从而进一步提升性能。
-如果此数据被发送到另一个进程,并且该类在此过程中存在,则数据将被反序列化为此类型的对象,而不会丢失任何信息。
+如果这些数据被发送到另一个进程,并且该进程中存在相应类,那么这些数据就会被反序列化为该类型的对象,而不会丢失信息。
-如果未启用元数据共享,新类数据将被跳过,并返回 `NonexistentSkipClass` 存根对象。
+如果没有启用元数据共享,新类数据会被跳过,并返回 `UnknownSkipClass` 存根对象。
## 将对象从一种类型复制/映射到另一种类型
@@ -159,7 +157,7 @@ public class StructMappingExample {
## 将 POJO 反序列化为另一种类型
-Fory 允许你序列化一个 POJO 并将其反序列化为另一个 POJO。不同的 POJO 意味着 schema 不一致。用户必须将 Fory 配置为 `CompatibleMode` 设置为 `org.apache.fory.config.CompatibleMode.COMPATIBLE`。
+Fory 允许你序列化一个 POJO,并将其反序列化为另一个不同的 POJO。不同的 POJO 意味着 schema 不一致。用户必须将 Fory 配置为 `CompatibleMode.COMPATIBLE`。
```java
public class DeserializeIntoType {
@@ -184,8 +182,8 @@ public class DeserializeIntoType {
public static void main(String[] args) {
Struct1 struct1 = new Struct1(10, "abc");
- byte[] data = fory.serializeJavaObject(struct1);
- Struct2 struct2 = (Struct2) fory.deserializeJavaObject(bytes, Struct2.class);
+ byte[] data = fory.serialize(struct1);
+ Struct2 struct2 = fory.deserialize(data, Struct2.class);
}
}
```
@@ -198,7 +196,7 @@ public class DeserializeIntoType {
| `checkClassVersion` | 检查类 schema 一致性 | `false` |
| `metaShareEnabled` | 启用元数据共享 | 如果是兼容模式则为 `true` |
| `scopedMetaShareEnabled` | 每次序列化的作用域元数据共享 | 如果是兼容模式则为 `true` |
-| `deserializeNonexistentClass` | 处理不存在的类 | 如果是兼容模式则为 `true` |
+| `deserializeUnknownClass` | 处理不存在或未知的类 | 如果是兼容模式则为 `true` |
| `metaCompressor` | 元数据压缩的压缩器 | `DeflaterMetaCompressor` |
## 最佳实践
@@ -212,4 +210,4 @@ public class DeserializeIntoType {
- [配置选项](configuration.md) - 所有 ForyBuilder 选项
- [跨语言序列化](cross-language.md) - XLANG 模式
-- [故障排除](troubleshooting.md) - 常见 schema 问题
+- [故障排查](troubleshooting.md) - 常见 Schema 问题
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/troubleshooting.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/troubleshooting.md
index f9265f23d..3b85463e8 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/troubleshooting.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/troubleshooting.md
@@ -1,6 +1,6 @@
---
-title: 故障排除
-sidebar_position: 11
+title: 故障排查
+sidebar_position: 14
id: troubleshooting
license: |
Licensed to the Apache Software Foundation (ASF) under one or more
@@ -21,11 +21,11 @@ license: |
本页介绍常见问题及其解决方案。
-## 类不一致和类版本检查
+## 类不一致与类版本检查
-如果你创建 Fory 时没有将 `CompatibleMode` 设置为 `org.apache.fory.config.CompatibleMode.COMPATIBLE`,并且遇到奇怪的序列化错误,这可能是由于序列化端和反序列化端之间的类不一致造成的。
+如果你创建 Fory 时没有将 `CompatibleMode` 设为 `org.apache.fory.config.CompatibleMode.COMPATIBLE`,并且遇到奇怪的序列化错误,那么原因可能是序列化端和反序列化端之间的类不一致。
-在这种情况下,你可以调用 `ForyBuilder#withClassVersionCheck` 来创建 Fory 以验证它。如果反序列化抛出 `org.apache.fory.exception.ClassNotCompatibleException`,则表示类不一致,你应该使用 `ForyBuilder#withCompatibleMode(CompatibleMode.COMPATIBLE)` 创建 Fory。
+在这种情况下,你可以调用 `ForyBuilder#withClassVersionCheck` 来创建 Fory 进行校验。如果反序列化抛出 `org.apache.fory.exception.ClassNotCompatibleException`,就说明类不一致,此时应改为使用 `ForyBuilder#withCompatibleMode(CompatibleMode.COMPATIBLE)` 创建 Fory。
```java
// 启用类版本检查以诊断问题
@@ -34,54 +34,44 @@ Fory fory = Fory.builder()
.withClassVersionCheck(true)
.build();
-// 如果抛出 ClassNotCompatibleException,使用兼容模式
+// 如果抛出 ClassNotCompatibleException,则改用兼容模式
Fory fory = Fory.builder()
.withLanguage(Language.JAVA)
.withCompatibleMode(CompatibleMode.COMPATIBLE)
.build();
```
-**注意**:`CompatibleMode.COMPATIBLE` 有更多的性能和空间成本。如果你的类在序列化和反序列化之间始终一致,请不要默认设置它。
+**注意**:`CompatibleMode.COMPATIBLE` 会带来更多的性能和空间开销。如果序列化端和反序列化端的类始终一致,就不要默认开启它。
-## 使用错误的反序列化 API
+## 使用了错误的反序列化 API
-确保使用匹配的 API 对:
+请将 `serialize` 与某个 `deserialize` 重载搭配使用:
-| 序列化 API | 反序列化 API |
-| ---------------------------------- | ------------------------------------ |
-| `Fory#serialize` | `Fory#deserialize` |
-| `Fory#serializeJavaObject` | `Fory#deserializeJavaObject` |
-| `Fory#serializeJavaObjectAndClass` | `Fory#deserializeJavaObjectAndClass` |
+| 序列化 API | 反序列化 API |
+| ----------------- | ----------------- |
+| `Fory#serialize` | `Fory#deserialize` |
-**错误使用示例:**
+**错误示例:**
```java
-// ❌ 错误:使用 serialize 序列化,使用 deserializeJavaObject 反序列化
-byte[] bytes = fory.serialize(object);
-Object result = fory.deserializeJavaObject(bytes, MyClass.class); // 错误!
-
-// ❌ 错误:使用 serializeJavaObject 序列化,使用 deserialize 反序列化
-byte[] bytes = fory.serializeJavaObject(object);
-Object result = fory.deserialize(bytes); // 错误!
+// ❌ 错误:使用不兼容的目标类型做反序列化
+byte[] bytes = fory.serialize(struct1);
+Struct2 result = fory.deserialize(bytes, Struct2.class); // 可能抛出 ClassCastException
```
-**正确使用:**
+**正确示例:**
```java
-// ✅ 正确:匹配的 API 对
byte[] bytes = fory.serialize(object);
Object result = fory.deserialize(bytes);
-byte[] bytes = fory.serializeJavaObject(object);
-MyClass result = fory.deserializeJavaObject(bytes, MyClass.class);
-
-byte[] bytes = fory.serializeJavaObjectAndClass(object);
-Object result = fory.deserializeJavaObjectAndClass(bytes);
+byte[] typedBytes = fory.serialize(object);
+MyClass typedResult = fory.deserialize(typedBytes, MyClass.class);
```
## 将 POJO 反序列化为另一种类型
-如果你想序列化一个 POJO 并将其反序列化为另一个 POJO 类型,你必须使用 `CompatibleMode.COMPATIBLE`:
+如果你想序列化一个 POJO,然后把它反序列化为另一种 POJO 类型,就必须使用 `CompatibleMode.COMPATIBLE`:
```java
public class DeserializeIntoType {
@@ -106,19 +96,19 @@ public class DeserializeIntoType {
public static void main(String[] args) {
Struct1 struct1 = new Struct1(10, "abc");
- byte[] data = fory.serializeJavaObject(struct1);
- Struct2 struct2 = (Struct2) fory.deserializeJavaObject(data, Struct2.class);
+ byte[] data = fory.serialize(struct1);
+ Struct2 struct2 = fory.deserialize(data, Struct2.class);
}
}
```
## 常见错误消息
-### "Class not registered"
+### `"Class not registered"`
-**原因**:需要类注册,但类未注册。
+**原因**:启用了类注册要求,但该类没有注册。
-**解决方案**:在序列化之前注册类:
+**解决方案**:在序列化前注册该类:
```java
fory.register(MyClass.class);
@@ -126,9 +116,9 @@ fory.register(MyClass.class);
fory.register(MyClass.class, 100);
```
-### "ClassNotCompatibleException"
+### `"ClassNotCompatibleException"`
-**原因**:序列化和反序列化之间的类 schema 不同。
+**原因**:序列化端和反序列化端之间的类 schema 不一致。
**解决方案**:使用兼容模式:
@@ -138,33 +128,33 @@ Fory fory = Fory.builder()
.build();
```
-### "Max depth exceeded"
+### `"Max depth exceeded"`
-**原因**:对象图太深,可能表示循环引用攻击。
+**原因**:对象图过深,可能意味着循环引用攻击。
-**解决方案**:如果是合法的,增加最大深度,或检查恶意数据:
+**解决方案**:如果数据本身合法,就提高最大深度;否则检查是否存在恶意数据:
```java
Fory fory = Fory.builder()
- .withMaxDepth(100) // 从默认的 50 增加
+ .withMaxDepth(100) // 相比默认值 50 提高上限
.build();
```
-### "Serializer not found"
+### `"Serializer not found"`
-**原因**:未为该类型注册序列化器。
+**原因**:该类型没有注册对应的序列化器。
**解决方案**:注册自定义序列化器:
```java
-fory.registerSerializer(MyClass.class, new MyClassSerializer(fory));
+fory.registerSerializer(MyClass.class, new MyClassSerializer(fory.getTypeResolver()));
```
## 性能问题
-### 初始序列化慢
+### 首次序列化较慢
-**原因**:JIT 编译在第一次序列化时发生。
+**原因**:第一次序列化时发生了 JIT 编译。
**解决方案**:启用异步编译:
@@ -174,32 +164,32 @@ Fory fory = Fory.builder()
.build();
```
-### 内存使用高
+### 内存使用过高
-**原因**:大对象图或引用跟踪开销。
+**原因**:对象图较大,或引用跟踪带来额外开销。
**解决方案**:
-- 如果不需要,禁用引用跟踪:`.withRefTracking(false)`
-- 使用自定义内存分配器进行池化
-- 考虑对大数据集使用行格式
+- 如果不需要,关闭引用跟踪:`.withRefTracking(false)`
+- 使用自定义内存分配器做池化
+- 对大数据集考虑使用行格式
-### 序列化大小大
+### 序列化结果偏大
-**原因**:元数据开销或未压缩的数据。
+**原因**:元数据开销过大,或数据未压缩。
**解决方案**:
- 启用压缩:`.withIntCompressed(true)`、`.withLongCompressed(true)`
-- 仅在需要时使用兼容模式
-- 注册类以避免类名序列化
+- 只在真正需要时使用兼容模式
+- 注册类以避免写入类名
## 调试技巧
-1. **启用类版本检查**以诊断 schema 问题
-2. **检查 API 配对** - 确保序列化/反序列化 API 匹配
-3. **验证注册顺序** - 必须在各端之间保持一致
-4. **启用日志记录**以查看内部操作:
+1. **启用类版本检查** 来诊断 Schema 问题。
+2. **检查 API 是否正确配对**,确保 serialize/deserialize 组合正确。
+3. **核对注册顺序**,两端必须保持一致。
+4. **启用日志** 观察内部行为:
```java
LoggerFactory.setLogLevel(LogLevel.DEBUG_LEVEL);
@@ -207,7 +197,7 @@ LoggerFactory.setLogLevel(LogLevel.DEBUG_LEVEL);
## 相关主题
-- [配置选项](configuration.md) - 所有 ForyBuilder 选项
-- [Schema 演化](schema-evolution.md) - 兼容模式详情
+- [配置](configuration.md) - 所有 ForyBuilder 选项
+- [Schema 演进](schema-evolution.md) - 兼容模式详情
- [类型注册](type-registration.md) - 注册最佳实践
- [迁移指南](migration.md) - 升级 Fory 版本
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/type-registration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/type-registration.md
index 73a90fa59..88baec0ce 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/type-registration.md
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/type-registration.md
@@ -19,19 +19,19 @@ license: |
limitations under the License.
---
-本页介绍类注册机制和安全配置。
+本页介绍类注册机制与安全配置。
## 类注册
-`ForyBuilder#requireClassRegistration` 可用于禁用类注册。这将允许反序列化未知类型的对象,这更灵活但**如果类包含恶意代码可能不安全**。
+`ForyBuilder#requireClassRegistration` 可用于关闭类注册要求。这会允许反序列化未知类型的对象,灵活性更高,但**如果这些类包含恶意代码,就可能不安全**。
-**除非你能确保环境是安全的,否则不要禁用类注册**。当禁用此选项时,反序列化未知/不受信任的类型时,`init/equals/hashCode` 中的恶意代码可能会被执行。
+**除非你能确保运行环境安全,否则不要关闭类注册。** 当这个选项被关闭时,反序列化未知或不受信任的类型时,`init/equals/hashCode` 中的恶意代码可能被执行。
-类注册不仅可以降低安全风险,还可以避免类名序列化成本。
+类注册不仅可以降低安全风险,也能避免写入类名带来的额外开销。
### 按 ID 注册
-你可以使用 API `Fory#register` 注册类:
+你可以通过 `Fory#register` 注册类:
```java
Fory fory = xxx;
@@ -39,56 +39,57 @@ fory.register(SomeClass.class);
fory.register(SomeClass1.class, 1);
```
-注意,类注册顺序很重要。序列化和反序列化端应该具有相同的注册顺序。
+注意,类注册顺序很重要。序列化端和反序列化端应该保持相同的注册顺序。
+
+内部类型 ID 的 `0-32` 预留给内置 xlang 类型。Java 原生内建类型从 `Types.NONE + 1` 开始,用户 ID 的编码形式是 `(user_id << 8) | internal_type_id`。
### 按名称注册
-按 ID 注册类会有更好的性能和更小的空间开销。但在某些情况下,管理一堆类型 ID 很复杂。在这种情况下,建议使用 API `register(Class<?> cls, String namespace, String typeName)` 按名称注册类:
+按 ID 注册有更好的性能和更小的空间开销。但在某些场景下,维护大量 type ID 也很复杂。这时,推荐使用 `register(Class<?> cls, String namespace, String typeName)` 按名称注册类:
```java
fory.register(Foo.class, "demo", "Foo");
```
-如果类型没有重复的名称,`namespace` 可以留空以减少序列化大小。
+如果类型名称不会冲突,可以将 `namespace` 留空以减小序列化体积。
-**不要使用此 API 注册类,因为与按 ID 注册类相比,它会大大增加序列化大小。**
+**不要在应追求紧凑编码的场景中优先使用这个 API,因为它相比按 ID 注册会显著增加序列化体积。**
## 安全配置
-### 类检查器
+### Type Checker
-如果你调用 `ForyBuilder#requireClassRegistration(false)` 来禁用类注册检查,你可以通过 `ClassResolver#setClassChecker` 设置 `org.apache.fory.resolver.ClassChecker` 来控制哪些类允许序列化。
+如果你调用 `ForyBuilder#requireClassRegistration(false)` 来关闭类注册检查,就可以通过 `ForyBuilder#withTypeChecker` 或 `TypeResolver#setTypeChecker` 配置 `org.apache.fory.resolver.TypeChecker`,从而控制哪些类允许被序列化。
-例如,你可以允许以 `org.example.*` 开头的类:
+例如,你可以允许所有以 `org.example.*` 开头的类:
```java
-Fory fory = xxx;
-fory.getClassResolver().setClassChecker(
- (classResolver, className) -> className.startsWith("org.example."));
+Fory fory = Fory.builder()
+ .requireClassRegistration(false)
+ .withTypeChecker((typeResolver, className) -> className.startsWith("org.example."))
+ .build();
```
### AllowListChecker
-Fory 提供了 `org.apache.fory.resolver.AllowListChecker`,这是一个基于允许/禁止列表的检查器,用于简化类检查机制的自定义:
+Fory 提供了 `org.apache.fory.resolver.AllowListChecker`,这是一个基于允许/禁止列表的检查器,可简化类检查机制的定制:
```java
AllowListChecker checker = new AllowListChecker(AllowListChecker.CheckLevel.STRICT);
-ThreadSafeFory fory = new ThreadLocalFory(classLoader -> {
- Fory f = Fory.builder().requireClassRegistration(true).withClassLoader(classLoader).build();
- f.getClassResolver().setClassChecker(checker);
- checker.addListener(f.getClassResolver());
- return f;
-});
checker.allowClass("org.example.*");
+ThreadSafeFory fory = Fory.builder()
+ .requireClassRegistration(false)
+ .withTypeChecker(checker)
+ .buildThreadSafeFory();
```
-你可以使用此检查器或自己实现更复杂的检查器。
+`withTypeChecker` 会在每个新建运行时上立即安装检查器,这也能避免在关闭类注册却没有配置检查器时产生通用启动警告。如果你需要在构建之后替换检查器,仍然可以继续使用 `TypeResolver#setTypeChecker` 或 `ThreadSafeFory#setTypeChecker`。
## 限制最大反序列化深度
-Fory 提供 `ForyBuilder#withMaxDepth` 来限制最大反序列化深度。默认最大深度为 50。
+Fory 提供 `ForyBuilder#withMaxDepth` 用于限制最大反序列化深度。默认最大深度为 50。
-如果达到最大深度,Fory 将抛出 `ForyException`。这可用于防止恶意数据导致堆栈溢出或其他问题。
+当达到最大深度时,Fory 会抛出 `ForyException`。这可用于防止恶意数据导致的栈溢出等问题。
```java
Fory fory = Fory.builder()
@@ -99,14 +100,14 @@ Fory fory = Fory.builder()
## 最佳实践
-1. **在生产环境中始终启用类注册**:使用 `requireClassRegistration(true)`
-2. **使用基于 ID 的注册以获得性能**:数字 ID 比字符串名称更快
-3. **保持一致的注册顺序**:序列化和反序列化端的顺序相同
-4. **设置适当的最大深度**:防止堆栈溢出攻击
-5. **使用 AllowListChecker 进行细粒度控制**:当你需要灵活的类过滤时
+1. **生产环境始终启用类注册**:使用 `requireClassRegistration(true)`。
+2. **优先使用按 ID 注册**:数字 ID 比字符串名称更快。
+3. **保持注册顺序一致**:序列化端和反序列化端必须相同。
+4. **设置合适的最大深度**:防止栈溢出攻击。
+5. **需要细粒度控制时使用 AllowListChecker**:适合灵活的类过滤场景。
## 相关主题
-- [配置选项](configuration.md) - ForyBuilder 安全选项
+- [配置](configuration.md) - ForyBuilder 的安全相关选项
- [自定义序列化器](custom-serializers.md) - 注册自定义序列化器
-- [故障排除](troubleshooting.md) - 常见注册问题
+- [故障排查](troubleshooting.md) - 常见注册问题
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/virtual-threads.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/virtual-threads.md
new file mode 100644
index 000000000..40f46007c
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/java/virtual-threads.md
@@ -0,0 +1,114 @@
+---
+title: 虚拟线程
+sidebar_position: 8
+id: java_virtual_threads
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Apache Fory Java 在虚拟线程工作负载下应使用 `buildThreadSafeFory()`。它会构建一个固定大小的共享 `ThreadPoolFory`,其大小为 `4 * availableProcessors()`。如果你需要不同的固定池大小,请使用 `buildThreadSafeForyPool(poolSize)`。
+
+## 使用二进制输入/输出 API
+
+在使用虚拟线程时,应始终使用 Fory 的二进制输入/输出 API:
+
+- `serialize(Object)` 或 `serialize(MemoryBuffer, Object)`
+- `deserialize(byte[])` 或 `deserialize(MemoryBuffer)`
+
+典型用法:
+
+```java
+ThreadSafeFory fory = Fory.builder()
+ .requireClassRegistration(false)
+ .buildThreadSafeFory();
+
+byte[] bytes = fory.serialize(request);
+Object value = fory.deserialize(bytes);
+```
+
+## 在大量虚拟线程场景下不要使用 Stream API
+
+对于大量依赖虚拟线程的工作负载,不要使用基于 stream 或 channel 的 API:
+
+- `serialize(OutputStream, Object)`
+- `deserialize(ForyInputStream)`
+- `deserialize(ForyReadableChannel)`
+
+这些 API 会在整个阻塞调用期间一直占用一个池化的 `Fory` 实例。在大量虚拟线程场景下,这意味着许多 `Fory` 实例会在等待 I/O 时持续处于占用状态。每个 `Fory` 实例通常会使用大约 `30~50 KB` 内存,因此在阻塞 I/O 期间保留大量实例会很快累积出明显的内存开销。
+
+只有当你的虚拟线程数量至多是几百个,并且这些额外保留的 `Fory` 内存仍然可以接受时,才建议在虚拟线程中使用 stream API。
+
+## 为什么二进制 API 更合适
+
+序列化和反序列化属于 CPU 工作。Fory 本身足够快,因此这部分 CPU 时间通常远短于网络传输时间。
+
+在大多数情况下,你并不需要让网络传输与 Fory 反序列化重叠执行。Fory 反序列化的耗时通常不到网络传输时间的 `1/10`,因此相比尝试通过 Fory 逐步流式处理一个对象图,优化传输路径往往更重要。
+
+大多数 RPC 系统本身也是基于带帧的字节消息,而不是 Java 对象流。例如,gRPC 使用长度定界帧,这与 Fory 的二进制 API 天然契合。
+
+一个适合虚拟线程的模式是:
+
+1. 读取一条完整的带帧消息到字节数组中
+2. 调用 `fory.deserialize(bytes)`
+3. 生成响应对象
+4. 调用 `fory.serialize(response)`
+5. 将响应字节写成下一段带帧数据
+
+## 推荐模式
+
+```java
+byte[] requestBytes = readOneFrame(channel);
+Request request = (Request) fory.deserialize(requestBytes);
+
+Response response = handle(request);
+byte[] responseBytes = fory.serialize(response);
+writeOneFrame(channel, responseBytes);
+```
+
+这种方式让 Fory 只参与高效的 CPU 密集部分,而把阻塞 I/O 留在序列化器之外。
+
+## 超大载荷:分块的长度定界流式处理
+
+对于大多数场景,上述常规的带帧字节模式已经足够。只有在载荷非常大,并且你希望让传输与序列化/反序列化重叠时,才需要考虑分块流式处理。
+
+即便如此,也不要使用 Fory 自带的 stream API。正确做法是:把一个大载荷拆成多个子对象图,将每个子对象图分别序列化为 `byte[]`,然后按以下顺序写出:
+
+1. 帧长度
+2. 分块字节
+
+在虚拟线程中进行反序列化时:
+
+1. 读取帧长度
+2. 精确读取对应字节数
+3. 调用 `fory.deserialize(chunkBytes)`
+
+这样可以让传输按块推进,而 Fory 始终只处理完整的二进制帧。
+
+```java
+for (Object chunk : splitIntoSubGraphs(largePayload)) {
+ byte[] bytes = fory.serialize(chunk);
+ writeFrame(output, bytes);
+}
+
+while (hasMoreFrames(input)) {
+ int length = readLength(input);
+ byte[] bytes = readBytes(input, length);
+ Object chunk = fory.deserialize(bytes);
+ consumeChunk(chunk);
+}
+```
+
+长度定界帧非常常见,gRPC 也使用长度定界帧而不是 Java 对象流,因此这种模式与典型 RPC 和虚拟线程传输模型非常契合。
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/_category_.json b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/_category_.json
similarity index 52%
copy from i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/_category_.json
copy to i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/_category_.json
index c543ab138..2434e92ab 100644
--- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/cpp/_category_.json
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/_category_.json
@@ -1,6 +1,6 @@
{
- "label": "C++",
- "position": 3,
+ "label": "JavaScript",
+ "position": 6,
"collapsible": true,
"collapsed": true
}
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/basic-serialization.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/basic-serialization.md
new file mode 100644
index 000000000..78d3926d3
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/basic-serialization.md
@@ -0,0 +1,219 @@
+---
+title: 基础序列化
+sidebar_position: 1
+id: basic_serialization
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本指南介绍 Apache Fory JavaScript 中的核心序列化 API。
+
+## 创建 `Fory` 实例
+
+```ts
+import Fory from "@apache-fory/core";
+
+const fory = new Fory();
+```
+
+创建一个实例,注册你的 schema,并重复复用它。Fory 会在首次调用 `register` 后缓存生成的序列化器,因此如果每个请求都重新创建实例,就会浪费这部分工作。
+
+## 使用 `Type.struct` 定义 Schema
+
+最常见的方式是先定义 schema,再进行注册。
+
+```ts
+import Fory, { Type } from "@apache-fory/core";
+
+const accountType = Type.struct(
+ { typeName: "example.account" },
+ {
+ id: Type.int64(),
+ owner: Type.string(),
+ active: Type.bool(),
+ nickname: Type.string().setNullable(true),
+ },
+);
+
+const fory = new Fory();
+const { serialize, deserialize } = fory.register(accountType);
+```
+
+## 序列化与反序列化
+
+```ts
+const bytes = serialize({
+ id: 42n,
+ owner: "Alice",
+ active: true,
+ nickname: null,
+});
+
+const value = deserialize(bytes);
+console.log(value);
+// { id: 42n, owner: 'Alice', active: true, nickname: null }
+```
+
+返回的 `bytes` 值是 `Uint8Array`/平台缓冲区,可以通过网络发送或写入存储。
+
+## 根级动态序列化
+
+`Fory` 也支持在不先绑定特定 schema 序列化器的情况下,对动态根值进行序列化。
+
+```ts
+const fory = new Fory();
+
+const bytes = fory.serialize(
+ new Map([
+ ["name", "Alice"],
+ ["age", 30],
+ ]),
+);
+
+const value = fory.deserialize(bytes);
+```
+
+这对动态载荷很方便,但对于稳定接口和跨语言契约,显式 schema 通常更合适。
+
+## 原始值
+
+```ts
+const fory = new Fory();
+
+fory.deserialize(fory.serialize(true));
+// true
+
+fory.deserialize(fory.serialize("hello"));
+// 'hello'
+
+fory.deserialize(fory.serialize(123));
+// 123
+
+fory.deserialize(fory.serialize(123n));
+// 123n
+
+fory.deserialize(fory.serialize(new Date("2021-10-20T09:13:00Z")));
+// Date
+```
+
+### `number` 与 `bigint`
+
+JavaScript 的 `number` 是 64 位浮点数,无法精确表示所有 64 位整数。对于跨语言契约,或任何需要精确整数宽度的场景,请在 schema 中使用显式字段类型:
+
+- `Type.int32()`:32 位整数;使用 JavaScript `number`
+- `Type.int64()`:64 位整数;使用 JavaScript `bigint`
+- `Type.float32()` / `Type.float64()`:浮点数
+
+动态根序列化(即不使用 schema,直接调用 `fory.serialize(someNumber)`)会推断类型,但 API 不保证推断结果稳定。对于任何稳定契约,都应使用 schema。
+
+## 数组、Map 和 Set
+
+```ts
+const inventoryType = Type.struct("example.inventory", {
+ tags: Type.array(Type.string()),
+ counts: Type.map(Type.string(), Type.int32()),
+ labels: Type.set(Type.string()),
+});
+
+const fory = new Fory({ ref: true });
+const { serialize, deserialize } = fory.register(inventoryType);
+
+const bytes = serialize({
+ tags: ["hot", "new"],
+ counts: new Map([
+ ["apple", 3],
+ ["pear", 8],
+ ]),
+ labels: new Set(["featured", "seasonal"]),
+});
+
+const value = deserialize(bytes);
+```
+
+## 嵌套 Struct
+
+```ts
+const addressType = Type.struct("example.address", {
+ city: Type.string(),
+ country: Type.string(),
+});
+
+const userType = Type.struct("example.user", {
+ name: Type.string(),
+ address: Type.struct("example.address", {
+ city: Type.string(),
+ country: Type.string(),
+ }),
+});
+
+const fory = new Fory();
+const { serialize, deserialize } = fory.register(userType);
+
+const bytes = serialize({
+ name: "Alice",
+ address: { city: "Hangzhou", country: "CN" },
+});
+
+const user = deserialize(bytes);
+```
+
+如果嵌套值可能缺失,请将其标记为可空:
+
+```ts
+const wrapperType = Type.struct("example.wrapper", {
+ child: Type.struct("example.child", {
+ name: Type.string(),
+ }).setNullable(true),
+});
+```
+
+## 基于 Decorator 的注册
+
+TypeScript decorator 也受支持。
+
+```ts
+import Fory, { Type } from "@apache-fory/core";
+
+@Type.struct("example.user")
+class User {
+ @Type.int64()
+ id!: bigint;
+
+ @Type.string()
+ name!: string;
+}
+
+const fory = new Fory();
+const { serialize, deserialize } = fory.register(User);
+
+const user = new User();
+user.id = 1n;
+user.name = "Alice";
+
+const copy = deserialize(serialize(user));
+console.log(copy instanceof User); // true
+```
+
+## 可空性
+
+在基于 schema 的 struct 中,字段的可空性需要显式声明。
+
+```ts
+const nullableType = Type.struct("example.optional_user", {
+ name: Type.string(),
+ email: Type.string().setNullable(true),
+});
+```
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/cross-language.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/cross-language.md
new file mode 100644
index 000000000..7aa9eb0d5
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/cross-language.md
@@ -0,0 +1,128 @@
+---
+title: 跨语言序列化
+sidebar_position: 80
+id: cross_language
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Fory JavaScript 与 Java、Python、Go、Rust、Swift 和 C++ 的 Fory 运行时使用相同的二进制格式进行序列化。你可以在 JavaScript 中写入消息,再在 Java 中读取它,反过来也一样,无需额外的转换层。
+
+需要注意:
+
+- Fory JavaScript 运行时只读写跨语言载荷,不支持任何语言原生格式。
+- 当前暂不支持 out-of-band mode。
+
+## 成功完成往返的要求
+
+要让一条消息能在 JavaScript 与另一种运行时之间稳定往返,双方必须满足:
+
+1. 两端具有**相同的类型标识**,即相同的数值 ID,或相同的 `namespace + typeName`
+2. **字段类型兼容**,例如 JavaScript 中的 `Type.int32()` 字段应对应 Java `int`、Go `int32`、C# `int`
+3. **可空性一致**,如果一侧把字段标记为可空,另一侧也应如此
+4. 如果使用 Schema 演进,双方的 `compatible` 模式必须一致
+5. 如果数据包含共享引用或循环引用,双方的引用跟踪配置也必须一致
+
+## 分步说明:从 JavaScript 到其他运行时
+
+1. 在 JavaScript 中使用与其他运行时相同的类型名称或数值 ID 定义 schema
+2. 在两端都注册该 schema
+3. 对齐字段类型、可空性和 `compatible` 设置
+4. 在发布前对真实载荷做端到端测试
+
+JavaScript 侧:
+
+```ts
+import Fory, { Type } from "@apache-fory/core";
+
+const messageType = Type.struct(
+ { typeName: "example.message" },
+ {
+ id: Type.int64(),
+ content: Type.string(),
+ },
+);
+
+const fory = new Fory();
+const { serialize } = fory.register(messageType);
+
+const bytes = serialize({
+ id: 1n,
+ content: "hello from JavaScript",
+});
+```
+
+在另一侧,请使用对应运行时的 API 注册同一个 `example.message` 类型,即相同的名称或相同的数值 ID:
+
+- [Java guide](../java/index.md)
+- [Python guide](../python/index.md)
+- [Go guide](../go/index.md)
+- [Rust guide](../rust/index.md)
+
+## 字段命名
+
+Fory 按字段名匹配字段。当模型在多种语言中定义时,应保持字段名一致,或者至少采用能够在不同语言间无歧义映射的命名方案,例如统一使用 `snake_case`。
+
+当使用 `compatible: true` 进行 Schema 演进时,字段顺序的差异是允许的,但字段名本身仍必须一致。
+
+## 数值类型
+
+JavaScript 的 `number` 是 64 位浮点数,无法与其他语言中的所有整数类型一一对应。因此应使用显式 schema 类型:
+
+- `Type.int32()`:用于 32 位整数,对应 Java `int`、Go `int32`、C# `int`
+- `Type.int64()`:配合 `bigint` 值使用,用于 64 位整数,对应 Java `long`、Go `int64`
+- `Type.float32()` 或 `Type.float64()`:用于浮点数
+
+## 日期与时间
+
+- `Type.timestamp()`:表示一个时间点;往返后仍是 JavaScript `Date`
+- `Type.date()`:表示不带时间的日期;反序列化结果为 `Date`
+- `Type.duration()`:在 JavaScript 中暴露为毫秒数
+
+## 多态字段
+
+`Type.any()` 允许字段在运行时承载不同类型的值,但它在跨语言场景中更难保持一致。只要可能,就应优先使用显式字段 schema。
+
+```ts
+const wrapperType = Type.struct(
+ { typeId: 3001 },
+ {
+ payload: Type.any(),
+ },
+);
+```
+
+## 枚举
+
+枚举成员的**顺序**必须在不同语言间保持一致。Fory 按 ordinal position 而不是按枚举值对枚举进行编码。
+
+```ts
+const Color = { Red: 1, Green: 2, Blue: 3 };
+const fory = new Fory();
+fory.register(Type.enum({ typeId: 210 }, Color));
+```
+
+在每个对端运行时中都应使用相同的类型 ID 或类型名。
+
+## 安全限制
+
+`maxDepth`、`maxBinarySize` 和 `maxCollectionSize` 这些选项用于保护 JavaScript 运行时,防止接收过大载荷。它们不会改变二进制格式,只决定本地运行时愿意接受什么样的数据。
+
+## 相关主题
+
+- [支持的类型](supported-types.md)
+- [Schema 演进](schema-evolution.md)
+- [Xlang 序列化规范](../../specification/xlang_serialization_spec.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/index.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/index.md
new file mode 100644
index 000000000..ae4b5b8f8
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/index.md
@@ -0,0 +1,141 @@
+---
+title: JavaScript 序列化指南
+sidebar_position: 0
+id: index
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Apache Fory JavaScript 让你可以把 JavaScript 和 TypeScript 对象序列化为字节,并再把它们反序列化回来,包括与 Java、Python、Go、Rust、Swift 以及其他 Fory 支持的语言编写的服务进行跨语言互通。
+
+## 为什么选择 Fory JavaScript?
+
+- **跨语言**:可以在 JavaScript 中序列化,在 Java、Python、Go 等语言中反序列化,无需编写胶水代码
+- **高性能**:序列化器代码会在首次注册 schema 时生成并缓存,而不是每次调用时都重新生成
+- **具备引用感知能力**:启用后可支持共享引用和循环对象图
+- **显式 schema**:字段类型、可空性和多态行为通过 `Type.*` builder 或 TypeScript decorator 一次性声明
+- **安全默认值**:可配置的深度、二进制大小和集合大小限制可以拒绝超出预期的大载荷或深层嵌套载荷
+- **现代类型支持**:支持 `bigint`、typed array、`Map`、`Set`、`Date`、`float16` 和 `bfloat16`
+
+## 安装
+
+从 npm 安装 JavaScript 包:
+
+```bash
+npm install @apache-fory/core
+```
+
+可选的 Node.js 字符串快速路径支持由 `@apache-fory/hps` 提供:
+
+```bash
+npm install @apache-fory/core @apache-fory/hps
+```
+
+`@apache-fory/hps` 依赖 Node.js 20+,并且是可选的。如果不可用,Fory 仍可正常工作;只需在配置中省略 `hps`。
+
+## 快速开始
+
+```ts
+import Fory, { Type } from "@apache-fory/core";
+
+const userType = Type.struct(
+ { typeName: "example.user" },
+ {
+ id: Type.int64(),
+ name: Type.string(),
+ age: Type.int32(),
+ },
+);
+
+const fory = new Fory();
+const { serialize, deserialize } = fory.register(userType);
+
+const bytes = serialize({
+ id: 1n,
+ name: "Alice",
+ age: 30,
+});
+
+const user = deserialize(bytes);
+console.log(user);
+// { id: 1n, name: 'Alice', age: 30 }
+```
+
+## 工作原理
+
+Fory 是由 schema 驱动的。你先用 `Type.*` builder 或 TypeScript decorator 描述一次数据结构,然后调用 `fory.register(schema)`。这会返回一个可高频复用、调用开销较低的 `{ serialize, deserialize }` 对。
+
+```ts
+// 1. 定义 schema
+const personType = Type.struct("example.person", {
+ name: Type.string(),
+ email: Type.string().setNullable(true),
+});
+
+// 2. 注册一次
+const fory = new Fory();
+const { serialize, deserialize } = fory.register(personType);
+
+// 3. 按需重复使用
+const bytes = serialize({ name: "Alice", email: null });
+const person = deserialize(bytes);
+```
+
+每个应用创建一个 `Fory` 实例并持续复用即可;如果每个请求都新建实例,就会浪费 schema 注册带来的缓存收益。
+
+## 配置
+
+```ts
+import Fory from "@apache-fory/core";
+import hps from "@apache-fory/hps";
+
+const fory = new Fory({
+ ref: true,
+ compatible: true,
+ maxDepth: 100,
+ maxBinarySize: 64 * 1024 * 1024,
+ maxCollectionSize: 1_000_000,
+ hps,
+});
+```
+
+| 选项 | 默认值 | 说明 |
+| -------------------------- | ----------- | ------------------------------------------------------------------------------------ |
+| `ref` | `false` | 为共享引用或循环对象图启用引用跟踪 |
+| `compatible` | `false` | 允许在不破坏现有消息的前提下新增或删除字段 |
+| `maxDepth` | `50` | 最大嵌套深度,必须 `>= 2`。如果结构嵌套很深,可适当调大 |
+| `maxBinarySize` | 64 MiB | 任意单个二进制字段可接受的最大字节数 |
+| `maxCollectionSize` | `1_000_000` | 任意 list、set 或 map 中可接受的最大元素数 |
+| `useSliceString` | `false` | Node.js 下的可选字符串读取优化。除非做过基准测试,否则保持默认即可 |
+| `hps` | unset | 来自 `@apache-fory/hps` 的可选快速字符串辅助模块(Node.js 20+) |
+| `hooks.afterCodeGenerated` | unset | 用于查看生成后的序列化器代码的回调,对调试很有帮助 |
+
+## 文档导航
+
+| 主题 | 说明 |
+| --------------------------------------------- | ------------------------------------------------------ |
+| [基础序列化](basic-serialization.md) | 核心 API 与日常用法 |
+| [类型注册](type-registration.md) | 数值 ID、名称、decorator 与 schema 注册方式 |
+| [支持的类型](supported-types.md) | 原始类型、集合、时间、枚举与 struct 的映射方式 |
+| [引用](references.md) | 共享引用与循环对象图 |
+| [Schema 演进](schema-evolution.md) | 兼容模式与 struct 演进 |
+| [跨语言](cross-language.md) | 互操作指导与类型映射规则 |
+| [故障排查](troubleshooting.md) | 常见问题、限制项与调试技巧 |
+
+## 相关资源
+
+- [Xlang 序列化规范](../../specification/xlang_serialization_spec.md)
+- [跨语言类型映射](../../specification/xlang_type_mapping.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/references.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/references.md
new file mode 100644
index 000000000..e084bcf2a
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/references.md
@@ -0,0 +1,111 @@
+---
+title: 引用
+sidebar_position: 50
+id: references
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+默认情况下,Fory 会把每个值都当作独立副本处理。如果同一个对象出现在两个字段中,它会被序列化两次;反序列化后,你得到的也是两个彼此独立的副本。以下情况应启用引用跟踪:
+
+- 同一个对象实例会在对象图中的多个位置被引用
+- 数据中包含循环结构,例如一个节点指向自己
+- 往返之后必须保留对象身份
+
+对于普通的树状数据,应保持引用跟踪关闭,因为它会引入少量额外开销。
+
+## 第一步:在 `Fory` 实例上启用引用跟踪
+
+```ts
+const fory = new Fory({ ref: true });
+```
+
+## 第二步:标记可能出现共享引用或循环引用的字段
+
+对于每个值可能被共享或形成循环的字段,都需要在字段 schema 上调用 `.setTrackingRef(true)`:
+
+```ts
+const nodeType = Type.struct("example.node", {
+ value: Type.string(),
+ next: Type.struct("example.node").setNullable(true).setTrackingRef(true),
+});
+```
+
+全局开关和字段级开关必须**同时**启用。缺少任何一个,值都会被复制,而不是按引用恢复。
+
+## 循环自引用示例
+
+```ts
+import Fory, { Type } from "@apache-fory/core";
+
+const nodeType = Type.struct("example.node", {
+ name: Type.string(),
+ selfRef: Type.struct("example.node").setNullable(true).setTrackingRef(true),
+});
+
+const fory = new Fory({ ref: true });
+const { serialize, deserialize } = fory.register(nodeType);
+
+const node: any = { name: "root", selfRef: null };
+node.selfRef = node;
+
+const copy = deserialize(serialize(node));
+console.log(copy.selfRef === copy); // true
+```
+
+## 共享嵌套引用示例
+
+```ts
+const innerType = Type.struct(501, {
+ value: Type.string(),
+});
+
+const outerType = Type.struct(502, {
+ left: Type.struct(501).setNullable(true).setTrackingRef(true),
+ right: Type.struct(501).setNullable(true).setTrackingRef(true),
+});
+
+const fory = new Fory({ ref: true });
+const { serialize, deserialize } = fory.register(outerType);
+
+const shared = { value: "same-object" };
+const copy = deserialize(serialize({ left: shared, right: shared }));
+console.log(copy.left === copy.right); // true
+```
+
+## 何时启用
+
+以下情况建议启用引用跟踪:
+
+- 同一个对象实例会被多个字段重复引用
+- 你的对象图可能存在环
+- 反序列化后对象身份是否保持一致很重要
+
+以下情况建议关闭:
+
+- 数据是普通树结构
+- 你希望获得最低开销
+- 对象身份并不重要
+
+## 跨语言说明
+
+引用跟踪是 Fory 二进制协议的一部分,并且可以跨运行时工作。为了让行为一致,两端都必须启用引用跟踪,并把相同字段标记为引用跟踪字段。
+
+## 相关主题
+
+- [基础序列化](basic-serialization.md)
+- [Schema 演进](schema-evolution.md)
+- [跨语言](cross-language.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/schema-evolution.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/schema-evolution.md
new file mode 100644
index 000000000..adbb202b1
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/schema-evolution.md
@@ -0,0 +1,99 @@
+---
+title: Schema 演进
+sidebar_position: 60
+id: schema_evolution
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+Schema 演进允许不同版本的服务安全地交换消息。也就是说,v2 写入端生成的消息,v1 读取端仍然可以理解,反之亦然。
+
+## 两种模式
+
+- **Schema-consistent 模式**(默认):更紧凑,但双方必须拥有完全相同的 schema。适合所有服务统一升级的场景。
+- **兼容模式**:会写入额外的字段元信息,使读取端能够跳过未知字段并容忍缺失字段。适合独立部署或滚动升级场景。
+
+## 启用兼容模式
+
+```ts
+const fory = new Fory({ compatible: true });
+```
+
+以下情况建议使用:
+
+- 服务会独立发布 schema 变更
+- 较旧的读取端可能会看到较新的载荷
+- 较新的读取端可能会看到字段尚未添加之前产生的旧载荷
+
+## 示例
+
+写入端 schema:
+
+```ts
+const writerType = Type.struct(
+ { typeId: 1001 },
+ {
+ name: Type.string(),
+ age: Type.int32(),
+ },
+);
+```
+
+字段更少的读取端 schema:
+
+```ts
+const readerType = Type.struct(
+ { typeId: 1001 },
+ {
+ name: Type.string(),
+ },
+);
+```
+
+启用 `compatible: true` 后,读取端会忽略自己不认识的字段,并为未知字段填充默认值。
+
+## 为单个 Struct 关闭演进
+
+即使实例启用了 `compatible: true`,你仍然可以为某个特定 struct 关闭演进元信息:
+
+```ts
+const fixedType = Type.struct(
+ { typeId: 1002, evolving: false },
+ {
+ name: Type.string(),
+ },
+);
+```
+
+`evolving: false` 会让该 struct 的消息更小,但**写入端和读取端必须在这个设置上保持一致**。如果一侧以 `evolving: false` 写入,而另一侧按兼容元信息读取,反序列化将失败。
+
+## 何时使用每种模式
+
+| | Schema-consistent | Compatible |
+| ------------------------------- | ----------------- | ------------------- |
+| 服务总是同时更新 | ✔ 最佳选择 | 可用,但有浪费 |
+| 独立部署 | 会出错 | ✔ 最佳选择 |
+| 需要尽可能小的消息 | ✔ | 稍大一些 |
+| 滚动升级 | 有风险 | ✔ 安全 |
+
+## 跨语言要求
+
+兼容模式只能帮你处理类型**字段**层面的 schema 差异。对于类型标识本身,你仍然需要在各端保持一致,即相同的数值 ID 或相同的 `namespace + typeName`。参见 [跨语言](cross-language.md)。
+
+## 相关主题
+
+- [类型注册](type-registration.md)
+- [跨语言](cross-language.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/supported-types.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/supported-types.md
new file mode 100644
index 000000000..0bbbf022f
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/supported-types.md
@@ -0,0 +1,177 @@
+---
+title: 支持的类型
+sidebar_position: 40
+id: supported_types
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页列出 Fory 支持的 JavaScript 和 TypeScript 类型,并说明在跨语言兼容场景下何时需要对类型选择保持明确和谨慎。
+
+## 原始类型与标量类型
+
+| JavaScript 值 | Fory schema | 说明 |
+| ------------------ | ----------------------------------------------------------------------------------- | ---------------------------------------------- |
+| `boolean` | `Type.bool()` | |
+| `number` | `Type.int8()` / `Type.int16()` / `Type.int32()` / `Type.float32()` / `Type.float64()` | 选择与对端语言一致的位宽 |
+| `bigint` | `Type.int64()` / `Type.varInt64()` / `Type.uint64()` | 64 位整数应使用 `bigint` |
+| `string` | `Type.string()` | |
+| `Uint8Array` | `Type.binary()` | 二进制 blob |
+| `Date` | `Type.timestamp()` | 序列化/反序列化结果均为 `Date` |
+| `Date` | `Type.date()` | 只包含日期,不包含时间;反序列化结果为 `Date` |
+| duration(毫秒) | `Type.duration()` | 在 JavaScript 中暴露为毫秒数 |
+| `number` | `Type.float16()` | 半精度浮点数 |
+| `BFloat16` / `number` | `Type.bfloat16()` | 反序列化结果为 `BFloat16` |
+
+## 整数类型
+
+JavaScript 的 `number` 是 64 位浮点数,无法安全表示所有 64 位整数,超过 `Number.MAX_SAFE_INTEGER` 的整数会丢失精度。请使用显式 schema,使其与对端语言期望的位宽一致:
+
+```ts
+Type.int8(); // -128 to 127
+Type.int16(); // -32,768 to 32,767
+Type.int32(); // matches Java int, Go int32, C# int
+Type.varInt32(); // variable-length encoding; smaller for small values
+Type.int64(); // use with bigint; matches Java long, Go int64
+Type.varInt64();
+Type.sliInt64();
+Type.uint8();
+Type.uint16();
+Type.uint32();
+Type.varUInt32();
+Type.uint64(); // use with bigint
+Type.varUInt64();
+Type.taggedUInt64();
+```
+
+**经验法则**:凡是在其他语言中映射为 64 位整数的值,在 JavaScript 侧都应使用 `Type.int64()` 或 `Type.uint64()`,并以 `bigint` 形式传入。
+
+## 浮点类型
+
+```ts
+Type.float16();
+Type.float32();
+Type.float64();
+Type.bfloat16();
+```
+
+当需要与使用低精度数值格式的运行时或载荷互操作时,`float16` 和 `bfloat16` 会很有用。
+
+## 数组与 Typed Array
+
+### 通用数组
+
+```ts
+Type.array(Type.string());
+Type.array(
+ Type.struct("example.item", {
+ id: Type.int64(),
+ }),
+);
+```
+
+它们会映射为 JavaScript 数组。
+
+## 优化过的数值数组
+
+对于数值数组,请使用专门的 typed array schema。它们更紧凑,并且会映射到原生 typed array:
+
+```ts
+Type.boolArray(); // boolean[] in JS
+Type.int16Array(); // Int16Array
+Type.int32Array(); // Int32Array
+Type.int64Array(); // BigInt64Array
+Type.float32Array(); // Float32Array
+Type.float64Array(); // Float64Array
+Type.float16Array(); // number[]
+Type.bfloat16Array(); // BFloat16[]
+```
+
+对于非数值数组或 struct 数组,应改用 `Type.array(elementType)`。
+
+## Map 与 Set
+
+```ts
+Type.map(Type.string(), Type.int32());
+Type.set(Type.string());
+```
+
+它们会映射为 JavaScript `Map` 和 `Set`。
+
+## Struct
+
+```ts
+Type.struct("example.user", {
+ id: Type.int64(),
+ name: Type.string(),
+ tags: Type.array(Type.string()),
+});
+```
+
+Struct 可以以内联方式声明,也可以通过 decorator 声明,或者嵌套在其他 schema 中。
+
+## 枚举
+
+```ts
+Type.enum("example.color", {
+ Red: 1,
+ Green: 2,
+ Blue: 3,
+});
+```
+
+Fory 按对象中的 ordinal position 编码枚举值,而不是按它们的取值进行编码。两端都必须以相同顺序声明枚举成员。与其他语言互操作时,必须保证成员顺序一致,而不仅仅是值相同。
+
+## 可空字段
+
+当字段可能为 `null` 时,请使用 `.setNullable(true)`。
+
+```ts
+Type.string().setNullable(true);
+```
+
+## 动态字段
+
+当字段在运行时可能承载不同类型的值时,请使用 `Type.any()`。
+
+```ts
+const eventType = Type.struct("example.event", {
+ kind: Type.string(),
+ payload: Type.any(),
+});
+```
+
+如果字段类型是已知的,应优先使用显式字段 schema,因为 `Type.any()` 更难在不同语言间保持对齐。
+
+## 引用跟踪字段
+
+当同一个对象实例可能出现在多个字段中,或者你的对象图存在循环时,应为对应字段单独启用引用跟踪:
+
+```ts
+Type.struct("example.node").setTrackingRef(true).setNullable(true);
+```
+
+这需要同时配置 `new Fory({ ref: true })`。参见 [引用](references.md)。
+
+## 扩展类型
+
+对于需要完全自定义编码的类型,可以使用 `Type.ext(...)`,并向 `fory.register(...)` 传入自定义序列化器。这属于高级用法;大多数场景下,标准的 `Type.struct` 已经足够。
+
+## 相关主题
+
+- [基础序列化](basic-serialization.md)
+- [引用](references.md)
+- [跨语言](cross-language.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/troubleshooting.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/troubleshooting.md
new file mode 100644
index 000000000..a4d83c62b
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/troubleshooting.md
@@ -0,0 +1,105 @@
+---
+title: 故障排查
+sidebar_position: 90
+id: troubleshooting
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+本页介绍使用 Fory JavaScript 时常见的问题。
+
+## 无法反序列化非跨语言载荷
+
+Fory JavaScript 运行时只能读取 Fory 的跨语言载荷。如果生产端是 Java 或 Go 服务,并且使用的是语言原生格式,那么 JavaScript 侧无法解码。
+
+修复方式:把生产端切换到跨语言模式。Java 请使用 `.withLanguage(Language.XLANG)`,Go 请使用 `WithXlang(true)`。
+
+## `maxDepth must be an integer >= 2`
+
+这表示你传入了无效的 `maxDepth` 值。它必须是大于等于 2 的正整数。
+
+```ts
+new Fory({ maxDepth: 100 });
+```
+
+只有当你的数据确实存在很深的嵌套时,才应提高这个值。
+
+## `Binary size ... exceeds maxBinarySize`
+
+某个二进制字段或整条消息超过了安全限制。如果这个大小符合预期,且数据源可信,可以提高限制:
+
+```ts
+new Fory({ maxBinarySize: 128 * 1024 * 1024 });
+```
+
+## `Collection size ... exceeds maxCollectionSize`
+
+某个 list、set 或 map 的元素数量超过了配置上限。这通常意味着数据异常地大。如果这是合法场景,可以提高限制:
+
+```ts
+new Fory({ maxCollectionSize: 2_000_000 });
+```
+
+## `Field "..." is not nullable`
+
+你向一个未声明为可空的字段传入了 `null`。修复方式:在字段 schema 上添加 `.setNullable(true)`:
+
+```ts
+const userType = Type.struct("example.user", {
+ name: Type.string(),
+ email: Type.string().setNullable(true), // ← this field can be null
+});
+```
+
+## 反序列化后对象不是同一个实例
+
+默认情况下,Fory 不保留对象身份。两个字段如果指向同一个对象,反序列化后会变成两个彼此独立的副本。
+
+修复方式:同时启用以下**两个**开关:
+
+1. 在实例上配置 `new Fory({ ref: true })`
+2. 在具体字段上调用 `.setTrackingRef(true)`
+
+参见 [引用](references.md)。
+
+## 大整数会以 `bigint` 返回
+
+这是预期行为。对于任何 64 位整数字段,例如 `Type.int64()`、`Type.uint64()`,Fory 都会使用 `bigint`。如果你确实需要 `number`,请使用更小的整数类型,比如 `Type.int32()`,但前提是该值确实能装进 32 位。
+
+## 查看生成的序列化器代码
+
+如果你需要排查 Fory 在底层生成了什么,可以通过 hook 查看生成后的序列化器代码:
+
+```ts
+const fory = new Fory({
+ hooks: {
+ afterCodeGenerated(code) {
+ console.log(code);
+ return code;
+ },
+ },
+});
+```
+
+## `@apache-fory/hps` 安装失败
+
+`@apache-fory/hps` 是一个可选的 Node.js 加速模块。如果它安装失败,例如当前平台不支持原生模块,只需把它从依赖中移除即可。即使没有它,Fory 也能正常工作。
+
+## 相关主题
+
+- [基础序列化](basic-serialization.md)
+- [引用](references.md)
+- [跨语言](cross-language.md)
diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/type-registration.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/type-registration.md
new file mode 100644
index 000000000..5fa242e88
--- /dev/null
+++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/javascript/type-registration.md
@@ -0,0 +1,200 @@
+---
+title: 类型注册
+sidebar_position: 30
+id: type_registration
+license: |
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+---
+
+你要序列化的每个 struct 和 enum,在使用前都必须先注册到 `Fory` 实例中。注册会告诉 Fory:如何在消息中标识该类型,以及如何对其进行编码和解码。
+
+## 注册 Struct
+
+你可以使用数值 ID 或名称来标识一个 struct。选择一种策略,并在所有共享这类消息的语言中保持一致。
+
+### 按数值 ID 注册
+
+编码更紧凑。当团队规模较小、可以协调 ID 分配时,这是很好的选择。
+
+```ts
+const userType = Type.struct(
+ { typeId: 1001 },
+ {
+ id: Type.int64(),
+ name: Type.string(),
+ },
+);
+
+const fory = new Fory();
+const { serialize, deserialize } = fory.register(userType);
+```
+
+所有读写该类型的运行时都必须使用同一个数值。
+
+### 按名称注册
+
+更容易跨团队协同,但消息中的元信息会稍大一些。
+
+```ts
+const userType = Type.struct(
+ { typeName: "example.user" },
+ {
+ id: Type.int64(),
+ name: Type.string(),
+ },
+);
... 68039 lines suppressed ...
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org