Re: [Mono-dev] [PATCH] DataTable.WriteXml

2006-10-06 Thread Nagappan
Hi Patrick,
The patch looks fine, but it doesn't apply with the latest SVN. Can you
make a new patch and send it across.

Thanks
Nagappan

Patrick Earl wrote:
 I've implemented the WriteXml method for System.Data.DataTable. Since
 writing a table is similar to writing a DataSet, it leverages many of
 the methods used to write DataSets. Included with the patch are a
 successful unit test for the new WriteXml functionality and a failing
 unit test for ReadXml, which has not yet been implemented. The patch
 caused no regressions in the System.Data net_2_0 test suite.

 The patch applies against the mcs/class/System.Data folder in the
 latest SVN revision (66162 as of this message).

 This is my first substantial contribution, so I'm happy to get
 feedback on it. Thanks.

 Patrick Earl
 

 Index: Test/System.Data/ChangeLog
 ===
 --- Test/System.Data/ChangeLog(revision 66162)
 +++ Test/System.Data/ChangeLog(working copy)
 @@ -1,3 +1,9 @@
 +2006-09-28  Patrick Earl [EMAIL PROTECTED]
 +
 + * DataTableReadWriteXml.cs: Added new tests for the DataTable's
 + ReadXml and WriteXml methods.  These tests assume proper
 + functioning of the DataSet ReadXml and WriteXml methods.
 +
  2006-09-18   Boris Kirzner [EMAIL PROTECTED]
  
   * DataViewTest.cs : fix compilation error.
 Index: Test/System.Data/DataTableReadWriteXmlTest.cs
 ===
 --- Test/System.Data/DataTableReadWriteXmlTest.cs (revision 0)
 +++ Test/System.Data/DataTableReadWriteXmlTest.cs (revision 0)
 @@ -0,0 +1,373 @@
 +// Author:
 +//   Patrick Earl [EMAIL PROTECTED]
 +//
 +// Copyright (c) 2006
 +//
 +// Permission is hereby granted, free of charge, to any person obtaining
 +// a copy of this software and associated documentation files (the
 +// Software), to deal in the Software without restriction, including
 +// without limitation the rights to use, copy, modify, merge, publish,
 +// distribute, sublicense, and/or sell copies of the Software, and to
 +// permit persons to whom the Software is furnished to do so, subject to
 +// the following conditions:
 +//
 +// The above copyright notice and this permission notice shall be
 +// included in all copies or substantial portions of the Software.
 +//
 +// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
 +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 +//
 +
 +#if NET_2_0
 +using System;
 +using System.Data;
 +using System.IO;
 +using System.Text.RegularExpressions;
 +using System.Xml;
 +using NUnit.Framework; 
 +
 +namespace MonoTests.System.Data
 +{
 +[TestFixture]
 +public class DataTableReadWriteXmlTest
 +{
 +void StandardizeXmlFormat(ref string xml)
 +{
 +XmlDocument doc = new XmlDocument();
 +doc.LoadXml(xml);
 +StringWriter sw = new StringWriter();
 +doc.Save(sw);
 +xml = sw.ToString();
 +}
 +
 +void GenerateTestData(out DataSet ds,
 +  out DataTable dtMainInDS,
 +  out DataTable dtChildInDS,
 +  out DataTable dtMain)
 +{
 +ds = new DataSet(MyDataSet);
 +
 +// Create a primary table and populate it with some data.  Make a
 +// copy of the primary table and put it into the dataset.
 +dtMain = new DataTable(Main);
 +dtMain.Columns.Add(new DataColumn(ID, typeof(int)));
 +dtMain.Columns.Add(new DataColumn(Data, typeof(string)));
 +
 +DataRow row = dtMain.NewRow();
 +row[ID] = 1;
 +row[Data] = One;
 +dtMain.Rows.Add(row);
 +
 +row = dtMain.NewRow();
 +row[ID] = 2;
 +row[Data] = Two;
 +dtMain.Rows.Add(row);
 +
 +row = dtMain.NewRow();
 +row[ID] = 3;
 +row[Data] = Three;
 +dtMain.Rows.Add(row);
 +
 +dtMainInDS = dtMain.Copy();
 +ds.Tables.Add(dtMainInDS);
 +
 +// Create a child table.  Make a copy of the child table and put
 +// it into the dataset.
 +dtChildInDS = new DataTable(Child);
 +dtChildInDS.Columns.Add(new DataColumn(ID, typeof(int)));
 +dtChildInDS.Columns.Add(new DataColumn(PID, typeof(int)));
 +

[Mono-dev] [PATCH] DataTable.WriteXml

2006-10-02 Thread Patrick Earl
I've implemented the WriteXml method for System.Data.DataTable.  Since 
writing a table is similar to writing a DataSet, it leverages many of 
the methods used to write DataSets.  Included with the patch are a 
successful unit test for the new WriteXml functionality and a failing 
unit test for ReadXml, which has not yet been implemented.  The patch 
caused no regressions in the System.Data net_2_0 test suite.


The patch applies against the mcs/class/System.Data folder in the latest 
SVN revision (66162 as of this message).


This is my first substantial contribution, so I'm happy to get feedback 
on it.  Thanks.


   Patrick Earl
Index: Test/System.Data/ChangeLog
===
--- Test/System.Data/ChangeLog  (revision 66162)
+++ Test/System.Data/ChangeLog  (working copy)
@@ -1,3 +1,9 @@
+2006-09-28  Patrick Earl [EMAIL PROTECTED]
+
+   * DataTableReadWriteXml.cs: Added new tests for the DataTable's
+   ReadXml and WriteXml methods.  These tests assume proper
+   functioning of the DataSet ReadXml and WriteXml methods.
+
 2006-09-18 Boris Kirzner [EMAIL PROTECTED]
 
* DataViewTest.cs : fix compilation error.
Index: Test/System.Data/DataTableReadWriteXmlTest.cs
===
--- Test/System.Data/DataTableReadWriteXmlTest.cs   (revision 0)
+++ Test/System.Data/DataTableReadWriteXmlTest.cs   (revision 0)
@@ -0,0 +1,373 @@
+// Author:
+//   Patrick Earl [EMAIL PROTECTED]
+//
+// Copyright (c) 2006
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// Software), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+using System;
+using System.Data;
+using System.IO;
+using System.Text.RegularExpressions;
+using System.Xml;
+using NUnit.Framework; 
+
+namespace MonoTests.System.Data
+{
+[TestFixture]
+public class DataTableReadWriteXmlTest
+{
+void StandardizeXmlFormat(ref string xml)
+{
+XmlDocument doc = new XmlDocument();
+doc.LoadXml(xml);
+StringWriter sw = new StringWriter();
+doc.Save(sw);
+xml = sw.ToString();
+}
+
+void GenerateTestData(out DataSet ds,
+  out DataTable dtMainInDS,
+  out DataTable dtChildInDS,
+  out DataTable dtMain)
+{
+ds = new DataSet(MyDataSet);
+
+// Create a primary table and populate it with some data.  Make a
+// copy of the primary table and put it into the dataset.
+dtMain = new DataTable(Main);
+dtMain.Columns.Add(new DataColumn(ID, typeof(int)));
+dtMain.Columns.Add(new DataColumn(Data, typeof(string)));
+
+DataRow row = dtMain.NewRow();
+row[ID] = 1;
+row[Data] = One;
+dtMain.Rows.Add(row);
+
+row = dtMain.NewRow();
+row[ID] = 2;
+row[Data] = Two;
+dtMain.Rows.Add(row);
+
+row = dtMain.NewRow();
+row[ID] = 3;
+row[Data] = Three;
+dtMain.Rows.Add(row);
+
+dtMainInDS = dtMain.Copy();
+ds.Tables.Add(dtMainInDS);
+
+// Create a child table.  Make a copy of the child table and put
+// it into the dataset.
+dtChildInDS = new DataTable(Child);
+dtChildInDS.Columns.Add(new DataColumn(ID, typeof(int)));
+dtChildInDS.Columns.Add(new DataColumn(PID, typeof(int)));
+dtChildInDS.Columns.Add(new DataColumn(ChildData, 
typeof(string)));
+
+row = dtChildInDS.NewRow();
+row[ID] = 1;
+row[PID] = 1;
+row[ChildData] = Parent1Child1;
+dtChildInDS.Rows.Add(row);
+
+row = dtChildInDS.NewRow();
+row[ID] =