anerjan / protobuf-net

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

OverwriteList option makes no effect when the list is empty #346

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
E-mail: yuretz@gmail.com

What steps will reproduce the problem?
1. Create a protobuf-serializable class with a public collection member, 
initialized to some default non-empty value in the class constructor.
The collection member should have a ProtoMemberAttribute attached with 
OverwriteList option set to true.

For example:

[ProtoContract]
public class Tst3
{
    public Tst3()
    {
        Items = new List<string>() {"Item1", "Item2"};
    }

    [ProtoMember(1, OverwriteList = true)]
    public List<string> Items;
}

2. Create a class instance and explicitly initialize a collection member to an 
empty value.

For example:
Tst3 instance = new Tst3() { Items = new List<string>() { } };

3. Use the DeepClone() method to create a copy of the instance created and 
check collection contents.

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

Expected output is an empty collection. What you see instead is a collection 
initialized with default values. 

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

Windows XP, .NET Framework 3.0

I've tried two protobuf-net v580 and v612, both give the same result

Original issue reported on code.google.com by yuretz on 21 Dec 2012 at 9:20