When setting the field number of each serialization and using Base128 the
reading of a message can be skipped, but this doesn't work with the Fixed32 or
Fixed32BigEndian prefix style.
The last console.write will return "Second String" in this case:
var typeModel = TypeModel.Create();
var first = "First";
var second = "Second String";
var s = new MemoryStream();
typeModel.SerializeWithLengthPrefix(s, first, first.GetType(),
PrefixStyle.Base128, 1);
typeModel.SerializeWithLengthPrefix(s, second, second.GetType(),
PrefixStyle.Base128, 2);
s.Seek(0, SeekOrigin.Begin);
var newSecond = (string)typeModel.DeserializeWithLengthPrefix(s, null,
typeof(string), PrefixStyle.Base128, 2);
Console.WriteLine(newSecond);
But if I change PrefixStyle to Fixed32 or Fixed32BigEndian the console output
is "Second". Of course in a complex example the deserialization throws an
exception.
typeModel.SerializeWithLengthPrefix(s, first, first.GetType(),
PrefixStyle.Fixed32, 1);
typeModel.SerializeWithLengthPrefix(s, second, second.GetType(),
PrefixStyle.Fixed32, 2);
s.Seek(0, SeekOrigin.Begin);
var newSecond = (string)typeModel.DeserializeWithLengthPrefix(s, null,
typeof(string), PrefixStyle.Fixed32, 2);
Console.WriteLine(newSecond);
Original issue reported on code.google.com by lukas.bu...@gmail.com on 30 Nov 2011 at 12:45
Original issue reported on code.google.com by
lukas.bu...@gmail.com
on 30 Nov 2011 at 12:45