简体   繁体   中英

Is it possible to use Google Protocol Buffers 2.6.1 with C#?

I have a project where I am using Google Protocol Buffers 2.6.1 for about two years now. I know that C# is supported in Google Protocol Buffers 3.0.0, but I don't want to migrate my protocol to a newer version at the moment. I tried to find a way to generate C# files from my .proto file but I didn't succeed.

Is it possible to use Google Protocol Buffers 2.6.1 with C#?

Check out this repo .

It states:

This repo was originally exported from http://code.google.com/p/protobuf-csharp-port , and represents the latest "legacy" version of protobuf-csharp-port.

This project has now been folded into the main Google Protocol Buffers project, and is being revamped to support proto3. It is not expected to be fully backwardly-compatible with the code in this repo - in particular, some of the C#-specific options may not be supported in the new codebase, and some of the generated code may differ. A new major version offers an opportunity to spring-clean, as it were.

In ~\\protobuf-csharp-port-2.4.1.555\\src\\ProtoGen\\ProtocGenCs.cs You've got example in comment:

// Usage example:
//   protoc.exe
//     --plugin=path\to\protoc-gen-cs.exe
//     --cs_out="-generated_code_attributes=true umbrella_namespace=TutorialProto :."
//     --proto_path=.\protos\
//     protos\tutorial\addressbook.proto

I have been consuming this repo It is based on protobuf protocol. Works well on production version of our product.

The Google C# implementation supports proto3; protobuf-net supports both proto2 and proto3. So if you need proto2 usage, you may wish to consider protobuf-net.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM