1

I am trying to generate C# classes for my message and was able to do so with the help of the online generator here. But I wanted to try and get this working from the command line with the help of the command-line tool but have not been able to get it to work even once - I get the help text indicating that my command was incorrect, although I am not sure what it is missing. I tried looking around for examples on Stackoverflow and mimicked my command with 'protoc'(which has a similar option list but surprisingly worked!) but it could not generate the classes because of an issue with importing bcl.Guid. Could you please point me to some examples of how to use this or correct what is wrong in my command below?

protogen --proto_PATH=C:\Users\xxxx\source\repos\ProtoBufWithMessages\ProtoBufWithMessages --csharp_out=C:\Users\xxxx\source\repos\ProtoBufWithMessages\ProtoBufWithMessages\src +langver=6.0 +names=auto +oneof=default +listset=yes C:\Users\xxxx\source\repos\ProtoBufWithMessages\ProtoBufWithMessages\xxxxx.proto
Sai
  • 682
  • 2
  • 12
  • 35

1 Answers1

1

Sorry, I was using --proto_PATH instead of --proto_path. Did not think this would be case sensitive.

Sai
  • 682
  • 2
  • 12
  • 35
  • Hmmm; question: is it case sensitive for `protoc`? If it isn't, I'll update `protogen` to agree – Marc Gravell Feb 18 '19 at 20:57
  • It does seem case sensitive for protoc as well, looks like I might have used IPATH with protoc to get it to work and then forgot to change it back to lower case for proto_path with protogen. And maybe IPATH did not work with Protogen due to some other issue in my command. – Sai Feb 18 '19 at 22:26
  • if it has identical case-sensitivity between `protogen` and `protoc`, then IMO the best thing to do here would be : no change – Marc Gravell Feb 19 '19 at 08:35
  • Yes, I agree with that – Sai Feb 19 '19 at 15:35
  • @MarcGravell Is it possible to use protogen to generate classes in Java or another language apart from C#/VB? – Sai Feb 20 '19 at 16:36
  • no, protogen is specifically intended for use with protobuf-net; if you want to target other platforms, or the google version on .NET, you'll want to use `protoc`; the website implementation simply includes both :) – Marc Gravell Feb 20 '19 at 16:44
  • Thanks for the super quick response, it is a breeze to generate .proto files in ProtoBuf-net by calling GetProto on the serializer. Many thanks to your wonderful work! I am not sure if Google's serializer exposes the GetProto method. I can't find much on their language/developer guide. Are you aware if Google's serializer supports it? – Sai Feb 20 '19 at 16:54
  • no; Google is very "contract first", so they'd always write the .proto schema first and generate code from it; protobuf-net supports "contract first" and "code first" – Marc Gravell Feb 20 '19 at 18:23