ericvana / protobuf-net

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

Deserialize field fail while property works #202

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
A List<string> member does not get deserialized when it is a field.

class A //property version
{
    [ProtoMember(3)]
    public List<string> flags { get; set; }
}

class A //field version
{
    [ProtoMember(3)]
    public List<string> flags;
}

What steps will reproduce the problem?
1. Serialize A with either the field or property version, same output as 
expected
2. Deserialize using the field version

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

The member flags should be deserialized, instead it is set to null.

Changing to the propery version and deserializing the same data(that was 
serialized using either the property or field version) works as expected.

So serialization works for both version resulting in binary equal output but 
the deserialization using the field version fail.

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

v2 beta r423.zip
Ubuntu 11.04
Mono 2.10

Original issue reported on code.google.com by pe...@endnode.se on 8 Jul 2011 at 1:04

GoogleCodeExporter commented 9 years ago
I have added a test for this on *regular* framework, but cannot reproduce. Does 
this perhaps relate to an *empty* list remaining null? Better, can you show a 
complete example that shows this? Compare to Issue202.cs (which passes the test)

Original comment by marc.gravell on 8 Jul 2011 at 1:22

GoogleCodeExporter commented 9 years ago
Could it also perhaps relate to the missing [ProtoContract] ?

Original comment by marc.gravell on 8 Jul 2011 at 1:24

GoogleCodeExporter commented 9 years ago
Sorry, no.

The [ProtoContract] is there in the code, I missed it in the example.

Currenlty it is a part of a larger project(source code available) but for 
simplicity I will come back with a simple complete example.

Original comment by pe...@endnode.se on 8 Jul 2011 at 1:37

GoogleCodeExporter commented 9 years ago
Output of example code:

Before:
[App] 2
    [Bp] b1 1: a
    [Bp] b2 1: b
[Apf] 2
    [Bf] b1 1: a
    [Bf] b2 1: b
[Afp] 2
    [Bp] b1 1: a
    [Bp] b2 1: b
[Aff] 2
    [Bf] b1 1: a
    [Bf] b2 1: b
Got 18 bytes
After:
[App] 2
    [Bp] b1 1: a
    [Bp] b2 1: b
[Apf] 2
    [Bf] b1 null
    [Bf] b2 null
[Afp] null
[Aff] null

Original comment by pe...@endnode.se on 8 Jul 2011 at 2:47

Attachments:

GoogleCodeExporter commented 9 years ago
Hmmm... even with the full example I can't reproduce on core .NET (new 
Issue202.cs passes); I have to assume it is platform related. Still looking.

Original comment by marc.gravell on 12 Jul 2011 at 7:12