Protobuf-net code generator

I am using Google Proto Buffers in my project and it is very nice how protoc.exe for windows generates header and source files for serialization / deserialization. I need a protobuf.net code generator. So, for example, if I am a Person class, I first need to define it in the .proto file. Then when I run protoc.exe on it, it will give me .h and .c files. But then manually, I have to do the following for the Person class:

[ProtoContract]
class Person {
    [ProtoMember(1)]
    public int Id {get;set;}
    [ProtoMember(2)]
    public string Name {get;set:}
    [ProtoMember(3)]
    public Address Address {get;set;}
}
[ProtoContract]
class Address {
    [ProtoMember(1)]
    public string Line1 {get;set;}
    [ProtoMember(2)]
    public string Line2 {get;set;}
}

      

And I want everything to be automated. So, technically, I would like to provide a .proto file for the Person class and get the above output in return. I do NOT want to do manual work. I can write this tool myself. But if there is already a tool that is widely used, I would rather use it instead of reinventing the wheel.

+3


source to share


1 answer


There is a C # protobuff generator here:

https://code.google.com/p/protobuf-csharp-port/wiki/ProtoGen



It can output protobin from the protoc.exe file, or it can take .proto files and transparently call protoc for you, then converts the output to C #. It's open source, so if you need to customize how it generates classes, you can.

+2


source







All Articles