Is it right to use List as counterpart of the repeated field in protobuf? I'm trying this and always got exception:
Invalid wire-type; this usually means you have over-written a file without truncating or setting the length; see Using Protobuf-net, I suddenly got an exception about an unknown wire-type
The whole buffer is (the first msg, next which arrive are appended to this): 9 8 5 26 5 24 238 98 32 1
java protobuf file:
package XXX;
option java_package = "XXX";
option java_outer_classname = "Protos";
option optimize_for = SPEED;
message V3DDelta {
optional int32 bid = 1;
optional int32 bidSize = 2;
optional int32 ask = 3;
optional int32 askSize = 4;
}
message Request {
optional int32 type = 1;
optional string request = 2;
}
message Response {
optional int32 type = 1;
optional string response = 2;
repeated V3DDelta v3dDelta = 3;
}
and protbuf-net classes:
[ProtoContract]
public class V3DDelta {
[ProtoMember(1)]
public double bid { get; set; }
[ProtoMember(2)]
public int bidSize { get; set; }
[ProtoMember(3)]
public double ask { get; set; }
[ProtoMember(4)]
public int askSize { get; set; }
}
[ProtoContract]
public class Request {
[ProtoMember(1)]
public int Type { get; set; }
[ProtoMember(2)]
public string Rq { get; set; }
}
[ProtoContract]
public class Response {
[ProtoMember(1)]
public int Type { get; set; }
[ProtoMember(2)]
public string Rsp { get; set; }
[ProtoMember(3)]
public List<V3DDelta> v3dDelta { get; set; }
public Response() {
v3dDelta = new List<V3DDelta>();
}
}
I tried V3DDelta[] but result is the same. Reading message:
Response rsp = Serializer.DeserializeWithLengthPrefix<Response>(rcvstream, PrefixStyle.Base128);
and in java message is send using writeDelimitedTo. Buffer in c# is exactly the same as in java. When there was na v3dDelta field everything works as expected.