Protobuf long fields (sint64) are all doubled (x2) [solved]

I am seeing something very strange when deserializing protobuf messages. In the proto file a class defines a series of sint64 properties, which in C# map to Int64 --> long; however, when I deserialize the messages all of my longs are x2 of the correct value received, and the other properties are ok.

Defining them as ulong instead does not affect the result … needless to say I am somewhat perplexed since the other fields deserialize correctly.

Has anyone else seen something like this? (SS v5.4 & protobufnet v2.4)

var bytes = Convert.FromBase64String(e.Data);
var fooItem = bytes.FromProtoBuf<Foo>();


I’ll respond to my own question here because the posts cannot be deleted. The issue is related to ZigZag encoding which is not enabled by default. Add this attribute to your fields to which it applies:

[ProtoMember(n, DataFormat = DataFormat.ZigZag)]

1 Like