跳到主要内容
版本:0.17

支持的类型

本页汇总 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# 类型编码类型
DateOnlyDate
DateTimeTimestamp
DateTimeOffsetTimestamp
TimeSpanDuration

用户类型

  • 通过 source generator 生成序列化器的 [ForyObject] 类、结构体、枚举
  • 通过 Register<T, TSerializer>(...) 注册的自定义序列化器类型
  • Union / Union2<...> 强类型联合支持

动态类型

通过 Serialize<object?> / Deserialize<object?> 处理动态对象载荷时,支持:

  • 基础值和对象值
  • 动态列表、集合、映射
  • 嵌套的动态结构

说明

  • 用户自定义类型应显式注册。
  • 跨语言使用时,请遵循 xlang 指南

相关主题