[Mono-bugs] [Bug 59638][Blo] Changed - MONO Beta 2 bug with XmlSerializer member ordering
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 9 Jun 2004 10:07:06 -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-08 12:39:23.000000000 -0400
+++ shadow/59638.tmp.28031 2004-06-09 10:07:06.000000000 -0400
@@ -91,6 +91,49 @@
Beta 2 XmlTypeMapping.cs with patch applied
------- Additional Comments From lluis@ximian.com 2004-06-08 12:39 -------
Have you checked if changing from Hashtable to ListDictionary has any
effect on performace? ListDictionary performs linear search of elements.
+
+------- Additional Comments From davidandrewtaylor@hotmail.com 2004-06-09 10:07 -------
+For any realistic situation I cannot see this impacting
+performance. You would need to have a really high number of
+attributes for this to be slow (>1000) and I have never seen a class
+with 1000 fields, let alone 1000 of them mapped to XmlAttribute.
+However your point is taken and I am happy running some perf tests.
+
+Have you looked at my rewrite of the GetReflectionMembers method, as
+I put a lot of thought into making sure it was performant and I was
+not doing anything stupud.
+
+BTW: For the Attribute ordering issue, it could also be solved by
+keeping the hashtable and just by sorting the attributes inside
+the "AttributeMembers" property by creating this IComparer:
+
+internal class XmlTypeMapMemberComparer : IComparer
+{
+ public int Compare(object x, object y)
+ {
+ XmlTypeMapMember objX = (XmlTypeMapMember) x;
+ XmlTypeMapMember objY = (XmlTypeMapMember) y;
+ if (objX.Index == objY.Index) return 0;
+ else return (objX.Index < objY.Index) ? -1 : 1;
+ }
+}
+
+Then in the XmlTypeMapping.Addmember method, before the
+line "_attributeMembers.Add (key, member);" add this line:
+member.Index = _attributeMembers.Count;
+
+and change the XmlTypeMapping.AttributeMembers Property to be:
+public ICollection AttributeMembers
+{
+ get {
+ if (_attributeMembers==null) return null;
+ ArrayList list = new ArrayList
+(_attributeMembers.Values)
+ list.Sort(new XmlTypeMapMemberComparer());
+ return list;
+ }
+}
+