Closed GoogleCodeExporter closed 8 years ago
Hi; I'll update SO later (work time etc), but ultimately the protocol buffers
wire
format doesn't provide any scope for [Flags] enums - it enforces enum values
against
the discreet set. I could allow this easily enugh, but:
- I'd probably have to disable enum mappings in this case, or do a lot of ugly bit-
matching work
- it would not be strictly compatible
An easier way of doing this may be to do a shim in your code:
public MyEnum MyValue {get;set;}
[ProtoMember(12)]
private int MyValueWire {
get {return (int)MyValue;}
set {MyValue = (MyEnum)value;}
}
The other alternative would be to add a flag that works like the above on your
behalf; treating it as an int rather than an enum.
Original comment by marc.gravell
on 30 Sep 2009 at 7:07
Hi Marc,
Thanks for the tips. However, would it be possible to bump up the priority on
this one?
I wouldn't mind having a flag that would auto-cast the enum to an int.
Original comment by stecy.d...@gmail.com
on 8 Oct 2009 at 7:55
I'll see if I can add something to MemberSerializationOptions
Original comment by marc.gravell
on 9 Oct 2009 at 5:51
Actually, I guess I could apply this by default for [Flags] enums (since such
enums
won't really work at the minute, it isn't a huge breaking change - and even
then it
assumes no [ProtoEnum] overrides, so a corner-case when it breaks)
Original comment by marc.gravell
on 9 Oct 2009 at 5:53
Mark with DataFormat = DataFormat.TwosComplement, in r274
Original comment by marc.gravell
on 9 Oct 2009 at 6:37
So quick!
Thanks, I'll be trying this next week.
Original comment by stecy.d...@gmail.com
on 9 Oct 2009 at 9:35
Original issue reported on code.google.com by
stecy.d...@gmail.com
on 29 Sep 2009 at 9:15