zhejiushizhuce / protobuf-net

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

Enum member doesn't deserialized correctly #177

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Please include an e-mail address if this might need a dialogue!
==============

What steps will reproduce the problem?
1. using protobuf-net v282
2. build the attached solution using VS2010

What is the expected output? What do you see instead?
The result I see:
Before: Andrew, Male
After: Andrew, Female
Before: Annie, Female
After: Annie, Female

The result I expect:
Andrew, Male.

What version of the product are you using? On what operating system?
v282, win 7 x86.

Please provide any additional information below.

Original issue reported on code.google.com by yuanzhi....@gmail.com on 30 May 2011 at 3:37

Attachments:

GoogleCodeExporter commented 9 years ago
This is because there is (via your constructor) an implicit default (right or 
wrong) around zeros. You can tell it about this:

        [ProtoMember(2), DefaultValue(Sex.Female)]
        public Sex Sex;

or you can tell it not to use any defaults:

        [ProtoMember(2, IsRequired=true)]
        public Sex Sex;

or, in v2, you can tell it to not use your constructor, which would also fix it.

Original comment by marc.gravell on 30 May 2011 at 8:05

GoogleCodeExporter commented 9 years ago

Original comment by marc.gravell on 13 Jun 2011 at 8:43

GoogleCodeExporter commented 9 years ago

Original comment by marc.gravell on 13 Jun 2011 at 8:44