cjyyyza / protobuf-net

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

Using AsReference and OverwriteList with ProtoPartialMembers does not work. #428

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a class with AsReference ProtoMember(s).
2. Generate a DataContract using svcutil.
3. Create partial classes to pair with the generated partial classes, with  
protobuf attributes to match those in the initial class.
4. Create a test instance of the class, then serialize it using the original 
class.  Then deserialize it using the generated class.

What is the expected output? What do you see instead?
Expected output - AsReference member deserializes correctly.
Actual output - The deserialized object has the reference information at the 
front of its member (easiest to see with a string).
e.g. the string "querystring1" becomes "<DLE><EOT>R<FF>querystring1"

What version of the product are you using? On what operating system?
protobuf-net 2.0.0.666
Windows 7

Please provide any additional information below.
After debugging through the deserialization I believe the issue is in 
MetaType.cs, NormalizeProtoMember.  
In the section going through the partial members, the "OverwriteList" and 
"AsReferenceHasValue" GetField extractions are passing in the attrib variable 
(which was always null in my case) as the AttributeMap, whereas all the others 
are using the loop's AttributeMap variable, ppma.

From lines 1020-1029, MetaType.cs
GetFieldNumber(ref fieldNumber, ppma, "Tag");
GetFieldName(ref name, ppma, "Name");
GetFieldBoolean(ref isRequired, ppma, "IsRequired");
GetFieldBoolean(ref isPacked, ppma, "IsPacked");
GetFieldBoolean(ref overwriteList, attrib, "OverwriteList");  //uses attrib
GetDataFormat(ref dataFormat, ppma, "DataFormat");

GetFieldBoolean(ref asReferenceHasValue, attrib, "AsReferenceHasValue", false); 
 //uses attrib

Thanks!

Original issue reported on code.google.com by jackieho...@gmail.com on 23 Jan 2014 at 5:25