Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am incorporating Google Proto Buffers into my project and it is really nice how protoc.exe for windows generates header and source files for serialization/deserialization. I need protobuf.net code generator. So, for example if I a class Person, I first need to define it in the .proto file. Then when I run protoc.exe on it, it will give me the .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 automated. So, technically I would want to give the .proto file for class Person and get the above output in return. I do NOT want to do manual work. I can write that tool myself. But if there is already a tool that is widely used, I would prefer to use that one instead of reinventing the wheel.

share|improve this question
up vote 1 down vote accepted

There is a C# protobuf generator here:

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.