How does Protobuf-net support for Dictionary/KeyValuePair works?

前端 未结 2 604
庸人自扰
庸人自扰 2021-01-14 01:17

I am trying to understand protobuf-net\'s Dictionary/KeyValuePair support. We would like to use the underlying binary stream and the generated proto file from java, but the

相关标签:
2条回答
  • 2021-01-14 01:32

    To get this for work add a new message to the generated .proto file that looks like this.

    message Pair_String_Int32 {
     required string Key = 1;
     required int32 Value = 2;    
    }
    

    Then protoc will be able to create the corresponding code for Java.

    0 讨论(0)
  • 2021-01-14 01:43

    I can check later (I'm on iPod at the moment) but I believe is it simply a "repeated" set of a dummy type with members key=1 value=2 (using the default types for each - so c# string maps to proto string etc). I am in the process of re-implementing GetProto for v2, so I'll try to ensure these dummy types are included in the output.

    0 讨论(0)
提交回复
热议问题