美文网首页
在 C# 中使用 Google Protocol Buffer

在 C# 中使用 Google Protocol Buffer

作者: 程序员小张 | 来源:发表于2017-04-28 22:43 被阅读278次

Version protobuf2, protobuf3

C# 下 protobuf 有 3 个版本

  1. 仅支持 protobuf2 的 jskeet

原本是 jskeet/protobuf-csharp-port 第三方支援的,
但是这个库当前已经废弃了.
这个版本仅仅支持 protobuf2.

  1. 仅支持 protobuf3 的 Google 官方库

jskeet/protobuf-csharp-port 废弃之后, google 接管过来了

现在 C# 也并入了 google 的官方支持
google/protobuf
这个版本支持了protobuf3, 但是对protobuf2不兼容.

  1. protobuf-net

Google官方的protobuf有个缺点, 就是无法判断一个 Field 是否设置
-- 缺少 has*_function().
包括Unity项目在内的所有项目所使用的protobuf都采用了这个库.
这个库的序列化/反序列化等提供的 API 和 Google 的完全不一样.

可是, 相比 Google 版本提供了很棒的 ToString() 方法,
这个版本没有提供. 在调试输出时比较麻烦.

相关文章

网友评论

      本文标题:在 C# 中使用 Google Protocol Buffer

      本文链接:https://www.haomeiwen.com/subject/bfgazttx.html