DerrickBrayanClayton / protobuf-net

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

Exception when serializing enum values with Flags attribute #102

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When trying to serialize a bit field enum value (where the enum has the 
Flags attribute on it), I get this error message:

> The value {0} has no wire-representation for property {1}

This only appears to happen if the enum value contains multiple flag 
values.

Feel free to contact me at jpage@fender.com if you'd like more information.

==============

> What steps will reproduce the problem?

1. Create a "flags" enum, like this:

       [DataContract, Flags]
       public enum TestEnum
       {
           [EnumMember]
           None = 0,

           [EnumMember]
           Animal = 1,

           [EnumMember]
           Vegetable = 2,

           [EnumMember]
           Mineral = 4
       }

2. Create a class with a value of that enum type:

       [DataContract]
       public class TestClass
       {
           [DataMember(Order=1)]
           public TestEnum TestProperty { get; set; }
       }

3. Try to serialize an object of that class:

       Serializer.Serialize(
           new TestClass { 
               TestProperty = TestEnum.Animal | TestEnum.Vegetable } );

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

I expect that the property should be serialized and deserialized.  Instead, 
we get the exception.

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

protobuf-net version 1.0.0.282 under Silverlight, running on Windows XP.

Original issue reported on code.google.com by jacob.h....@gmail.com on 1 Apr 2010 at 10:37

GoogleCodeExporter commented 8 years ago

Original comment by marc.gravell on 22 Apr 2010 at 9:20

GoogleCodeExporter commented 8 years ago

Original comment by marc.gravell on 13 Jun 2011 at 9:06

GoogleCodeExporter commented 8 years ago
What's the next compatible version that fixes this issue?

Original comment by ces...@mindtouch.com on 4 Apr 2013 at 12:18