katit
katit

Reputation: 17915

Protobuf-net and .proto file?

I'm going to use protobuf-net library with my WCF services. Clients is Java-Android and I work with proto files on that side.

Should I manually code classes on .NET side or protobuf-net somehow supports .proto files?

Upvotes: 2

Views: 2111

Answers (2)

Marc Gravell
Marc Gravell

Reputation: 1063338

If you are working from interop, then starting from .proto is the best option. For protobuf-net, there is a command-line tool "protogen", and a VS IDE add-in, that allow you to create protobuf-net compatible classes from .proto, similar to how you generate the code for other platforms. Both are available on the protobuf-net project site. If you already have classes, there is also some support for generating .proto from protobuf-net classes, but this is incomplete (indeed, in terms of v2 I only wrote it last night, so it is not in an official download yet).

If you are using cross-platform, you might also want to consider protobuf-csharp-port. This is a separate and parallel implementation by Jon, which retains a similar API to the Java API. You might find having a similar API between platforms to be be convenient.

Upvotes: 6

Daniel Pryden
Daniel Pryden

Reputation: 60987

Since you're interoperating with Java, you shouldn't write .NET classes -- instead, you should generate C# classes from the .proto files.

I haven't used protobuf-net (although I've used the Java protobuf extensively), but supposedly there's a Visual Studio tool to automatically generate C# code from .proto files. There is also apparently a command line tool, but it seems that may not always be available.

Upvotes: 1

Related Questions