How to choose between protobuf-csharp-port and protobuf-net

前端 未结 5 1120
一生所求
一生所求 2020-12-07 12:15

I\'ve recently had to look for a C# porting of the Protocol Buffers library originally developped by Google. And guess what, I found two projects owned both by two very well

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 12:56

    I agree with Jon's points; if you are coding over multiple environments, then his version gives you a similar API to the other "core" implementations. protobuf-net is much more similar to how most of the .NET serializers are implemented, so is more familiar (IMO) to .NET devs. And as Jon notes - the raw binary output should be identical so you can re-implement with a different API if you need to later.

    Some points re protobuf-net that are specific to this implementation:

    • works with existing types (not just generated types from .proto)
    • works under things like WCF and memcached
    • can be used to implement ISerializable for existing types
    • supports inheritance* and serialization callback methods
    • supports common patterns such as ShouldSerialize[name]
    • works with existing decorated types (XmlType/XmlElement or DataContract/DataMember) - meaning (for example) that LINQ-to-SQL models serialize out-of-the-box (as long as serialization is enabled in the DBML)
    • in v2, works for POCO types without any attributes
    • in v2, works in .NET 1.1 (not sure this is a huge selling feature) and most other frameworks (including monotouch - yay!)
    • possibly (not yet implemented) v2 might support full-graph* serialization (not just tree serialization)

    (*=these features use 100% valid protobuf binary, but which might be hard to consume from other languages)

提交回复
热议问题