Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c29e297

Browse files
author
Atsushi Kanamori
committed
System.Data.Common.Tests down to 1 failure on ILC
Divering more BinaryFormatter tests to our Aot-trapped helper. More rd.xml magic.
1 parent 064e0d8 commit c29e297

File tree

5 files changed

+24
-35
lines changed

5 files changed

+24
-35
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
2+
<Library>
3+
<!-- Tests create an XmlSerializer on type System.Data.DataTable. -->
4+
<Type Name="System.Data.DataTable" Dynamic="Required Public" />
5+
</Library>
6+
</Directives>
7+

src/System.Data.Common/tests/System.Data.Common.Tests.csproj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@
107107
<Compile Include="$(CommonTestPath)\System\Diagnostics\Tracing\TestEventListener.cs">
108108
<Link>Common\System\Diagnostics\Tracing\TestEventListener.cs</Link>
109109
</Compile>
110+
<Compile Include="$(CommonTestPath)\System\PlatformDetection.cs">
111+
<Link>System\PlatformDetection.cs</Link>
112+
</Compile>
113+
<Compile Include="$(CommonTestPath)\System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs">
114+
<Link>System\Runtime\Serialization\Formatters\BinaryFormatterHelpers.cs</Link>
115+
</Compile>
116+
</ItemGroup>
117+
<ItemGroup>
118+
<EmbeddedResource Include="Resources\$(AssemblyName).rd.xml" />
110119
</ItemGroup>
111120
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
112-
</Project>
121+
</Project>

src/System.Data.Common/tests/System/Data/DataSetTest2.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
using System.Xml;
3232
using System.Runtime.Serialization.Formatters.Binary;
33+
using System.Runtime.Serialization.Formatters.Tests;
3334
using System.Globalization;
3435

3536
namespace System.Data.Tests
@@ -3607,11 +3608,7 @@ public void Bug537229_BinFormatSerializer_Test()
36073608

36083609
AssertDataTableValues(dt);
36093610

3610-
MemoryStream mstm = new MemoryStream();
3611-
BinaryFormatter bfmt = new BinaryFormatter();
3612-
bfmt.Serialize(mstm, dt);
3613-
MemoryStream mstm2 = new MemoryStream(mstm.ToArray());
3614-
DataTable vdt = (DataTable)bfmt.Deserialize(mstm2);
3611+
DataTable vdt = BinaryFormatterHelpers.Clone(dt);
36153612
AssertDataTableValues(vdt);
36163613
}
36173614
}

src/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
using System.Collections;
3030
using System.Runtime.Serialization;
31+
using System.Runtime.Serialization.Formatters.Tests;
3132
using System.Xml;
3233
using System.Xml.Schema;
3334
using System.IO;
@@ -745,15 +746,7 @@ public void TypedDataSet()
745746
ds1.DataTable1.AddDataTable1Row("test");
746747
ds1.DataTable1.AddDataTable1Row("test2");
747748

748-
global::System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter =
749-
new global::System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
750-
MemoryStream stream = new MemoryStream();
751-
752-
formatter.Serialize(stream, ds1);
753-
754-
stream.Seek(0, SeekOrigin.Begin);
755-
756-
DataSet1 ds1load = (DataSet1)formatter.Deserialize(stream);
749+
DataSet1 ds1load = BinaryFormatterHelpers.Clone(ds1);
757750

758751
Assert.True(ds1load.Tables.Contains("DataTable1"));
759752
Assert.Equal("DataTable1DataTable", ds1load.Tables["DataTable1"].GetType().Name);
@@ -775,13 +768,7 @@ public void TypedDataSet()
775768
//now test when the mode is exclude schema
776769
ds1.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.ExcludeSchema;
777770

778-
stream = new MemoryStream();
779-
780-
formatter.Serialize(stream, ds1);
781-
782-
stream.Seek(0, SeekOrigin.Begin);
783-
784-
ds1load = (DataSet1)formatter.Deserialize(stream);
771+
ds1load = BinaryFormatterHelpers.Clone(ds1);
785772

786773
Assert.True(ds1load.Tables.Contains("DataTable1"));
787774
Assert.Equal("DataTable1DataTable", ds1load.Tables["DataTable1"].GetType().Name);

src/System.Data.Common/tests/System/Data/DataTableTest.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
using System.Globalization;
3333
using System.IO;
3434
using System.Runtime.Serialization.Formatters.Binary;
35+
using System.Runtime.Serialization.Formatters.Tests;
3536
using System.Xml;
3637

3738

@@ -1893,12 +1894,6 @@ public void TestWriteXmlSchema3()
18931894
[Fact]
18941895
public void Serialize()
18951896
{
1896-
MemoryStream fs = new MemoryStream();
1897-
1898-
// Construct a BinaryFormatter and use it
1899-
// to serialize the data to the stream.
1900-
BinaryFormatter formatter = new BinaryFormatter();
1901-
19021897
// Create an array with multiple elements refering to
19031898
// the one Singleton object.
19041899
DataTable dt = new DataTable();
@@ -1919,13 +1914,7 @@ public void Serialize()
19191914
dt.Rows.Add(loRowToAdd);
19201915

19211916
DataTable[] dtarr = new DataTable[] { dt };
1922-
1923-
// Serialize the array elements.
1924-
formatter.Serialize(fs, dtarr);
1925-
1926-
// Deserialize the array elements.
1927-
fs.Position = 0;
1928-
DataTable[] a2 = (DataTable[])formatter.Deserialize(fs);
1917+
DataTable[] a2 = BinaryFormatterHelpers.Clone(dtarr);
19291918

19301919
var ds = new DataSet();
19311920
ds.Tables.Add(a2[0]);

0 commit comments

Comments
 (0)