a253560600 / protobuf-net

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

serialization of fixed-length integers #61

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
email: s.volchkov@gmail.com

protobuf-net seems to serialize fixed-length integer types (fixed32,
fixed64, sfixed32, sfixed64) as varints.

Example:

.proto file:

message Foo
{
    required fixed64 bar = 1;
}

c# code attached; the main part:

            foo.Foo f = new foo.Foo();
            f.bar = 42;

            MemoryStream ms = new MemoryStream();
            ProtoBuf.Serializer.Serialize(ms, f);

This produced two byte sequence:

 08 2A

(first byte denoting varint field with tag 1, and second containing the
payload)

I thought the likely reason was that in the generated c# file, the
corresponding property was marked with "DataFormat =
ProtoBuf.DataFormat.Default" option.

After some changes in csharp.xslt (see attached patch), everything worked fine:

 09 2A 00 00 00 00 00 00 00

Observed on the latest release, r258, .net framework 2.0 and 3.5sp1.

Original issue reported on code.google.com by s.volchkov on 1 Jul 2009 at 8:01

Attachments:

GoogleCodeExporter commented 9 years ago
Wow; that is embarrassing. Investigating now...

Original comment by marc.gravell on 1 Jul 2009 at 8:36

GoogleCodeExporter commented 9 years ago
fixed r261; huge apologies

Original comment by marc.gravell on 1 Jul 2009 at 8:50