[Mono-bugs] [Bug 74349][Nor] New - classes implementing IXmlSerializable are not serialized correctly (patch attached)

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 3 Apr 2005 07:52:51 -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 kostat@mainsoft.com.

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

--- shadow/74349	2005-04-03 07:52:51.000000000 -0400
+++ shadow/74349.tmp.7621	2005-04-03 07:52:51.000000000 -0400
@@ -0,0 +1,132 @@
+Bug#: 74349
+Product: Mono: Class Libraries
+Version: 1.1
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Sys.XML
+AssignedTo: lluis@ximian.com                            
+ReportedBy: kostat@mainsoft.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: classes implementing IXmlSerializable are not serialized correctly (patch attached)
+
+Test case:
+
+using System;
+using System.Xml;
+using System.IO;
+using System.Diagnostics;
+using System.Xml.Serialization;
+using System.Data;
+
+public class Test {
+
+   private static DataTable MakeTable () {
+       DataTable namesTable = new DataTable ("Names");
+       DataColumn idColumn = new  DataColumn ();
+                                                                          
+                       
+                                                                          
+                       
+       idColumn.DataType = Type.GetType ("System.Int32");
+       idColumn.ColumnName = "Id";
+       idColumn.AutoIncrement = true;
+       namesTable.Columns.Add (idColumn);
+                                                                          
+                       
+                                                                          
+                       
+       DataColumn fNameColumn = new DataColumn ();
+       fNameColumn.DataType = Type.GetType ("System.String");
+       fNameColumn.ColumnName = "Fname";
+       fNameColumn.DefaultValue = "Fname";
+       namesTable.Columns.Add (fNameColumn);
+                                                                          
+                       
+       DataColumn lNameColumn = new DataColumn ();
+       lNameColumn.DataType = Type.GetType ("System.String");
+       lNameColumn.ColumnName = "LName";
+       lNameColumn.DefaultValue="LName";
+       namesTable.Columns.Add (lNameColumn);
+                                                                          
+                       
+                                                                          
+                       
+       // Set the primary key for the table
+       DataColumn [] keys = new DataColumn [1];
+       keys [0] = idColumn;
+       namesTable.PrimaryKey = keys;
+       // Return the new DataTable.
+       return namesTable;
+   }
+
+   static void Test3() {
+       //Clear all existing values from table
+       DataTable table = MakeTable ();
+             DataRow row = table.NewRow ();
+       row["FName"] = "My FName";
+       row["Id"] = 0;
+       table.Rows.Add (row);
+                                                                          
+                       
+       DataTable tableC = new DataTable ("Child");
+       DataColumn colC;
+       DataRow rowC;
+                                                                          
+                       
+       colC = new DataColumn ();
+       colC.DataType = Type.GetType ("System.Int32");
+       colC.ColumnName = "Id";
+       colC.AutoIncrement=true;
+       tableC.Columns.Add (colC);
+                                                                          
+                       
+                                                                          
+                       
+       colC = new DataColumn ();
+       colC.DataType = Type.GetType ("System.String");
+       colC.ColumnName = "Name";
+       tableC.Columns.Add (colC);
+                                                                          
+                       
+       rowC = tableC.NewRow ();
+       rowC["Name"] = "My FName";
+       tableC.Rows.Add (rowC);
+       DataSet ds = new DataSet ();
+       ds.Tables.Add (table);
+       ds.Tables.Add (tableC);
+       DataRelation dr = new DataRelation ("PO", table.Columns ["Id"],
+tableC.Columns ["Id"]);
+       ds.Relations.Add (dr);
+                                                                          
+                       
+       rowC.SetParentRow (table.Rows [0], dr);
+                                                                          
+                       
+         ds.Relations.Clear ();
+       dr = new DataRelation ("PO", table.Columns ["Id"], tableC.Columns
+["Id"], false);
+       ds.Relations.Add (dr);
+       rowC.SetParentRow (table.Rows [0], dr);
+
+       XmlSerializer ser = new XmlSerializer(typeof(DataSet));
+
+       ser.Serialize(Console.Out, ds);
+   }
+
+   public static void Main () {
+       Test3();
+   }
+}
+
+Actual Results:
+DataSet is serialized as an ordinary object
+
+Expected Results:
+DataSet is serialized using IXmlSerializable interface