What NuGet package should I use between protobuf-net and google.protobuf for a new .net core app?

3.2k views Asked by At

What NuGet package should I use between protobuf-net and google.protobuf for a new .net core app?

  • It is for "Code first", not contract first.
  • It is actually only for C# but would be great if more languages could easily read the format but not a must. I would favor performance over portability for binary serialization. I will also use XML or Json for portability (which for my opinion is better suited for portability although a lot slower).
1

There are 1 answers

8
Marc Gravell On BEST ANSWER

With the edit, this becomes more answerable; first let's consider the options shown here, plus the Google implementation, in the context of the constraints in the question:

  1. Google.Protobuf - the reference implementation
  • + solid, dependable, well-maintained
  • - fundamentally "contract first" (unmanaged parser/generator), proto3 only
  1. protobuf-csharp-port
  • - strictly legacy, this effectively became Google.Protobuf; do not use
  1. SilentOrbit/protobuf
  • - fundamentally "contract first" (managed parser/generator)
  • (honestly, I don't know a lot about this one, so I'm not going to comment much for or against)
  1. protobuf-net
  • + "code first" or "contract first" (optional managed parser/generator)
  • + "code first" is usable to any .NET language; .proto schemas can be generated from code for use with any other platform/language (marked + because this is a non-essential nice to have, according to the question)
  • + reasonably well maintained (it isn't my day job, but I try!)

So; given that the question says:

It is for "Code first", not contract first.

It seems to become a very simple selection process, with protobuf-net being the only horse in that race. In terms of .NET Core: protobuf-net is fully up to date with .NET Core, including being optimized for the span APIs and looking ahead to .NET 5 / C# 9 features.

As a side note: if you're starting green-field, I would recommend using the v3 versions of protobuf-net and using the highest currently defined CompatibilityLevel