Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google's Protocol Buffers in c#

We are looking at using Google's Protocol Buffers to handle serialization between a c++ application and a c# application via networking.

My question is, I've found a couple of different verisions for c#. Both look pretty good, however, does anyone know what is different (if anything) between the two

  1. protobuf-net
  2. jskeet / dotnet-protobufs
like image 225
photo_tom Avatar asked Oct 11 '10 16:10

photo_tom


People also ask

What is protocol buffer in C#?

Protobuf is used to serialize data structure efficiently. It is faster, smaller & simpler than XML. Protobuf is useful in developing programs to communicate with each other over a wire and it is created by Google. It helps us in creating gRPC services.

Does Google use protobuf?

Protocol buffers, or Protobuf, is a binary format created by Google to serialize data between different services. Google made this protocol open source and now it provides support, out of the box, to the most common languages, like JavaScript, Java, C#, Ruby and others.

How do Google Protocol Buffers work?

Protocol buffers provide a language-neutral, platform-neutral, extensible mechanism for serializing structured data in a forward-compatible and backward-compatible way. It's like JSON, except it's smaller and faster, and it generates native language bindings.

What languages does protobuf support?

Protocol buffers currently support generated code in Java, Python, Objective-C, and C++. With our new proto3 language version, you can also work with Kotlin, Dart, Go, Ruby, and C#, with more languages to come.


1 Answers

Sure; dotnet-protobufs is a port of the java version, so shares a very similar API and approach to the core google implementation; code-gem, immutability, etc.

Protobuf-net is byte compatible, but is a complete from-scratch re-implementation, following standard .NET idioms - so is familiar to users of XmlSerializer etc. It also works against mutable objects (and immutable depending on the setup, and structs in v2), and has optional hooks for WCF, remoting, etc.

Both can work from .proto (arguably dotnet-protobufs is better at this than protobuf-net); but protobuf-net can work against existing .net poco/DTO etc without .proto or any codegen.

Additionally, protobuf-net offers things like inheritance support, but you might not choose to use that in your scenario as it doesn't map as easily to .proto definitions.

like image 200
Marc Gravell Avatar answered Sep 17 '22 16:09

Marc Gravell