diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs
index a0acf34a33..c49e0cd1f9 100644
--- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs
@@ -189,23 +189,23 @@ public class SqlAuthenticationParameters
///
protected SqlAuthenticationParameters(Microsoft.Data.SqlClient.SqlAuthenticationMethod authenticationMethod, string serverName, string databaseName, string resource, string authority, string userId, string password, System.Guid connectionId, int connectionTimeout) { }
///
- public Microsoft.Data.SqlClient.SqlAuthenticationMethod AuthenticationMethod { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public Microsoft.Data.SqlClient.SqlAuthenticationMethod AuthenticationMethod { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
///
- public string Authority { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public string Authority { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
///
- public System.Guid ConnectionId { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public System.Guid ConnectionId { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
///
- public string DatabaseName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public string DatabaseName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
///
- public string Password { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public string Password { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
///
- public string Resource { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public string Resource { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
///
- public string ServerName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public string ServerName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
///
- public string UserId { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public string UserId { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
///
- public int ConnectionTimeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public int ConnectionTimeout { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
}
///
public abstract partial class SqlAuthenticationProvider
@@ -231,9 +231,9 @@ public partial class SqlAuthenticationToken
///
public SqlAuthenticationToken(string accessToken, System.DateTimeOffset expiresOn) { }
///
- public string AccessToken { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public string AccessToken { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
///
- public System.DateTimeOffset ExpiresOn { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
+ public System.DateTimeOffset ExpiresOn { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } }
}
///
public sealed partial class SqlBulkCopy : System.IDisposable
@@ -427,6 +427,14 @@ internal SqlClientFactory() { }
public override System.Data.Common.DbDataAdapter CreateDataAdapter() { throw null; }
///
public override System.Data.Common.DbParameter CreateParameter() { throw null; }
+ ///
+ public override System.Data.Common.DbDataSourceEnumerator CreateDataSourceEnumerator() { throw null; }
+ ///
+ public override bool CanCreateBatch { get { throw null; } }
+ ///
+ public override System.Data.Common.DbBatch CreateBatch() { throw null; }
+ ///
+ public override System.Data.Common.DbBatchCommand CreateBatchCommand() { throw null; }
}
///
public partial class SqlClientLogger
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
index 57497fd2b0..2cd3537ea7 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -383,6 +383,9 @@
Microsoft\Data\SqlClient\SqlClientEventSource.cs
+
+ Microsoft\Data\SqlClient\SqlClientFactory.cs
+
Microsoft\Data\SqlClient\SqlClientLogger.cs
@@ -646,8 +649,6 @@
-
-
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientFactory.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientFactory.NetCoreApp.cs
deleted file mode 100644
index a48179b621..0000000000
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientFactory.NetCoreApp.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-#if NET6_0_OR_GREATER
-
-using System.Data.Common;
-
-namespace Microsoft.Data.SqlClient
-{
- public sealed partial class SqlClientFactory : DbProviderFactory
- {
- ///
- public override bool CanCreateBatch => true;
-
- ///
- public override DbBatch CreateBatch() => new SqlBatch();
-
- ///
- public override DbBatchCommand CreateBatchCommand() => new SqlBatchCommand();
- }
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientFactory.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientFactory.cs
deleted file mode 100644
index 2dd3261fe6..0000000000
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientFactory.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Data.Common;
-
-namespace Microsoft.Data.SqlClient
-{
- ///
- public sealed partial class SqlClientFactory : DbProviderFactory
- {
- ///
- public static readonly SqlClientFactory Instance = new SqlClientFactory();
-
- private SqlClientFactory()
- {
- }
-
- ///
- public override DbCommand CreateCommand()
- {
- return new SqlCommand();
- }
-
- ///
- public override DbCommandBuilder CreateCommandBuilder()
- {
- return new SqlCommandBuilder();
- }
-
- ///
- public override DbConnection CreateConnection()
- {
- return new SqlConnection();
- }
-
- ///
- public override DbConnectionStringBuilder CreateConnectionStringBuilder()
- {
- return new SqlConnectionStringBuilder();
- }
-
- ///
- public override DbDataAdapter CreateDataAdapter()
- {
- return new SqlDataAdapter();
- }
-
- ///
- public override DbParameter CreateParameter()
- {
- return new SqlParameter();
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
index 2dd8d69b08..e291206a4a 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -423,6 +423,9 @@
Microsoft\Data\SqlClient\SqlClientEventSource.cs
+
+ Microsoft\Data\SqlClient\SqlClientFactory.cs
+
Microsoft\Data\SqlClient\SqlClientLogger.cs
@@ -668,7 +671,6 @@
-
@@ -766,4 +768,4 @@
-
\ No newline at end of file
+
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientFactory.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientFactory.cs
deleted file mode 100644
index 3d44d202c0..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientFactory.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Data.Common;
-using System.Data.Sql;
-using System.Security;
-using System.Security.Permissions;
-using Microsoft.Data.Common;
-
-namespace Microsoft.Data.SqlClient
-{
- ///
- public sealed class SqlClientFactory : DbProviderFactory, IServiceProvider
- {
-
- ///
- public static readonly SqlClientFactory Instance = new SqlClientFactory();
-
- private SqlClientFactory()
- {
- }
-
- ///
- public override bool CanCreateDataSourceEnumerator
- {
- get
- {
- return true;
- }
- }
-
- ///
- public override DbCommand CreateCommand()
- {
- return new SqlCommand();
- }
-
- ///
- public override DbCommandBuilder CreateCommandBuilder()
- {
- return new SqlCommandBuilder();
- }
-
- ///
- public override DbConnection CreateConnection()
- {
- return new SqlConnection();
- }
-
- ///
- public override DbConnectionStringBuilder CreateConnectionStringBuilder()
- {
- return new SqlConnectionStringBuilder();
- }
-
- ///
- public override DbDataAdapter CreateDataAdapter()
- {
- return new SqlDataAdapter();
- }
-
- ///
- public override DbParameter CreateParameter()
- {
- return new SqlParameter();
- }
-
- ///
- public override CodeAccessPermission CreatePermission(PermissionState state)
- {
- return new SqlClientPermission(state);
- }
-
- ///
- public override DbDataSourceEnumerator CreateDataSourceEnumerator()
- {
- return SqlDataSourceEnumerator.Instance;
- }
-
- ///
- /// Extension mechanism for additional services; currently the only service
- /// supported is the DbProviderServices
- ///
- /// requested service provider or null.
- object IServiceProvider.GetService(Type serviceType)
- {
- object result = null;
- if (serviceType == GreenMethods.SystemDataCommonDbProviderServices_Type)
- {
- result = GreenMethods.MicrosoftDataSqlClientSqlProviderServices_Instance();
- }
- return result;
- }
- }
-}
-
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientFactory.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientFactory.cs
new file mode 100644
index 0000000000..eacf4d6e55
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientFactory.cs
@@ -0,0 +1,108 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Microsoft.Data.Sql;
+using System;
+using System.Data.Common;
+using System.Security.Permissions;
+using System.Security;
+using Microsoft.Data.Common;
+
+namespace Microsoft.Data.SqlClient
+{
+ ///
+ public sealed class SqlClientFactory : DbProviderFactory
+#if NETFRAMEWORK
+ , IServiceProvider
+#endif
+ {
+
+ ///
+ public static readonly SqlClientFactory Instance = new SqlClientFactory();
+
+ private SqlClientFactory()
+ {
+ }
+
+ ///
+ public override bool CanCreateDataSourceEnumerator => true;
+
+ ///
+ public override DbCommand CreateCommand()
+ {
+ return new SqlCommand();
+ }
+
+ ///
+ public override DbCommandBuilder CreateCommandBuilder()
+ {
+ return new SqlCommandBuilder();
+ }
+
+ ///
+ public override DbConnection CreateConnection()
+ {
+ return new SqlConnection();
+ }
+
+ ///
+ public override DbConnectionStringBuilder CreateConnectionStringBuilder()
+ {
+ return new SqlConnectionStringBuilder();
+ }
+
+ ///
+ public override DbDataAdapter CreateDataAdapter()
+ {
+ return new SqlDataAdapter();
+ }
+
+ ///
+ public override DbParameter CreateParameter()
+ {
+ return new SqlParameter();
+ }
+
+#if NETFRAMEWORK
+ ///
+ public override CodeAccessPermission CreatePermission(PermissionState state)
+ {
+ return new SqlClientPermission(state);
+ }
+
+ ///
+ /// Extension mechanism for additional services; currently the only service
+ /// supported is the DbProviderServices
+ ///
+ /// requested service provider or null.
+ object IServiceProvider.GetService(Type serviceType)
+ {
+ object result = null;
+ if (serviceType == GreenMethods.SystemDataCommonDbProviderServices_Type)
+ {
+ result = GreenMethods.MicrosoftDataSqlClientSqlProviderServices_Instance();
+ }
+ return result;
+ }
+#endif
+
+ ///
+ public override DbDataSourceEnumerator CreateDataSourceEnumerator()
+ {
+ return SqlDataSourceEnumerator.Instance;
+ }
+
+#if NET6_0_OR_GREATER
+ ///
+ public override bool CanCreateBatch => true;
+
+ ///
+ public override DbBatch CreateBatch() => new SqlBatch();
+
+ ///
+ public override DbBatchCommand CreateBatchCommand() => new SqlBatchCommand();
+#endif
+
+ }
+}
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlClientFactoryTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlClientFactoryTest.cs
index f0e8d39173..b88ae0a260 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlClientFactoryTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlClientFactoryTest.cs
@@ -21,40 +21,34 @@ public void InstanceTest()
public static readonly object[][] FactoryMethodTestData =
{
- new object[] { new Func