Open GoogleCodeExporter opened 8 years ago
[deleted comment]
looks like nullable enums cannot be serialized, it still throws the cast
exception with
the original code
Original comment by sangeeta...@gmail.com
on 17 Feb 2010 at 1:25
I'll investigate; thanks.
Original comment by marc.gravell
on 17 Feb 2010 at 7:48
I have a fix for this issue.Let me know if its good enough. Basically I fork
off
creating a new "PropertyNullableEnum" serializer for it, that serializes a byte
at the
beginning indicating if the enum has value or not and then serializing the
actual value
as int.
Original comment by sangeeta...@gmail.com
on 23 Feb 2010 at 1:07
Attachments:
I'll take a look, but adding an extra byte sounds like it is a breaking change.
I'm
sorry I haven't managed to get to this yet, but I've swamped with other work.
I've
bumped this up my list.
Original comment by marc.gravell
on 23 Feb 2010 at 5:18
I finally got some time to look at this, but cannot reproduce (see below). What
do I
need to reproduce this?
using System;
using ProtoBuf;
[ProtoContract]
class Data
{
public enum Foo { A, B, C }
[ProtoMember(1)]
public Foo? Bar { get; set; }
static void Main()
{
Data data = new Data();
data.Bar = Foo.A;
data = Serializer.DeepClone(data);
Console.WriteLine(data.Bar);
data.Bar = null;
data = Serializer.DeepClone(data);
Console.WriteLine(data.Bar);
data.Bar = Foo.B;
data = Serializer.DeepClone(data);
Console.WriteLine(data.Bar);
}
}
Original comment by marc.gravell
on 5 Mar 2010 at 6:07
Original issue reported on code.google.com by
sangeeta...@gmail.com
on 16 Feb 2010 at 3:27