[Mono-bugs] [Bug 51060][Blo] New - Multiple indexers of the class cause to failure in XMLSerializer
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Mon, 17 Nov 2003 03:18:16 -0500 (EST)
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 pavels@mainsoft.com.
http://bugzilla.ximian.com/show_bug.cgi?id=51060
--- shadow/51060 2003-11-17 03:18:16.000000000 -0500
+++ shadow/51060.tmp.4971 2003-11-17 03:18:16.000000000 -0500
@@ -0,0 +1,174 @@
+Bug#: 51060
+Product: Mono/Class Libraries
+Version: unspecified
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Blocker
+Component: System.XML
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: pavels@mainsoft.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Multiple indexers of the class cause to failure in XMLSerializer
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem: Creating of XMLSerializarer fails when class
+provided as parameter contains multiple indexers that returns same value
+and uses different number of parameters.
+
+
+Steps to reproduce the problem:
+1. You can either use attached program or create class with two indexers
+with different number of parameters
+2. Run the following line: XmlSerializer serializer = new XmlSerializer
+(typeof(YOUR CLASS))
+3.
+
+Actual Results:
+---------------
+Unhandled Exception: System.InvalidOperationException: The XML element
+named 'Item' from namespace '' already present in the current scope. Use
+XML attributes to specify another XML name or namespace for the element.
+in <0x006fa> System.Xml.Serialization.ClassMap:AddMember
+(System.Xml.Serialization.XmlTypeMapMember)
+in <0x00303>
+System.Xml.Serialization.XmlReflectionImporter:ImportClassMapping
+(System.Type,System.Xml.Serialization.XmlRootAttribute,string)
+in <0x00106>
+System.Xml.Serialization.XmlReflectionImporter:ImportTypeMapping
+(System.Type,System.Xml.Serialization.XmlRootAttribute,string)
+in <0x000f0> System.Xml.Serialization.XmlSerializer:.ctor
+(System.Type,System.Xml.Serialization.XmlAttributeOverrides,System.Type
+[],System.Xml.Serialization.XmlRootAttribute,string)
+in <0x00021> System.Xml.Serialization.XmlSerializer:.ctor (System.Type)
+in <0x0002d> XmlBug1.Class1:Main (string[])
+
+
+Expected Results:
+Should not fail
+
+How often does this happen?
+Always
+
+Additional Information:
+Here is a code that cause a failure:
+
+
+using System;
+using System.Xml;
+using System.Xml.Serialization;
+
+namespace XmlBug1
+{
+ public class Class1
+ {
+ #region "Data members"
+ private object[] rows;
+ private int num_items;
+ private int num_rows;
+ #endregion
+
+ #region "Construction"
+ public Class1()
+ {
+ rows = new object[0];
+ num_items = 0;
+ num_rows = 0;
+ }
+ #endregion
+
+ #region "Indexers"
+ public object this [int a_row, int a_item]
+ {
+ get
+ {
+ try
+ {
+ return ((object[])rows[a_row])
+[a_item];
+ }
+ catch (IndexOutOfRangeException)
+ {
+ return null;
+ }
+ catch (ArgumentException)
+ {
+ return null;
+ }
+ }
+ set
+ {
+ ((object[])rows[a_row])[a_item] = value;
+ }
+ }
+ public object this [int pos]
+ {
+ get
+ {
+ try
+ {
+ return ((object[])rows[pos])[pos];
+ }
+ catch (IndexOutOfRangeException)
+ {
+ return null;
+ }
+ catch (ArgumentException)
+ {
+ return null;
+ }
+ }
+ set
+ {
+ ((object[])rows[pos])[pos] = value;
+ }
+ }
+ #endregion
+
+ #region "Properties"
+ [XmlArrayItem (ElementName="Row", Type = typeof(Object))]
+ [XmlArray()]
+ public object[] Rows
+ {
+ get
+ {
+ return rows;
+ }
+ set
+ {
+ rows = value;
+ }
+ }
+ [XmlIgnore]
+ public int NumOfItems
+ {
+ get
+ {
+ return ((object[])rows[0]).Length;
+ }
+ }
+ [XmlIgnore]
+ public int NumOfRows
+ {
+ get
+ {
+ return rows.Length;
+ }
+ }
+ #endregion
+
+ [STAThread]
+ static void Main(string[] args)
+ {
+ //Class1 myClass = new Class1();
+ XmlSerializer serializer = new XmlSerializer
+(typeof(XmlBug1.Class1));
+ }
+ }
+}