[Mono-bugs] [Bug 59638][Blo] New - MONO Beta 2 bug with XmlSerializer member ordering

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 5 Jun 2004 22:24:22 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by davidandrewtaylor@hotmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=59638

--- shadow/59638	2004-06-05 22:24:22.000000000 -0400
+++ shadow/59638.tmp.17005	2004-06-05 22:24:22.000000000 -0400
@@ -0,0 +1,72 @@
+Bug#: 59638
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 001 One hour
+Priority: Blocker
+Component: Sys.XML
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: davidandrewtaylor@hotmail.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: MONO Beta 2 bug with XmlSerializer member ordering
+
+I have provided two patches for MONO Beta 2, and given I am not on CVS 
+they will either need to be applied manually given the instructions below 
+or you can use my "patched" files: XmlTypeMapping.cs and 
+XmlReflectionImporter.cs (provided no other changes have been done to 
+these classes since Beta2).
+
+BUG PART A:
+There are two bugs in the MONO XmlSerializer regarding ordering of 
+serialized members.  The first bug is in the XmlReflectionImporter.cs 
+file in the follwoing method: "ICollection GetReflectionMembers(Type 
+type)".  In the current code there has been an attempt to return members 
+in the same order as the MS.NET implementation if a class consisting of 
+an inheritance hierarchy is serialized.  The code is "almost correct", 
+however differs from the MS.NET implementation if you try to serialize a 
+class consisting of both a type hierarchy AND both properties and 
+fields.  MS.NET serializes starting at the base class (first all base 
+class fields, then all base class properties), then proceeds up the 
+inheritance hierarchy (first fields, then properties).  You can see the 
+difference in behavior by running the attached testcase.cs
+
+To correct this bug please replace the entire GetReflectionMembers(Type 
+type) method with the replacement method I have 
+attached "GetReflectionMembers.txt" in the XmlReflectionImporter.cs file.
+Note: This fix works for both the serialization interpreter and the 
+serialization code generator.
+Note: The current SoapReflectionImporter appear to be correct and does 
+not require any modifications.
+
+BUG PART B:
+MONO currently does not maintain XML attribute ordering during 
+serialization (it uses a hashtable), which is different to MS.NET which 
+maintains order.  Whilst this is not strictly a bug (as attribute 
+ordering should never be assumed), we increase compabilility with MS.NET 
+by making a simple change. This change will also ensure that anyone who 
+has "hand written" poor quality XML parsers will not have problems when 
+they attempt to migrate their web services from MS.NET to MONO.
+
+The fix requires that 3 lines be changed in the XmlTypeMappings.cs file:
+
+- Line 148: Hashtable _attributeMembers;
++ Line 148: System.Collections.Specialized.ListDictionary 
+_attributeMembers;
+
+- Line 176: if (_attributeMembers == null) _attributeMembers = new 
+Hashtable();
++Line 176: if (_attributeMembers == null) _attributeMembers = new 
+System.Collections.Specialized.ListDictionary();
+
+- Line 178 if (_attributeMembers.ContainsKey (key))
++ Line 178 if (_attributeMembers.Contains (key))
+Note: You may want to add "using System.Collections.Specialized;"
+
+Thanks,
+David Taylor