Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate .proto files from Protocol Buffers .NET code?

So having our classes with attributes in folder how to generate .proto markup files out from them (to get for example C++ code)?

like image 262
myWallJSON Avatar asked Dec 06 '12 12:12

myWallJSON


People also ask

How do I create a .proto file?

proto file are simple: you add a message for each data structure you want to serialize, then specify a name and a type for each field in the message. Here is the . proto file that defines your messages, addressbook. proto .

What does Protobuf generate?

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.

How are Protobufs encoded?

Protobuf encodingA Protobuf message is structured as a collection of key/value pairs, with the numeric tag as the key and the corresponding field as the value.


1 Answers

By "classes with attributes", do you mean attributes suitable for protobuf-net? If so, protobuf-net has a GetProto method which will provide the schema based on a root type:

string proto = Serializer.GetProto<SomeType>();

Despite the rumors to the contrary, this method in v2 has been re-implemented for quite some time now.

like image 61
Marc Gravell Avatar answered Oct 06 '22 04:10

Marc Gravell