From a615b99b2517deb0851da22b1331c3947660acda Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Thu, 16 Jul 2020 15:27:07 -0400 Subject: [PATCH 1/4] [Wasm] Enable System.Data.Common tests and PNSE a few types --- .../src/System.Data.Common.csproj | 6 +- .../Data/Common/DbProviderFactories.Any.cs | 71 +++++++++++++++++++ .../Common/DbProviderFactories.Browser.cs | 30 ++++++++ .../System/Data/Common/DbProviderFactories.cs | 59 --------------- .../System/Data/DataTableExtensions.Any.cs | 39 ++++++++++ .../Data/DataTableExtensions.Browser.cs | 37 ++++++++++ .../src/System/Data/DataTableExtensions.cs | 25 +------ .../Data/Common/DbProviderFactoriesTests.cs | 2 + .../Data/Common/DbProviderFactoryTest.cs | 1 + .../tests/System/Data/DataRowTest2.cs | 2 +- .../System/Data/DataSetInferXmlSchemaTest.cs | 14 ++-- .../System/Data/DataSetReadXmlSchemaTest.cs | 40 +++++------ .../tests/System/Data/DataSetReadXmlTest.cs | 12 ++-- .../tests/System/Data/DataSetTest.cs | 14 ++-- .../tests/System/Data/DataSetTest2.cs | 42 +++++------ .../System/Data/DataSetTypedDataSetTest.cs | 2 +- .../System/Data/DataTableExtensionsTest.cs | 1 + .../System/Data/DataTableReadXmlSchemaTest.cs | 16 ++--- .../tests/System/Data/DataTableTest.cs | 8 +-- .../tests/System/Data/DataTableTest4.cs | 4 +- .../Data/SqlTypes/SqlStringSortingTest.cs | 2 +- .../System/Data/SqlTypes/SqlStringTest.cs | 69 +++++++++--------- src/libraries/tests.proj | 1 - 23 files changed, 301 insertions(+), 196 deletions(-) create mode 100644 src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Any.cs create mode 100644 src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Browser.cs create mode 100644 src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Any.cs create mode 100644 src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Browser.cs diff --git a/src/libraries/System.Data.Common/src/System.Data.Common.csproj b/src/libraries/System.Data.Common/src/System.Data.Common.csproj index a872f6cefe451..2f0aa983ae25d 100644 --- a/src/libraries/System.Data.Common/src/System.Data.Common.csproj +++ b/src/libraries/System.Data.Common/src/System.Data.Common.csproj @@ -2,7 +2,7 @@ System.Data.Common true - $(NetCoreAppCurrent) + $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser enable @@ -78,6 +78,8 @@ Component + + @@ -217,6 +219,8 @@ + + diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Any.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Any.cs new file mode 100644 index 0000000000000..d0529dad09e0c --- /dev/null +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Any.cs @@ -0,0 +1,71 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; + +namespace System.Data.Common +{ + public static partial class DbProviderFactories + { + private const string AssemblyQualifiedNameColumnName = "AssemblyQualifiedName"; + private const string InvariantNameColumnName = "InvariantName"; + private const string NameColumnName = "Name"; + private const string DescriptionColumnName = "Description"; + private const string ProviderGroupColumnName = "DbProviderFactories"; + + public static DbProviderFactory GetFactory(string providerInvariantName) + { + return GetFactory(providerInvariantName, throwOnError: true)!; + } + + public static DbProviderFactory GetFactory(DataRow providerRow) + { + ADP.CheckArgumentNull(providerRow, nameof(providerRow)); + + DataColumn? assemblyQualifiedNameColumn = providerRow.Table.Columns[AssemblyQualifiedNameColumnName]; + if (null == assemblyQualifiedNameColumn) + { + throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); + } + + string? assemblyQualifiedName = providerRow[assemblyQualifiedNameColumn] as string; + if (string.IsNullOrWhiteSpace(assemblyQualifiedName)) + { + throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); + } + + return GetFactoryInstance(GetProviderTypeFromTypeName(assemblyQualifiedName)); + } + + + public static DbProviderFactory? GetFactory(DbConnection connection) + { + ADP.CheckArgumentNull(connection, nameof(connection)); + + return connection.ProviderFactory; + } + + public static DataTable GetFactoryClasses() + { + DataColumn nameColumn = new DataColumn(NameColumnName, typeof(string)) { ReadOnly = true }; + DataColumn descriptionColumn = new DataColumn(DescriptionColumnName, typeof(string)) { ReadOnly = true }; + DataColumn invariantNameColumn = new DataColumn(InvariantNameColumnName, typeof(string)) { ReadOnly = true }; + DataColumn assemblyQualifiedNameColumn = new DataColumn(AssemblyQualifiedNameColumnName, typeof(string)) { ReadOnly = true }; + + DataTable toReturn = new DataTable(ProviderGroupColumnName) { Locale = CultureInfo.InvariantCulture }; + toReturn.Columns.AddRange(new[] { nameColumn, descriptionColumn, invariantNameColumn, assemblyQualifiedNameColumn }); + toReturn.PrimaryKey = new[] { invariantNameColumn }; + foreach (var kvp in _registeredFactories) + { + DataRow newRow = toReturn.NewRow(); + newRow[InvariantNameColumnName] = kvp.Key; + newRow[AssemblyQualifiedNameColumnName] = kvp.Value.FactoryTypeAssemblyQualifiedName; + newRow[NameColumnName] = string.Empty; + newRow[DescriptionColumnName] = string.Empty; + toReturn.AddRow(newRow); + } + return toReturn; + } + } +} + diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Browser.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Browser.cs new file mode 100644 index 0000000000000..21dedd1d26ace --- /dev/null +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Browser.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; + +namespace System.Data.Common +{ + public static partial class DbProviderFactories + { + public static DbProviderFactory GetFactory(string providerInvariantName) + { + throw new PlatformNotSupportedException(); + } + + public static DbProviderFactory GetFactory(DataRow providerRow) + { + throw new PlatformNotSupportedException(); + } + + public static DbProviderFactory? GetFactory(DbConnection connection) + { + throw new PlatformNotSupportedException(); + } + + public static DataTable GetFactoryClasses() + { + throw new PlatformNotSupportedException(); + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs index 2ad35f787cdee..b0da326ec02f2 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs @@ -33,11 +33,6 @@ internal ProviderRegistration(string factoryTypeAssemblyQualifiedName, DbProvide } private static readonly ConcurrentDictionary _registeredFactories = new ConcurrentDictionary(); - private const string AssemblyQualifiedNameColumnName = "AssemblyQualifiedName"; - private const string InvariantNameColumnName = "InvariantName"; - private const string NameColumnName = "Name"; - private const string DescriptionColumnName = "Description"; - private const string ProviderGroupColumnName = "DbProviderFactories"; private const string InstanceFieldName = "Instance"; public static bool TryGetFactory(string providerInvariantName, [NotNullWhen(true)] out DbProviderFactory? factory) @@ -46,60 +41,6 @@ public static bool TryGetFactory(string providerInvariantName, [NotNullWhen(true return factory != null; } - public static DbProviderFactory GetFactory(string providerInvariantName) - { - return GetFactory(providerInvariantName, throwOnError: true)!; - } - - public static DbProviderFactory GetFactory(DataRow providerRow) - { - ADP.CheckArgumentNull(providerRow, nameof(providerRow)); - - DataColumn? assemblyQualifiedNameColumn = providerRow.Table.Columns[AssemblyQualifiedNameColumnName]; - if (null == assemblyQualifiedNameColumn) - { - throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); - } - - string? assemblyQualifiedName = providerRow[assemblyQualifiedNameColumn] as string; - if (string.IsNullOrWhiteSpace(assemblyQualifiedName)) - { - throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); - } - - return GetFactoryInstance(GetProviderTypeFromTypeName(assemblyQualifiedName)); - } - - - public static DbProviderFactory? GetFactory(DbConnection connection) - { - ADP.CheckArgumentNull(connection, nameof(connection)); - - return connection.ProviderFactory; - } - - public static DataTable GetFactoryClasses() - { - DataColumn nameColumn = new DataColumn(NameColumnName, typeof(string)) { ReadOnly = true }; - DataColumn descriptionColumn = new DataColumn(DescriptionColumnName, typeof(string)) { ReadOnly = true }; - DataColumn invariantNameColumn = new DataColumn(InvariantNameColumnName, typeof(string)) { ReadOnly = true }; - DataColumn assemblyQualifiedNameColumn = new DataColumn(AssemblyQualifiedNameColumnName, typeof(string)) { ReadOnly = true }; - - DataTable toReturn = new DataTable(ProviderGroupColumnName) { Locale = CultureInfo.InvariantCulture }; - toReturn.Columns.AddRange(new[] { nameColumn, descriptionColumn, invariantNameColumn, assemblyQualifiedNameColumn }); - toReturn.PrimaryKey = new[] { invariantNameColumn }; - foreach (var kvp in _registeredFactories) - { - DataRow newRow = toReturn.NewRow(); - newRow[InvariantNameColumnName] = kvp.Key; - newRow[AssemblyQualifiedNameColumnName] = kvp.Value.FactoryTypeAssemblyQualifiedName; - newRow[NameColumnName] = string.Empty; - newRow[DescriptionColumnName] = string.Empty; - toReturn.AddRow(newRow); - } - return toReturn; - } - public static IEnumerable GetProviderInvariantNames() { return _registeredFactories.Keys.ToList(); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Any.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Any.cs new file mode 100644 index 0000000000000..a13371974e6ec --- /dev/null +++ b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Any.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace System.Data +{ + + /// + /// This static class defines the DataTable extension methods. + /// + public static partial class DataTableExtensions + { + /// + /// Creates a LinkDataView of DataRow over the input table. + /// + /// DataTable that the view is over. + /// An instance of LinkDataView. + public static DataView AsDataView(this DataTable table) + { + DataSetUtil.CheckArgumentNull(table, nameof(table)); + return new LinqDataView(table, null); + } + + /// + /// Creates a LinqDataView from EnumerableDataTable + /// + /// Type of the row in the table. Must inherit from DataRow + /// The enumerable-datatable over which view must be created. + /// Generated LinkDataView of type T + public static DataView AsDataView(this EnumerableRowCollection source) where T : DataRow + { + DataSetUtil.CheckArgumentNull>(source, nameof(source)); + return source.GetLinqDataView(); + } + } +} diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Browser.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Browser.cs new file mode 100644 index 0000000000000..01ebf2fcfff7f --- /dev/null +++ b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Browser.cs @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; + +namespace System.Data +{ + + /// + /// This static class defines the DataTable extension methods. + /// + public static partial class DataTableExtensions + { + /// + /// Creates a LinkDataView of DataRow over the input table. + /// + /// DataTable that the view is over. + /// An instance of LinkDataView. + public static DataView AsDataView(this DataTable table) + { + throw new PlatformNotSupportedException(); + } + + /// + /// Creates a LinqDataView from EnumerableDataTable + /// + /// Type of the row in the table. Must inherit from DataRow + /// The enumerable-datatable over which view must be created. + /// Generated LinkDataView of type T + public static DataView AsDataView(this EnumerableRowCollection source) where T : DataRow + { + throw new PlatformNotSupportedException(); + } + } +} diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.cs index c5a04f760f67b..e457da43df7e1 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.cs @@ -11,7 +11,7 @@ namespace System.Data /// /// This static class defines the DataTable extension methods. /// - public static class DataTableExtensions + public static partial class DataTableExtensions { /// /// This method returns a IEnumerable of Datarows. @@ -218,28 +218,5 @@ private static DataTable LoadTableFromEnumerable(IEnumerable source, DataT Debug.Assert(null != table, "null DataTable"); return table; } - - /// - /// Creates a LinkDataView of DataRow over the input table. - /// - /// DataTable that the view is over. - /// An instance of LinkDataView. - public static DataView AsDataView(this DataTable table) - { - DataSetUtil.CheckArgumentNull(table, nameof(table)); - return new LinqDataView(table, null); - } - - /// - /// Creates a LinqDataView from EnumerableDataTable - /// - /// Type of the row in the table. Must inherit from DataRow - /// The enumerable-datatable over which view must be created. - /// Generated LinkDataView of type T - public static DataView AsDataView(this EnumerableRowCollection source) where T : DataRow - { - DataSetUtil.CheckArgumentNull>(source, nameof(source)); - return source.GetLinqDataView(); - } } } diff --git a/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoriesTests.cs b/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoriesTests.cs index 8862a85e5c377..f395e64bb25ee 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoriesTests.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoriesTests.cs @@ -15,6 +15,7 @@ public sealed class TestProviderFactory : DbProviderFactory private TestProviderFactory() { } } + [PlatformSpecific(~TestPlatforms.Browser)] public class DbProviderFactoriesTests { [Fact] @@ -69,6 +70,7 @@ public void GetFactoryWithDataRowTest() public void RegisterFactoryWithTypeNameTest() { ClearRegisteredFactories(); + Console.WriteLine("Name: " + typeof(System.Data.SqlClient.SqlClientFactory).AssemblyQualifiedName); RegisterSqlClientAndTestRegistration(()=>DbProviderFactories.RegisterFactory("System.Data.SqlClient", typeof(System.Data.SqlClient.SqlClientFactory).AssemblyQualifiedName)); } diff --git a/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoryTest.cs b/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoryTest.cs index 9393016bc51f9..b810686ab4f72 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoryTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoryTest.cs @@ -6,6 +6,7 @@ namespace System.Data.Tests.Common { + [PlatformSpecific(~TestPlatforms.Browser)] public class DbProviderFactoryTest { [Fact] diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataRowTest2.cs b/src/libraries/System.Data.Common/tests/System/Data/DataRowTest2.cs index 7369c85886694..bfb22d111550f 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataRowTest2.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataRowTest2.cs @@ -1894,7 +1894,7 @@ public void IsNull_ByIndex() Assert.True(dr.IsNull(1)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void IsNull_ByName() { DataTable dt = new DataTable(); diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetInferXmlSchemaTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetInferXmlSchemaTest.cs index b953a5d3616c6..5bf2ef00533a8 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetInferXmlSchemaTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetInferXmlSchemaTest.cs @@ -246,7 +246,7 @@ public void SimpleElementTable() DataSetAssertion.AssertDataColumn("col3", dt.Columns[2], "col3", true, false, 0, 1, "col3", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 2, string.Empty, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void SimpleDataSet() { DataSet ds = GetDataSet(_xml8, null); @@ -337,7 +337,7 @@ public void SignificantWhitespaceIgnored2() DataSetAssertion.AssertDataSet("pure_whitespace", ds, "root", 0, 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TwoElementTable() { // FIXME: Also test ReadXml (, XmlReadMode.InferSchema) and @@ -356,7 +356,7 @@ public void TwoElementTable() DataSetAssertion.AssertDataColumn("col2_2", dt.Columns[1], "col2_2", true, false, 0, 1, "col2_2", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ConflictSimpleComplexColumns() { DataSet ds = GetDataSet(_xml18, null); @@ -377,7 +377,7 @@ public void ConflictSimpleComplexColumns() DataSetAssertion.AssertForeignKeyConstraint("fkey", dr.ChildKeyConstraint, "table_col", AcceptRejectRule.None, Rule.Cascade, Rule.Cascade, new string[] { "table_Id" }, new string[] { "table_Id" }); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ConflictColumnTable() { DataSet ds = GetDataSet(_xml19, null); @@ -398,7 +398,7 @@ public void ConflictColumnTable() DataSetAssertion.AssertForeignKeyConstraint("fkey", dr.ChildKeyConstraint, "table_col", AcceptRejectRule.None, Rule.Cascade, Rule.Cascade, new string[] { "table_Id" }, new string[] { "table_Id" }); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ConflictColumnTableAttribute() { // Conflicts between a column and a table, additionally an attribute. @@ -421,7 +421,7 @@ public void ConflictColumnTableAttribute() DataSetAssertion.AssertForeignKeyConstraint("fkey", dr.ChildKeyConstraint, "table_col", AcceptRejectRule.None, Rule.Cascade, Rule.Cascade, new string[] { "table_Id" }, new string[] { "table_Id" }); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ConflictAttributeDataTable() { Assert.Throws(() => @@ -433,7 +433,7 @@ public void ConflictAttributeDataTable() }); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ConflictExistingPrimaryKey() { Assert.Throws(() => diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetReadXmlSchemaTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetReadXmlSchemaTest.cs index 4c1bfa8ca081b..de1c0685bb05e 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetReadXmlSchemaTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetReadXmlSchemaTest.cs @@ -52,7 +52,7 @@ private DataSet CreateTestSet() return ds; } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void SingleElementTreatmentDifference() { // This is one of the most complicated case. When the content @@ -149,7 +149,7 @@ public void SingleElementTreatmentDifference() DataSetAssertion.AssertDataTable("complex", ds.Tables[0], "Root", 1, 0, 0, 0, 0, 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void SuspiciousDataSetElement() { string schema = @" @@ -174,7 +174,7 @@ public void SuspiciousDataSetElement() DataSetAssertion.AssertDataTable("table", ds.Tables[0], "elem", 2, 0, 0, 0, 0, 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void UnusedComplexTypesIgnored() { string xs = @" @@ -213,7 +213,7 @@ public void SimpleTypeComponentsIgnored() DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 0, 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void IsDataSetAndTypeIgnored() { string xsbase = @" @@ -243,7 +243,7 @@ public void IsDataSetAndTypeIgnored() DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void NestedReferenceNotAllowed() { string xs = @" @@ -272,7 +272,7 @@ public void NestedReferenceNotAllowed() }); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void IsDataSetOnLocalElementIgnored() { string xsbase = @" @@ -294,7 +294,7 @@ public void IsDataSetOnLocalElementIgnored() DataSetAssertion.AssertDataSet("ds", ds, "NewDataSet", 1, 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void LocaleOnRootWithoutIsDataSet() { using (new ThreadCultureChange("fi-FI")) @@ -323,7 +323,7 @@ public void LocaleOnRootWithoutIsDataSet() } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ElementHasIdentityConstraint() { string constraints = @" @@ -381,7 +381,7 @@ public void ElementHasIdentityConstraint() Assert.Equal(0, ds.Relations.Count); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void PrefixedTargetNS() { string xs = @" @@ -477,7 +477,7 @@ private void ReadTest1Check(DataSet ds) new string[] { "Column1_3" }); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] // 001-004 public void TestSampleFileNoTables() { @@ -510,7 +510,7 @@ public void TestSampleFileNoTables() DataSetAssertion.AssertDataSet("004", ds, "NewDataSet", 0, 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TestSampleFileSimpleTables() { var ds = new DataSet(); @@ -547,7 +547,7 @@ public void TestSampleFileSimpleTables() DataSetAssertion.AssertDataColumn("att2", dt.Columns["att2"], "att2", true, false, 0, 1, "att2", MappingType.Attribute, typeof(int), 2, string.Empty, -1, string.Empty, /*1*/-1, string.Empty, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TestSampleFileComplexTables() { // Nested simple type element @@ -608,7 +608,7 @@ public void TestSampleFileComplexTables() DataSetAssertion.AssertDataColumn("id", dt.Columns[1], "uno_Id", true, false, 0, 1, "uno_Id", MappingType.Hidden, typeof(int), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TestSampleFileComplexTables3() { var ds = new DataSet(); @@ -639,7 +639,7 @@ public void TestSampleFileComplexTables3() DataSetAssertion.AssertDataColumn("simple", dt.Columns[1], "e_text", false, false, 0, 1, "e_text", MappingType.SimpleContent, typeof(decimal), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TestSampleFileXPath() { var ds = new DataSet(); @@ -681,7 +681,7 @@ public void TestSampleFileXPath() ")); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TestAnnotatedRelation1() { var ds = new DataSet(); @@ -732,7 +732,7 @@ public void TestAnnotatedRelation1() DataSetAssertion.AssertDataRelation("rel", ds.Relations[0], "rel", false, new string[] { "pk" }, new string[] { "fk" }, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TestAnnotatedRelation2() { var ds = new DataSet(); @@ -783,7 +783,7 @@ public void TestAnnotatedRelation2() DataSetAssertion.AssertDataRelation("rel", ds.Relations[0], "rel", true, new string[] { "pk" }, new string[] { "fk" }, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void RepeatableSimpleElement() { var ds = new DataSet(); @@ -811,7 +811,7 @@ public void RepeatableSimpleElement() DataSetAssertion.AssertDataRelation("rel", ds.Relations[0], "Foo_Bar", true, new string[] { "Foo_Id" }, new string[] { "Foo_Id" }, true, true); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TestMoreThanOneRepeatableColumns() { var ds = new DataSet(); @@ -861,7 +861,7 @@ public void AutoIncrementStep() Assert.True(ds.GetXmlSchema().IndexOf("AutoIncrementStep") > 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadConstraints() { var ds = new DataSet(); @@ -904,7 +904,7 @@ public void ReadConstraints() Assert.Equal("fk1", ds.Tables[1].Constraints[0].ConstraintName); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadAnnotatedRelations_MultipleColumns() { var ds = new DataSet(); diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetReadXmlTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetReadXmlTest.cs index 0bf6fd5491433..fa45aa582875a 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetReadXmlTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetReadXmlTest.cs @@ -65,7 +65,7 @@ public class DataSetReadXmlTest "; private const string schema2 = schema1 + xml8; - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadSimpleAuto() { DataSet ds; @@ -285,7 +285,7 @@ public void ReadSimpleIgnoreSchema() "NewDataSet", 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadSimpleInferSchema() { DataSet ds; @@ -606,7 +606,7 @@ public void SequentialRead2() DataSetAssertion.AssertDataTable("#3", ds.Tables[0], "root", 1, 2, 0, 0, 0, 0); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadComplexElementDocument() { var ds = new DataSet(); @@ -639,7 +639,7 @@ public void IgnoreSchemaShouldFillData() Assert.Equal(0, dt.Rows.Count); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void NameConflictDSAndTable() { string xml = @" @@ -657,7 +657,7 @@ public void NameConflictDSAndTable() Assert.NotNull(ds.Tables["PriceListDetails"]); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ColumnOrder() { string xml = "" + @@ -690,7 +690,7 @@ public void ColumnOrder() Assert.Equal(3, ds.Tables[0].Columns[3].Ordinal); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void XmlSpace() { string xml = "" + diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetTest.cs index bd35d061c0dd4..4c2e8b38b4e5f 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetTest.cs @@ -367,7 +367,7 @@ public void OwnWriteXmlSchema() Assert.Equal("", TextString); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadWriteXml() { var ds = new DataSet(); @@ -424,7 +424,7 @@ public void ReadWriteXml() Assert.Equal("", TextString); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadWriteXmlDiffGram() { var ds = new DataSet(); @@ -507,7 +507,7 @@ public void ReadWriteXmlDiffGram() Assert.Equal("", TextString); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void WriteXmlSchema() { using (new ThreadCultureChange("fi-FI")) @@ -989,7 +989,7 @@ public void WriteNestedTableXml() Assert.Equal(sw.ToString().Replace("\r\n", "\n"), xml.Replace("\r\n", "\n")); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void WriteXmlToStream() { string xml = "sample textsample text 2"; @@ -1028,7 +1028,7 @@ public void WtiteXmlEncodedXml() Assert.Equal(sw.ToString().Replace("\r\n", "\n"), xml.Replace("\r\n", "\n")); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadWriteXml2() { string xml = ""; @@ -1046,7 +1046,7 @@ public void ReadWriteXml2() Assert.Equal(xml, sw.ToString()); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadWriteXml3() { string input = @" @@ -1559,7 +1559,7 @@ public void WriteXmlModeSchema() Assert.Equal(result.Replace("\r\n", "\n"), xml.Replace("\r\n", "\n")); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void WriteXmlModeSchema1() { // Keeping the brackets as the test otherwise starts to fail. diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs index aec8467dbc609..3cf2295c6ca7e 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs @@ -540,7 +540,7 @@ public void HasErrors() #region test namespaces - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_BasicXml() { StringBuilder sb = new StringBuilder(); @@ -572,7 +572,7 @@ public void InferXmlSchema_BasicXml() Assert.Equal("Discontinued", ds.Tables[1].Columns[2].ColumnName); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_WithoutIgnoreNameSpaces() { StringBuilder sb = new StringBuilder(); @@ -597,7 +597,7 @@ public void InferXmlSchema_WithoutIgnoreNameSpaces() Assert.Equal(8, ds.Tables.Count); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_IgnoreNameSpace() { StringBuilder sb = new StringBuilder(); @@ -637,7 +637,7 @@ public void InferXmlSchema_IgnoreNameSpace() Assert.Equal("Discontinued", ds.Tables[2].Columns["Discontinued"].ColumnName); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_IgnoreNameSpaces() //Ignoring 2 namespaces { StringBuilder sb = new StringBuilder(); @@ -667,7 +667,7 @@ public void InferXmlSchema_IgnoreNameSpaces() //Ignoring 2 namespaces #endregion #region inferringTables - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_inferringTables1() { //According to the msdn documantaion : @@ -691,7 +691,7 @@ public void InferXmlSchema_inferringTables1() Assert.Equal("Element1_Text", ds.Tables[0].Columns["Element1_Text"].ColumnName); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_inferringTables2() { //According to the msdn documantaion : @@ -741,7 +741,7 @@ public void InferXmlSchema_inferringTables3() Assert.Equal("Element2", ds.Tables[0].Columns["Element2"].ColumnName); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_inferringTables4() { //According to the msdn documantaion : @@ -766,7 +766,7 @@ public void InferXmlSchema_inferringTables4() Assert.Equal("attr2", ds.Tables[0].Columns["attr2"].ColumnName); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_inferringTables5() { //According to the msdn documantaion : @@ -791,7 +791,7 @@ public void InferXmlSchema_inferringTables5() #endregion #region inferringColumns - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_inferringColumns1() { //ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconinferringcolumns.htm @@ -815,7 +815,7 @@ public void InferXmlSchema_inferringColumns1() Assert.Equal(typeof(string), ds.Tables[0].Columns["attr2"].DataType); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_inferringColumns2() { //ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconinferringcolumns.htm @@ -850,7 +850,7 @@ public void InferXmlSchema_inferringColumns2() #region Inferring Relationships - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_inferringRelationships1() { //ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconinferringrelationships.htm @@ -914,7 +914,7 @@ public void InferXmlSchema_inferringRelationships1() #region Inferring Element Text - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_elementText1() { //ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconinferringelementtext.htm @@ -942,7 +942,7 @@ public void InferXmlSchema_elementText1() Assert.Equal(typeof(string), ds.Tables["Element1"].Columns["Element1_Text"].DataType); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void InferXmlSchema_elementText2() { //ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconinferringelementtext.htm @@ -988,7 +988,7 @@ public void Locale() Assert.Equal(culInfo, ds.Locale); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void DataSetSpecificCulture() { using (new ThreadCultureChange("cs-CZ")) @@ -2235,7 +2235,7 @@ public void ReadXml_Strm2() // Tables[2] ParentRelations[0] name Assert.Equal("Stock_Price", ds.Tables[2].ParentRelations[0].RelationName); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadXml_Strm3() { DataSet ds = new DataSet("TestDataSet"); @@ -2264,7 +2264,7 @@ public void ReadXml_Strm3() Assert.Equal(MappingType.Hidden, ds.Tables["Price"].Columns["Stock_Id"].ColumnMapping); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadXml_Strm4() { _ds = new DataSet("Stocks"); @@ -2365,7 +2365,7 @@ private void privateTestCase(string name, string toTable, string toTestSelect, s Assert.Equal(_ds.Tables[toTable].Select(toTestSelect)[0]["Stock_Id"], _ds.Tables[toCompareTable].Select(toCompareSelect)[0]["Stock_Id"]); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadXml_Strm5() { string xmlData; @@ -2589,7 +2589,7 @@ private string dataSetDescription(DataSet ds) return desc; } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadXml_Strm6() { // TC1 @@ -2608,7 +2608,7 @@ public void ReadXml_Strm6() Assert.Equal(3, ds.Tables["c"].Rows.Count); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadXmlSchema_2() { var ds = new DataSet(); @@ -3070,7 +3070,7 @@ private void CheckNode(string description, string xPath, int expectedNodesCout, Assert.Equal(expectedNodesCout, actualNodeCount); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void WriteXml_Stream() { { @@ -3515,7 +3515,7 @@ private void AssertDataTableValues(DataTable dt) Assert.Equal("data8", dt.Rows[0]["&ID"]); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void Bug537229_BinFormatSerializer_Test() { DataSet ds = new DataSet(); diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs index cc5d61cdac4a7..b2f99a484f97d 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs @@ -40,7 +40,7 @@ public class DataSetTypedDataSetTest { private string _eventStatus = string.Empty; - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TypedDataSet() { int i = 0; diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataTableExtensionsTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataTableExtensionsTest.cs index e3f53fe429ab6..8608ba7bd645d 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataTableExtensionsTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataTableExtensionsTest.cs @@ -5,6 +5,7 @@ namespace System.Data.Tests { + [PlatformSpecific(~TestPlatforms.Browser)] public class DataTableExtensionsTest { private DataTable _dt; diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs index 59191f5226fea..6483f7b96f063 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs @@ -53,7 +53,7 @@ private DataSet CreateTestSet() return ds; } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void SuspiciousDataSetElement() { string schema = @" @@ -108,7 +108,7 @@ public void UnusedComplexTypesIgnored() }); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void IsDataSetAndTypeIgnored() { string xsbase = @" @@ -140,7 +140,7 @@ public void IsDataSetAndTypeIgnored() }); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void NestedReferenceNotAllowed() { string xs = @" @@ -194,7 +194,7 @@ public void LocaleOnRootWithoutIsDataSet() DataSetAssertion.AssertDataColumn("col2", dt.Columns[1], "Child", false, false, 0, 1, "Child", MappingType.Element, typeof(string), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void PrefixedTargetNS() { string xs = @" @@ -308,7 +308,7 @@ public void TestSampleFileSimpleTables() DataSetAssertion.AssertDataColumn("att2", dt.Columns["att2"], "att2", true, false, 0, 1, "att2", MappingType.Attribute, typeof(int), 2, string.Empty, -1, string.Empty, /*1*/-1, string.Empty, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TestSampleFileComplexTables3() { var ds = new DataSet(); @@ -338,7 +338,7 @@ public void TestSampleFileComplexTables3() DataSetAssertion.AssertDataColumn("simple", dt.Columns[1], "e_text", false, false, 0, 1, "e_text", MappingType.SimpleContent, typeof(decimal), DBNull.Value, string.Empty, -1, string.Empty, 1, string.Empty, false, false); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TestSampleFileXPath() { var ds = new DataSet(); @@ -428,7 +428,7 @@ public void ReadConstraints() Assert.Equal("Constraint1", ds.Tables[0].Constraints[0].ConstraintName); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void XsdSchemaSerializationIgnoresLocale() { var serializer = new BinaryFormatter(); @@ -475,7 +475,7 @@ public void XsdSchemaSerializationIgnoresLocale() Assert.DoesNotContain("()2", rawSchemaXML); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, ".NET Framework does not have the fix for this bug")] public void XsdSchemaDeserializationIgnoresLocale() { diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs index 2202651e330eb..9047247343334 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs @@ -375,7 +375,7 @@ public void SelectOperators() } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void DataColumnTypeSerialization() { DataTable dt = new DataTable("MyTable"); @@ -1767,7 +1767,7 @@ public void TestWriteXmlSchema3() Assert.Equal("", textString); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void Serialize() { // Create an array with multiple elements refering to @@ -2887,7 +2887,7 @@ public void ReadXmlSchema() Assert.True(column3.Unique); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void ReadXmlSchema_2() { DataTable dt = new DataTable(); @@ -3111,7 +3111,7 @@ public void ReadXmlSchema_ByXmlReader() Assert.Equal(0, dt2.Rows.Count); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void WriteXmlSchema() { using (new ThreadCultureChange("en-GB")) diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataTableTest4.cs b/src/libraries/System.Data.Common/tests/System/Data/DataTableTest4.cs index 4fa0a6308fa76..da6cabc4ecd1b 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataTableTest4.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataTableTest4.cs @@ -870,7 +870,7 @@ public void XmlTest7() Assert.Equal(3, row["ParentID"]); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void XmlTest8() { MakeParentTable1(); @@ -910,7 +910,7 @@ public void XmlTest8() Assert.Equal("3", row["DepartmentID"]); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void XmlTest9() { MakeParentTable1(); diff --git a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs index 1f6fb8536ea45..0cae8f7a40409 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs @@ -37,7 +37,7 @@ public static class SqlStringSortingTest private static readonly UnicodeEncoding s_unicodeEncoding = new UnicodeEncoding(bigEndian: false, byteOrderMark: false, throwOnInvalidBytes: true); - [ConditionalTheory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] [InlineData("ja-JP", 0x0411)] // Japanese - Japan [InlineData("ar-SA", 0x0401)] // Arabic - Saudi Arabia [InlineData("de-DE", 0x0407)] // German - Germany diff --git a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringTest.cs b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringTest.cs index d123a60bf4e0b..86a4b1683c4c9 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringTest.cs @@ -62,7 +62,7 @@ public void Constructor_Value_Success() ValidateProperties(value, CultureInfo.CurrentCulture, new SqlString(value)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] [InlineData(1033, "en-US")] [InlineData(1036, "fr-FR")] public void Constructor_ValueLcid_Success(int lcid, string name) @@ -97,35 +97,38 @@ public void Create() SqlString testString = new SqlString("Test"); Assert.Equal("Test", testString.Value); - // SqlString (String, int) - testString = new SqlString("Test", 2057); - Assert.Equal(2057, testString.LCID); - - // SqlString (int, SqlCompareOptions, byte[]) - testString = new SqlString(2057, - SqlCompareOptions.BinarySort | SqlCompareOptions.IgnoreCase, - new byte[2] { 123, 221 }); - Assert.Equal(2057, testString.CompareInfo.LCID); - - // SqlString(string, int, SqlCompareOptions) - testString = new SqlString("Test", 2057, SqlCompareOptions.IgnoreNonSpace); - Assert.False(testString.IsNull); - - // SqlString (int, SqlCompareOptions, byte[], bool) - testString = new SqlString(2057, SqlCompareOptions.BinarySort, new byte[4] { 100, 100, 200, 45 }, true); - Assert.Equal((byte)63, testString.GetNonUnicodeBytes()[0]); - testString = new SqlString(2057, SqlCompareOptions.BinarySort, new byte[2] { 113, 100 }, false); - Assert.Equal("qd", testString.Value); - - // SqlString (int, SqlCompareOptions, byte[], int, int) - testString = new SqlString(2057, SqlCompareOptions.BinarySort, new byte[2] { 113, 100 }, 0, 2); - Assert.False(testString.IsNull); - - // SqlString (int, SqlCompareOptions, byte[], int, int, bool) - testString = new SqlString(2057, SqlCompareOptions.IgnoreCase, new byte[3] { 100, 111, 50 }, 1, 2, false); - Assert.Equal("o2", testString.Value); - testString = new SqlString(2057, SqlCompareOptions.IgnoreCase, new byte[3] { 123, 111, 222 }, 1, 2, true); - Assert.False(testString.IsNull); + if (PlatformDetection.IsNotInvariantGlobalization) + { + // SqlString (String, int) + testString = new SqlString("Test", 2057); + Assert.Equal(2057, testString.LCID); + + // SqlString (int, SqlCompareOptions, byte[]) + testString = new SqlString(2057, + SqlCompareOptions.BinarySort | SqlCompareOptions.IgnoreCase, + new byte[2] { 123, 221 }); + Assert.Equal(2057, testString.CompareInfo.LCID); + + // SqlString(string, int, SqlCompareOptions) + testString = new SqlString("Test", 2057, SqlCompareOptions.IgnoreNonSpace); + Assert.False(testString.IsNull); + + // SqlString (int, SqlCompareOptions, byte[], bool) + testString = new SqlString(2057, SqlCompareOptions.BinarySort, new byte[4] { 100, 100, 200, 45 }, true); + Assert.Equal((byte)63, testString.GetNonUnicodeBytes()[0]); + testString = new SqlString(2057, SqlCompareOptions.BinarySort, new byte[2] { 113, 100 }, false); + Assert.Equal("qd", testString.Value); + + // SqlString (int, SqlCompareOptions, byte[], int, int) + testString = new SqlString(2057, SqlCompareOptions.BinarySort, new byte[2] { 113, 100 }, 0, 2); + Assert.False(testString.IsNull); + + // SqlString (int, SqlCompareOptions, byte[], int, int, bool) + testString = new SqlString(2057, SqlCompareOptions.IgnoreCase, new byte[3] { 100, 111, 50 }, 1, 2, false); + Assert.Equal("o2", testString.Value); + testString = new SqlString(2057, SqlCompareOptions.IgnoreCase, new byte[3] { 123, 111, 222 }, 1, 2, true); + Assert.False(testString.IsNull); + } } [Fact] @@ -170,7 +173,7 @@ public void PublicFields() } // Test properties - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void Properties() { using (new ThreadCultureChange("en-AU")) @@ -207,7 +210,7 @@ public void CompareToArgumentException() AssertExtensions.Throws(null, () => _test1.CompareTo(test)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void CompareToSqlTypeException() { SqlString t1 = new SqlString("test", 2057, SqlCompareOptions.IgnoreCase); @@ -215,7 +218,7 @@ public void CompareToSqlTypeException() Assert.Throws(() => t1.CompareTo(t2)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void CompareTo() { Assert.True(_test1.CompareTo(_test3) < 0); diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index 460378ec8add0..43c433a188747 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -24,7 +24,6 @@ - From 49bdd54da33d815aec1faa0e20af01d1c41ee480 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Thu, 16 Jul 2020 17:13:43 -0400 Subject: [PATCH 2/4] Removed unnecessary console.writeline --- .../tests/System/Data/Common/DbProviderFactoriesTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoriesTests.cs b/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoriesTests.cs index f395e64bb25ee..2537fb30e95db 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoriesTests.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/Common/DbProviderFactoriesTests.cs @@ -70,7 +70,6 @@ public void GetFactoryWithDataRowTest() public void RegisterFactoryWithTypeNameTest() { ClearRegisteredFactories(); - Console.WriteLine("Name: " + typeof(System.Data.SqlClient.SqlClientFactory).AssemblyQualifiedName); RegisterSqlClientAndTestRegistration(()=>DbProviderFactories.RegisterFactory("System.Data.SqlClient", typeof(System.Data.SqlClient.SqlClientFactory).AssemblyQualifiedName)); } From fbb69013f553dcb495c544b3f12698587641d31f Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Mon, 3 Aug 2020 09:10:38 -0400 Subject: [PATCH 3/4] Removed PNSE off of a few types based on feedback. Skipped tests that were failing b/c of binaryformatter not being supported --- .../src/System.Data.Common.csproj | 6 +- .../Data/Common/DbProviderFactories.Any.cs | 71 ------------------- .../Common/DbProviderFactories.Browser.cs | 30 -------- .../System/Data/Common/DbProviderFactories.cs | 59 +++++++++++++++ .../System/Data/DataTableExtensions.Any.cs | 39 ---------- .../Data/DataTableExtensions.Browser.cs | 37 ---------- .../src/System/Data/DataTableExtensions.cs | 25 ++++++- .../tests/SuitePlatformDetection.cs | 15 ++++ .../tests/System.Data.Common.Tests.csproj | 1 + .../tests/System/Data/DataSetTest2.cs | 2 +- .../System/Data/DataSetTypedDataSetTest.cs | 2 +- .../System/Data/DataTableReadXmlSchemaTest.cs | 4 +- .../tests/System/Data/DataTableTest.cs | 4 +- .../tests/System/Data/FacadeTest.cs | 1 + 14 files changed, 107 insertions(+), 189 deletions(-) delete mode 100644 src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Any.cs delete mode 100644 src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Browser.cs delete mode 100644 src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Any.cs delete mode 100644 src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Browser.cs create mode 100644 src/libraries/System.Data.Common/tests/SuitePlatformDetection.cs diff --git a/src/libraries/System.Data.Common/src/System.Data.Common.csproj b/src/libraries/System.Data.Common/src/System.Data.Common.csproj index f4ca189489099..5e445cebc31df 100644 --- a/src/libraries/System.Data.Common/src/System.Data.Common.csproj +++ b/src/libraries/System.Data.Common/src/System.Data.Common.csproj @@ -1,7 +1,7 @@ true - $(NetCoreAppCurrent);$(NetCoreAppCurrent)-Browser + $(NetCoreAppCurrent) enable @@ -77,8 +77,6 @@ Component - - @@ -218,8 +216,6 @@ - - diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Any.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Any.cs deleted file mode 100644 index d0529dad09e0c..0000000000000 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Any.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace System.Data.Common -{ - public static partial class DbProviderFactories - { - private const string AssemblyQualifiedNameColumnName = "AssemblyQualifiedName"; - private const string InvariantNameColumnName = "InvariantName"; - private const string NameColumnName = "Name"; - private const string DescriptionColumnName = "Description"; - private const string ProviderGroupColumnName = "DbProviderFactories"; - - public static DbProviderFactory GetFactory(string providerInvariantName) - { - return GetFactory(providerInvariantName, throwOnError: true)!; - } - - public static DbProviderFactory GetFactory(DataRow providerRow) - { - ADP.CheckArgumentNull(providerRow, nameof(providerRow)); - - DataColumn? assemblyQualifiedNameColumn = providerRow.Table.Columns[AssemblyQualifiedNameColumnName]; - if (null == assemblyQualifiedNameColumn) - { - throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); - } - - string? assemblyQualifiedName = providerRow[assemblyQualifiedNameColumn] as string; - if (string.IsNullOrWhiteSpace(assemblyQualifiedName)) - { - throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); - } - - return GetFactoryInstance(GetProviderTypeFromTypeName(assemblyQualifiedName)); - } - - - public static DbProviderFactory? GetFactory(DbConnection connection) - { - ADP.CheckArgumentNull(connection, nameof(connection)); - - return connection.ProviderFactory; - } - - public static DataTable GetFactoryClasses() - { - DataColumn nameColumn = new DataColumn(NameColumnName, typeof(string)) { ReadOnly = true }; - DataColumn descriptionColumn = new DataColumn(DescriptionColumnName, typeof(string)) { ReadOnly = true }; - DataColumn invariantNameColumn = new DataColumn(InvariantNameColumnName, typeof(string)) { ReadOnly = true }; - DataColumn assemblyQualifiedNameColumn = new DataColumn(AssemblyQualifiedNameColumnName, typeof(string)) { ReadOnly = true }; - - DataTable toReturn = new DataTable(ProviderGroupColumnName) { Locale = CultureInfo.InvariantCulture }; - toReturn.Columns.AddRange(new[] { nameColumn, descriptionColumn, invariantNameColumn, assemblyQualifiedNameColumn }); - toReturn.PrimaryKey = new[] { invariantNameColumn }; - foreach (var kvp in _registeredFactories) - { - DataRow newRow = toReturn.NewRow(); - newRow[InvariantNameColumnName] = kvp.Key; - newRow[AssemblyQualifiedNameColumnName] = kvp.Value.FactoryTypeAssemblyQualifiedName; - newRow[NameColumnName] = string.Empty; - newRow[DescriptionColumnName] = string.Empty; - toReturn.AddRow(newRow); - } - return toReturn; - } - } -} - diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Browser.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Browser.cs deleted file mode 100644 index 21dedd1d26ace..0000000000000 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.Browser.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; - -namespace System.Data.Common -{ - public static partial class DbProviderFactories - { - public static DbProviderFactory GetFactory(string providerInvariantName) - { - throw new PlatformNotSupportedException(); - } - - public static DbProviderFactory GetFactory(DataRow providerRow) - { - throw new PlatformNotSupportedException(); - } - - public static DbProviderFactory? GetFactory(DbConnection connection) - { - throw new PlatformNotSupportedException(); - } - - public static DataTable GetFactoryClasses() - { - throw new PlatformNotSupportedException(); - } - } -} \ No newline at end of file diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs index b0da326ec02f2..2ad35f787cdee 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/DbProviderFactories.cs @@ -33,6 +33,11 @@ internal ProviderRegistration(string factoryTypeAssemblyQualifiedName, DbProvide } private static readonly ConcurrentDictionary _registeredFactories = new ConcurrentDictionary(); + private const string AssemblyQualifiedNameColumnName = "AssemblyQualifiedName"; + private const string InvariantNameColumnName = "InvariantName"; + private const string NameColumnName = "Name"; + private const string DescriptionColumnName = "Description"; + private const string ProviderGroupColumnName = "DbProviderFactories"; private const string InstanceFieldName = "Instance"; public static bool TryGetFactory(string providerInvariantName, [NotNullWhen(true)] out DbProviderFactory? factory) @@ -41,6 +46,60 @@ public static bool TryGetFactory(string providerInvariantName, [NotNullWhen(true return factory != null; } + public static DbProviderFactory GetFactory(string providerInvariantName) + { + return GetFactory(providerInvariantName, throwOnError: true)!; + } + + public static DbProviderFactory GetFactory(DataRow providerRow) + { + ADP.CheckArgumentNull(providerRow, nameof(providerRow)); + + DataColumn? assemblyQualifiedNameColumn = providerRow.Table.Columns[AssemblyQualifiedNameColumnName]; + if (null == assemblyQualifiedNameColumn) + { + throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); + } + + string? assemblyQualifiedName = providerRow[assemblyQualifiedNameColumn] as string; + if (string.IsNullOrWhiteSpace(assemblyQualifiedName)) + { + throw ADP.Argument(SR.ADP_DbProviderFactories_NoAssemblyQualifiedName); + } + + return GetFactoryInstance(GetProviderTypeFromTypeName(assemblyQualifiedName)); + } + + + public static DbProviderFactory? GetFactory(DbConnection connection) + { + ADP.CheckArgumentNull(connection, nameof(connection)); + + return connection.ProviderFactory; + } + + public static DataTable GetFactoryClasses() + { + DataColumn nameColumn = new DataColumn(NameColumnName, typeof(string)) { ReadOnly = true }; + DataColumn descriptionColumn = new DataColumn(DescriptionColumnName, typeof(string)) { ReadOnly = true }; + DataColumn invariantNameColumn = new DataColumn(InvariantNameColumnName, typeof(string)) { ReadOnly = true }; + DataColumn assemblyQualifiedNameColumn = new DataColumn(AssemblyQualifiedNameColumnName, typeof(string)) { ReadOnly = true }; + + DataTable toReturn = new DataTable(ProviderGroupColumnName) { Locale = CultureInfo.InvariantCulture }; + toReturn.Columns.AddRange(new[] { nameColumn, descriptionColumn, invariantNameColumn, assemblyQualifiedNameColumn }); + toReturn.PrimaryKey = new[] { invariantNameColumn }; + foreach (var kvp in _registeredFactories) + { + DataRow newRow = toReturn.NewRow(); + newRow[InvariantNameColumnName] = kvp.Key; + newRow[AssemblyQualifiedNameColumnName] = kvp.Value.FactoryTypeAssemblyQualifiedName; + newRow[NameColumnName] = string.Empty; + newRow[DescriptionColumnName] = string.Empty; + toReturn.AddRow(newRow); + } + return toReturn; + } + public static IEnumerable GetProviderInvariantNames() { return _registeredFactories.Keys.ToList(); diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Any.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Any.cs deleted file mode 100644 index a13371974e6ec..0000000000000 --- a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Any.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; - -namespace System.Data -{ - - /// - /// This static class defines the DataTable extension methods. - /// - public static partial class DataTableExtensions - { - /// - /// Creates a LinkDataView of DataRow over the input table. - /// - /// DataTable that the view is over. - /// An instance of LinkDataView. - public static DataView AsDataView(this DataTable table) - { - DataSetUtil.CheckArgumentNull(table, nameof(table)); - return new LinqDataView(table, null); - } - - /// - /// Creates a LinqDataView from EnumerableDataTable - /// - /// Type of the row in the table. Must inherit from DataRow - /// The enumerable-datatable over which view must be created. - /// Generated LinkDataView of type T - public static DataView AsDataView(this EnumerableRowCollection source) where T : DataRow - { - DataSetUtil.CheckArgumentNull>(source, nameof(source)); - return source.GetLinqDataView(); - } - } -} diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Browser.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Browser.cs deleted file mode 100644 index 01ebf2fcfff7f..0000000000000 --- a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.Browser.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; - -namespace System.Data -{ - - /// - /// This static class defines the DataTable extension methods. - /// - public static partial class DataTableExtensions - { - /// - /// Creates a LinkDataView of DataRow over the input table. - /// - /// DataTable that the view is over. - /// An instance of LinkDataView. - public static DataView AsDataView(this DataTable table) - { - throw new PlatformNotSupportedException(); - } - - /// - /// Creates a LinqDataView from EnumerableDataTable - /// - /// Type of the row in the table. Must inherit from DataRow - /// The enumerable-datatable over which view must be created. - /// Generated LinkDataView of type T - public static DataView AsDataView(this EnumerableRowCollection source) where T : DataRow - { - throw new PlatformNotSupportedException(); - } - } -} diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.cs b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.cs index e457da43df7e1..c5a04f760f67b 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTableExtensions.cs @@ -11,7 +11,7 @@ namespace System.Data /// /// This static class defines the DataTable extension methods. /// - public static partial class DataTableExtensions + public static class DataTableExtensions { /// /// This method returns a IEnumerable of Datarows. @@ -218,5 +218,28 @@ private static DataTable LoadTableFromEnumerable(IEnumerable source, DataT Debug.Assert(null != table, "null DataTable"); return table; } + + /// + /// Creates a LinkDataView of DataRow over the input table. + /// + /// DataTable that the view is over. + /// An instance of LinkDataView. + public static DataView AsDataView(this DataTable table) + { + DataSetUtil.CheckArgumentNull(table, nameof(table)); + return new LinqDataView(table, null); + } + + /// + /// Creates a LinqDataView from EnumerableDataTable + /// + /// Type of the row in the table. Must inherit from DataRow + /// The enumerable-datatable over which view must be created. + /// Generated LinkDataView of type T + public static DataView AsDataView(this EnumerableRowCollection source) where T : DataRow + { + DataSetUtil.CheckArgumentNull>(source, nameof(source)); + return source.GetLinqDataView(); + } } } diff --git a/src/libraries/System.Data.Common/tests/SuitePlatformDetection.cs b/src/libraries/System.Data.Common/tests/SuitePlatformDetection.cs new file mode 100644 index 0000000000000..8cafa04bf6f4e --- /dev/null +++ b/src/libraries/System.Data.Common/tests/SuitePlatformDetection.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace System +{ + public static class SuitePlatformDetection + { + // + // Do not use the " { get; } = " pattern here. Having all the initialization happen in the type initializer + // means that one exception anywhere means all tests using PlatformDetection fail. If you feel a value is worth latching, + // do it in a way that failures don't cascade. + // + public static bool IsBinaryFormatterSupportedAndNotInvariantGlobalization => PlatformDetection.IsBinaryFormatterSupported && PlatformDetection.IsNotInvariantGlobalization; + } +} diff --git a/src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj b/src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj index 3eff311a0a4bf..1ca047fd1e666 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj +++ b/src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj @@ -105,6 +105,7 @@ + diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs index 3cf2295c6ca7e..d5552aa9b244d 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs @@ -3515,7 +3515,7 @@ private void AssertDataTableValues(DataTable dt) Assert.Equal("data8", dt.Rows[0]["&ID"]); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] public void Bug537229_BinFormatSerializer_Test() { DataSet ds = new DataSet(); diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs index b2f99a484f97d..bd61485905fe9 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs @@ -40,7 +40,7 @@ public class DataSetTypedDataSetTest { private string _eventStatus = string.Empty; - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] public void TypedDataSet() { int i = 0; diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs index 6483f7b96f063..d8c9a9ad00feb 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs @@ -428,7 +428,7 @@ public void ReadConstraints() Assert.Equal("Constraint1", ds.Tables[0].Constraints[0].ConstraintName); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] public void XsdSchemaSerializationIgnoresLocale() { var serializer = new BinaryFormatter(); @@ -475,7 +475,7 @@ public void XsdSchemaSerializationIgnoresLocale() Assert.DoesNotContain("()2", rawSchemaXML); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, ".NET Framework does not have the fix for this bug")] public void XsdSchemaDeserializationIgnoresLocale() { diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs index 9047247343334..31e069394dff5 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs @@ -375,7 +375,7 @@ public void SelectOperators() } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] public void DataColumnTypeSerialization() { DataTable dt = new DataTable("MyTable"); @@ -1767,7 +1767,7 @@ public void TestWriteXmlSchema3() Assert.Equal("", textString); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] public void Serialize() { // Create an array with multiple elements refering to diff --git a/src/libraries/System.Data.Common/tests/System/Data/FacadeTest.cs b/src/libraries/System.Data.Common/tests/System/Data/FacadeTest.cs index 49540efe7a7eb..f8eba45d7f5c4 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/FacadeTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/FacadeTest.cs @@ -10,6 +10,7 @@ public class FacadeTest [Theory] [InlineData("Microsoft.SqlServer.Server.SqlMetaData")] // Type from System.Data.SqlClient [InlineData("System.Data.SqlTypes.SqlBytes")] // Type from System.Data.Common + [PlatformSpecific(~TestPlatforms.Browser)] public void TestSystemData(string typeName) { // Verify that the type can be loaded via .NET Framework compat facade From 342a015497a77e27ab4ababa4e7b8cc9f7a208d8 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Mon, 3 Aug 2020 10:27:57 -0400 Subject: [PATCH 4/4] Feedback --- .../tests/SuitePlatformDetection.cs | 15 --------------- .../tests/System.Data.Common.Tests.csproj | 1 - .../tests/System/Data/DataSetTest2.cs | 2 +- .../tests/System/Data/DataSetTypedDataSetTest.cs | 2 +- .../System/Data/DataTableReadXmlSchemaTest.cs | 4 ++-- .../tests/System/Data/DataTableTest.cs | 4 ++-- 6 files changed, 6 insertions(+), 22 deletions(-) delete mode 100644 src/libraries/System.Data.Common/tests/SuitePlatformDetection.cs diff --git a/src/libraries/System.Data.Common/tests/SuitePlatformDetection.cs b/src/libraries/System.Data.Common/tests/SuitePlatformDetection.cs deleted file mode 100644 index 8cafa04bf6f4e..0000000000000 --- a/src/libraries/System.Data.Common/tests/SuitePlatformDetection.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace System -{ - public static class SuitePlatformDetection - { - // - // Do not use the " { get; } = " pattern here. Having all the initialization happen in the type initializer - // means that one exception anywhere means all tests using PlatformDetection fail. If you feel a value is worth latching, - // do it in a way that failures don't cascade. - // - public static bool IsBinaryFormatterSupportedAndNotInvariantGlobalization => PlatformDetection.IsBinaryFormatterSupported && PlatformDetection.IsNotInvariantGlobalization; - } -} diff --git a/src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj b/src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj index 1ca047fd1e666..3eff311a0a4bf 100644 --- a/src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj +++ b/src/libraries/System.Data.Common/tests/System.Data.Common.Tests.csproj @@ -105,7 +105,6 @@ - diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs index d5552aa9b244d..d5943b3da388c 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetTest2.cs @@ -3515,7 +3515,7 @@ private void AssertDataTableValues(DataTable dt) Assert.Equal("data8", dt.Rows[0]["&ID"]); } - [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void Bug537229_BinFormatSerializer_Test() { DataSet ds = new DataSet(); diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs index bd61485905fe9..856b779e8c11a 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataSetTypedDataSetTest.cs @@ -40,7 +40,7 @@ public class DataSetTypedDataSetTest { private string _eventStatus = string.Empty; - [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void TypedDataSet() { int i = 0; diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs index d8c9a9ad00feb..17bb95df00d1a 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataTableReadXmlSchemaTest.cs @@ -428,7 +428,7 @@ public void ReadConstraints() Assert.Equal("Constraint1", ds.Tables[0].Constraints[0].ConstraintName); } - [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void XsdSchemaSerializationIgnoresLocale() { var serializer = new BinaryFormatter(); @@ -475,7 +475,7 @@ public void XsdSchemaSerializationIgnoresLocale() Assert.DoesNotContain("()2", rawSchemaXML); } - [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported), nameof(PlatformDetection.IsNotInvariantGlobalization))] [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, ".NET Framework does not have the fix for this bug")] public void XsdSchemaDeserializationIgnoresLocale() { diff --git a/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs b/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs index 31e069394dff5..df8276d0aac4e 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/DataTableTest.cs @@ -375,7 +375,7 @@ public void SelectOperators() } - [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void DataColumnTypeSerialization() { DataTable dt = new DataTable("MyTable"); @@ -1767,7 +1767,7 @@ public void TestWriteXmlSchema3() Assert.Equal("", textString); } - [ConditionalFact(typeof(SuitePlatformDetection), nameof(SuitePlatformDetection.IsBinaryFormatterSupportedAndNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsBinaryFormatterSupported), nameof(PlatformDetection.IsNotInvariantGlobalization))] public void Serialize() { // Create an array with multiple elements refering to