zhejiushizhuce / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
0 stars 0 forks source link

Int64 in Proto definition is compiled as long in C# #151

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
timothy parez at gmail dot com
==============

1. Has a protocol message definition with an Int64
   --> optional int64 Size = 2 [default = 0];
2. Generate the cs file

What is the expected output? What do you see instead?

I'd expect the field to be defined as a ulong,
but instead it's defined as long.

I'm not sure you might consider this a bug,
and perhaps it's related to the fact that not all languages
support ulong, but it can cause some problems when working with large values.

What version of the product are you using? On what operating system?

protobuf-net-VS9 , Windows 7

Please provide any additional information below.

Original issue reported on code.google.com by timothyp...@gmail.com on 1 Feb 2011 at 11:31

GoogleCodeExporter commented 9 years ago
In line with the table here: 
http://code.google.com/apis/protocolbuffers/docs/proto.html, int64 is treated 
as a **signed** 64-bit, but using twos complement (meaning: negative is 
expensive). For ulong , using uint64 in the proto. For long (but without the 
expensive negatives) use sint64. There is also fixed64 and sfixed64 if you want 
constant length (on the wire).

Original comment by marc.gravell on 2 Feb 2011 at 8:12