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
commit 417a4de83062e114cad44d28248cef1d24b0f50e Author: chaokunyang <[email protected]> AuthorDate: Wed May 27 08:54:12 2026 +0000 π synced local 'docs/guide/' with remote 'docs/guide/' --- docs/guide/csharp/schema-metadata.md | 29 ++++++++++++++++++++++++++++- docs/guide/csharp/supported-types.md | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/guide/csharp/schema-metadata.md b/docs/guide/csharp/schema-metadata.md index 37ebd33a76..52ae4cea85 100644 --- a/docs/guide/csharp/schema-metadata.md +++ b/docs/guide/csharp/schema-metadata.md @@ -19,7 +19,7 @@ license: | limitations under the License. --- -This page covers field-level serializer configuration for C# generated serializers. +This page covers schema metadata for C# generated serializers. ## `[ForyStruct]` and `[ForyField]` @@ -81,6 +81,33 @@ Dense array fields use `S.Array<TElement>`, for example `S.Array<S.Int32>` or `S Nullability comes from the C# carrier type. Use `List<ulong?>` for nullable list elements and `NullableKeyDictionary<TKey, TValue>` when a map needs nullable keys. +## `[ForyUnion]` and `[ForyCase]` + +Generated union cases use `[ForyCase]` for both the stable case ID and optional +case payload schema type. Do not put `[ForyField]` on union case payload +members. Known case record names use PascalCase FDL case names; payload types +use qualified references when needed to avoid name conflicts. + +```csharp +using Apache.Fory; +using S = Apache.Fory.Schema.Types; + +[ForyUnion] +public abstract partial record Shape +{ + private Shape() {} + + [ForyCase(0)] + public sealed partial record UnknownCase(int CaseId, object? Value) : Shape; + + [ForyCase(1)] + public sealed partial record Circle(global::example.Circle Value) : Shape; + + [ForyCase(2, Type = typeof(S.Fixed<S.Int32>))] + public sealed partial record Code(int Value) : Shape; +} +``` + ## Nullability and Reference Tracking - Field nullability comes from C# type nullability (`string?`, nullable value types, etc.). diff --git a/docs/guide/csharp/supported-types.md b/docs/guide/csharp/supported-types.md index e93b592216..3148694ade 100644 --- a/docs/guide/csharp/supported-types.md +++ b/docs/guide/csharp/supported-types.md @@ -76,7 +76,7 @@ This page summarizes built-in and generated type support in Apache Foryβ’ C#. ## User Types -- `[ForyStruct]` classes/structs via source-generated serializers, plus `[ForyEnum]` enums and `[ForyUnion]` union subclasses +- `[ForyStruct]` classes/structs via source-generated serializers, plus `[ForyEnum]` enums and `[ForyUnion]` ADT records - Custom serializer types registered through `Register<T, TSerializer>(...)` - `Union` / `Union2<...>` typed union support --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
