diff --git a/build.proj b/build.proj
index 061716db70..af2081f7b6 100644
--- a/build.proj
+++ b/build.proj
@@ -81,7 +81,7 @@
- $(DotNetCmd) dotnet build -c Release"
+ $(DotNetCmd) dotnet build -c Release -p:ReferenceType=$(ReferenceType)"
diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs
index 2b5db7d447..c925335791 100644
--- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs
@@ -5,35 +5,6 @@
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
-namespace Microsoft.Data.SqlClient
-{
- public partial class SqlDataReader : System.Data.Common.IDbColumnSchemaGenerator
- {
- ///
- public System.Collections.ObjectModel.ReadOnlyCollection GetColumnSchema() { throw null; }
- }
-
- ///
- public enum PoolBlockingPeriod
- {
- ///
- Auto = 0,
- ///
- AlwaysBlock = 1,
- ///
- NeverBlock = 2,
- }
-
- ///
- public sealed partial class SqlConnectionStringBuilder : System.Data.Common.DbConnectionStringBuilder
- {
- ///
- [System.ComponentModel.DisplayNameAttribute("Pool Blocking Period")]
- [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
- public PoolBlockingPeriod PoolBlockingPeriod { get { throw null; } set { } }
- }
-}
-
namespace Microsoft.Data.SqlTypes
{
///
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 1fa1f14d05..659f490053 100644
--- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs
@@ -62,6 +62,16 @@ public enum ApplicationIntent
///
ReadWrite = 0
}
+ ///
+ public enum PoolBlockingPeriod
+ {
+ ///
+ Auto = 0,
+ ///
+ AlwaysBlock = 1,
+ ///
+ NeverBlock = 2,
+ }
///
public delegate void OnChangeEventHandler(object sender, Microsoft.Data.SqlClient.SqlNotificationEventArgs e);
///
@@ -965,7 +975,10 @@ public SqlConnectionStringBuilder(string connectionString) { }
[System.ComponentModel.DisplayNameAttribute("Persist Security Info")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public bool PersistSecurityInfo { get { throw null; } set { } }
- ///
+ ///
+ [System.ComponentModel.DisplayNameAttribute("Pool Blocking Period")]
+ [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
+ public PoolBlockingPeriod PoolBlockingPeriod { get { throw null; } set { } }///
[System.ComponentModel.DisplayNameAttribute("Pooling")]
[System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)]
public bool Pooling { get { throw null; } set { } }
@@ -1101,7 +1114,8 @@ public override void Close() { }
public override char GetChar(int i) { throw null; }
///
public override long GetChars(int i, long dataIndex, char[] buffer, int bufferIndex, int length) { throw null; }
- ///
+ ///
+ public System.Collections.ObjectModel.ReadOnlyCollection GetColumnSchema() { throw null; }///
public override string GetDataTypeName(int i) { throw null; }
///
public override System.DateTime GetDateTime(int i) { throw null; }
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 33aab3dd27..d51d6be457 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -383,11 +383,9 @@
-
-
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.NetCoreApp.cs
deleted file mode 100644
index 21de544144..0000000000
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.NetCoreApp.cs
+++ /dev/null
@@ -1,147 +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.Diagnostics;
-using Microsoft.Data.SqlClient;
-
-namespace Microsoft.Data.Common
-{
- internal static partial class DbConnectionStringBuilderUtil
- {
- #region <>
- internal static bool TryConvertToPoolBlockingPeriod(string value, out PoolBlockingPeriod result)
- {
- Debug.Assert(Enum.GetNames(typeof(PoolBlockingPeriod)).Length == 3, "PoolBlockingPeriod enum has changed, update needed");
- Debug.Assert(null != value, "TryConvertToPoolBlockingPeriod(null,...)");
-
- if (StringComparer.OrdinalIgnoreCase.Equals(value, nameof(PoolBlockingPeriod.Auto)))
- {
- result = PoolBlockingPeriod.Auto;
- return true;
- }
- else if (StringComparer.OrdinalIgnoreCase.Equals(value, nameof(PoolBlockingPeriod.AlwaysBlock)))
- {
- result = PoolBlockingPeriod.AlwaysBlock;
- return true;
- }
- else if (StringComparer.OrdinalIgnoreCase.Equals(value, nameof(PoolBlockingPeriod.NeverBlock)))
- {
- result = PoolBlockingPeriod.NeverBlock;
- return true;
- }
- else
- {
- result = DbConnectionStringDefaults.PoolBlockingPeriod;
- return false;
- }
- }
-
- internal static bool IsValidPoolBlockingPeriodValue(PoolBlockingPeriod value)
- {
- Debug.Assert(Enum.GetNames(typeof(PoolBlockingPeriod)).Length == 3, "PoolBlockingPeriod enum has changed, update needed");
- return (uint)value <= (uint)PoolBlockingPeriod.NeverBlock;
- }
-
- internal static string PoolBlockingPeriodToString(PoolBlockingPeriod value)
- {
- Debug.Assert(IsValidPoolBlockingPeriodValue(value));
-
- switch (value)
- {
- case PoolBlockingPeriod.AlwaysBlock:
- return nameof(PoolBlockingPeriod.AlwaysBlock);
- case PoolBlockingPeriod.NeverBlock:
- return nameof(PoolBlockingPeriod.NeverBlock);
- default:
- return nameof(PoolBlockingPeriod.Auto);
- }
- }
-
- ///
- /// This method attempts to convert the given value to a PoolBlockingPeriod enum. The algorithm is:
- /// * if the value is from type string, it will be matched against PoolBlockingPeriod enum names only, using ordinal, case-insensitive comparer
- /// * if the value is from type PoolBlockingPeriod, it will be used as is
- /// * if the value is from integral type (SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, or UInt64), it will be converted to enum
- /// * if the value is another enum or any other type, it will be blocked with an appropriate ArgumentException
- ///
- /// in any case above, if the converted value is out of valid range, the method raises ArgumentOutOfRangeException.
- ///
- /// PoolBlockingPeriod value in the valid range
- internal static PoolBlockingPeriod ConvertToPoolBlockingPeriod(string keyword, object value)
- {
- Debug.Assert(null != value, "ConvertToPoolBlockingPeriod(null)");
- string sValue = (value as string);
- PoolBlockingPeriod result;
- if (null != sValue)
- {
- // We could use Enum.TryParse here, but it accepts value combinations like
- // "ReadOnly, ReadWrite" which are unwelcome here
- // Also, Enum.TryParse is 100x slower than plain StringComparer.OrdinalIgnoreCase.Equals method.
- if (TryConvertToPoolBlockingPeriod(sValue, out result))
- {
- return result;
- }
-
- // try again after remove leading & trailing whitespaces.
- sValue = sValue.Trim();
- if (TryConvertToPoolBlockingPeriod(sValue, out result))
- {
- return result;
- }
-
- // string values must be valid
- throw ADP.InvalidConnectionOptionValue(keyword);
- }
- else
- {
- // the value is not string, try other options
- PoolBlockingPeriod eValue;
-
- if (value is PoolBlockingPeriod)
- {
- // quick path for the most common case
- eValue = (PoolBlockingPeriod)value;
- }
- else if (value.GetType().IsEnum)
- {
- // explicitly block scenarios in which user tries to use wrong enum types, like:
- // builder["PoolBlockingPeriod"] = EnvironmentVariableTarget.Process;
- // workaround: explicitly cast non-PoolBlockingPeriod enums to int
- throw ADP.ConvertFailed(value.GetType(), typeof(PoolBlockingPeriod), null);
- }
- else
- {
- try
- {
- // Enum.ToObject allows only integral and enum values (enums are blocked above), raising ArgumentException for the rest
- eValue = (PoolBlockingPeriod)Enum.ToObject(typeof(PoolBlockingPeriod), value);
- }
- catch (ArgumentException e)
- {
- // to be consistent with the messages we send in case of wrong type usage, replace
- // the error with our exception, and keep the original one as inner one for troubleshooting
- throw ADP.ConvertFailed(value.GetType(), typeof(PoolBlockingPeriod), e);
- }
- }
-
- // ensure value is in valid range
- if (IsValidPoolBlockingPeriodValue(eValue))
- {
- return eValue;
- }
- else
- {
- throw ADP.InvalidEnumerationValue(typeof(ApplicationIntent), (int)eValue);
- }
- }
- }
- #endregion
- }
-
- internal static partial class DbConnectionStringDefaults
- {
- internal const PoolBlockingPeriod PoolBlockingPeriod = Microsoft.Data.SqlClient.PoolBlockingPeriod.Auto;
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs
index f18f1af0bc..0530df9cac 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs
@@ -835,6 +835,135 @@ internal static SqlConnectionColumnEncryptionSetting ConvertToColumnEncryptionSe
}
}
}
+
+ #region <>
+ internal static bool TryConvertToPoolBlockingPeriod(string value, out PoolBlockingPeriod result)
+ {
+ Debug.Assert(Enum.GetNames(typeof(PoolBlockingPeriod)).Length == 3, "PoolBlockingPeriod enum has changed, update needed");
+ Debug.Assert(null != value, "TryConvertToPoolBlockingPeriod(null,...)");
+
+ if (StringComparer.OrdinalIgnoreCase.Equals(value, nameof(PoolBlockingPeriod.Auto)))
+ {
+ result = PoolBlockingPeriod.Auto;
+ return true;
+ }
+ else if (StringComparer.OrdinalIgnoreCase.Equals(value, nameof(PoolBlockingPeriod.AlwaysBlock)))
+ {
+ result = PoolBlockingPeriod.AlwaysBlock;
+ return true;
+ }
+ else if (StringComparer.OrdinalIgnoreCase.Equals(value, nameof(PoolBlockingPeriod.NeverBlock)))
+ {
+ result = PoolBlockingPeriod.NeverBlock;
+ return true;
+ }
+ else
+ {
+ result = DbConnectionStringDefaults.PoolBlockingPeriod;
+ return false;
+ }
+ }
+
+ internal static bool IsValidPoolBlockingPeriodValue(PoolBlockingPeriod value)
+ {
+ Debug.Assert(Enum.GetNames(typeof(PoolBlockingPeriod)).Length == 3, "PoolBlockingPeriod enum has changed, update needed");
+ return (uint)value <= (uint)PoolBlockingPeriod.NeverBlock;
+ }
+
+ internal static string PoolBlockingPeriodToString(PoolBlockingPeriod value)
+ {
+ Debug.Assert(IsValidPoolBlockingPeriodValue(value));
+
+ switch (value)
+ {
+ case PoolBlockingPeriod.AlwaysBlock:
+ return nameof(PoolBlockingPeriod.AlwaysBlock);
+ case PoolBlockingPeriod.NeverBlock:
+ return nameof(PoolBlockingPeriod.NeverBlock);
+ default:
+ return nameof(PoolBlockingPeriod.Auto);
+ }
+ }
+
+ ///
+ /// This method attempts to convert the given value to a PoolBlockingPeriod enum. The algorithm is:
+ /// * if the value is from type string, it will be matched against PoolBlockingPeriod enum names only, using ordinal, case-insensitive comparer
+ /// * if the value is from type PoolBlockingPeriod, it will be used as is
+ /// * if the value is from integral type (SByte, Int16, Int32, Int64, Byte, UInt16, UInt32, or UInt64), it will be converted to enum
+ /// * if the value is another enum or any other type, it will be blocked with an appropriate ArgumentException
+ ///
+ /// in any case above, if the converted value is out of valid range, the method raises ArgumentOutOfRangeException.
+ ///
+ /// PoolBlockingPeriod value in the valid range
+ internal static PoolBlockingPeriod ConvertToPoolBlockingPeriod(string keyword, object value)
+ {
+ Debug.Assert(null != value, "ConvertToPoolBlockingPeriod(null)");
+ string sValue = (value as string);
+ PoolBlockingPeriod result;
+ if (null != sValue)
+ {
+ // We could use Enum.TryParse here, but it accepts value combinations like
+ // "ReadOnly, ReadWrite" which are unwelcome here
+ // Also, Enum.TryParse is 100x slower than plain StringComparer.OrdinalIgnoreCase.Equals method.
+ if (TryConvertToPoolBlockingPeriod(sValue, out result))
+ {
+ return result;
+ }
+
+ // try again after remove leading & trailing whitespaces.
+ sValue = sValue.Trim();
+ if (TryConvertToPoolBlockingPeriod(sValue, out result))
+ {
+ return result;
+ }
+
+ // string values must be valid
+ throw ADP.InvalidConnectionOptionValue(keyword);
+ }
+ else
+ {
+ // the value is not string, try other options
+ PoolBlockingPeriod eValue;
+
+ if (value is PoolBlockingPeriod)
+ {
+ // quick path for the most common case
+ eValue = (PoolBlockingPeriod)value;
+ }
+ else if (value.GetType().IsEnum)
+ {
+ // explicitly block scenarios in which user tries to use wrong enum types, like:
+ // builder["PoolBlockingPeriod"] = EnvironmentVariableTarget.Process;
+ // workaround: explicitly cast non-PoolBlockingPeriod enums to int
+ throw ADP.ConvertFailed(value.GetType(), typeof(PoolBlockingPeriod), null);
+ }
+ else
+ {
+ try
+ {
+ // Enum.ToObject allows only integral and enum values (enums are blocked above), raising ArgumentException for the rest
+ eValue = (PoolBlockingPeriod)Enum.ToObject(typeof(PoolBlockingPeriod), value);
+ }
+ catch (ArgumentException e)
+ {
+ // to be consistent with the messages we send in case of wrong type usage, replace
+ // the error with our exception, and keep the original one as inner one for troubleshooting
+ throw ADP.ConvertFailed(value.GetType(), typeof(PoolBlockingPeriod), e);
+ }
+ }
+
+ // ensure value is in valid range
+ if (IsValidPoolBlockingPeriodValue(eValue))
+ {
+ return eValue;
+ }
+ else
+ {
+ throw ADP.InvalidEnumerationValue(typeof(ApplicationIntent), (int)eValue);
+ }
+ }
+ }
+ #endregion
}
internal static partial class DbConnectionStringDefaults
@@ -874,6 +1003,7 @@ internal static partial class DbConnectionStringDefaults
internal const string TransactionBinding = "Implicit Unbind";
internal const int ConnectRetryCount = 1;
internal const int ConnectRetryInterval = 10;
+ internal const PoolBlockingPeriod PoolBlockingPeriod = Microsoft.Data.SqlClient.PoolBlockingPeriod.Auto;
internal static readonly SqlAuthenticationMethod Authentication = SqlAuthenticationMethod.NotSpecified;
internal const SqlConnectionColumnEncryptionSetting ColumnEncryptionSetting = SqlConnectionColumnEncryptionSetting.Disabled;
internal const string EnclaveAttestationUrl = _emptyString;
@@ -881,7 +1011,6 @@ internal static partial class DbConnectionStringDefaults
internal const SqlConnectionIPAddressPreference IPAddressPreference = SqlConnectionIPAddressPreference.IPv4First;
}
-
internal static partial class DbConnectionStringKeywords
{
// all
@@ -931,9 +1060,7 @@ internal static partial class DbConnectionStringKeywords
internal const string MaxPoolSize = "Max Pool Size";
internal const string Pooling = "Pooling";
internal const string MinPoolSize = "Min Pool Size";
-#if NETCOREAPP
internal const string PoolBlockingPeriod = "Pool Blocking Period";
-#endif
}
internal static class DbConnectionStringSynonyms
@@ -990,10 +1117,8 @@ internal static class DbConnectionStringSynonyms
internal const string NET = "net";
internal const string NETWORK = "network";
-#if NETCOREAPP
//internal const string PoolBlockingPeriod = POOLBLOCKINGPERIOD;
internal const string POOLBLOCKINGPERIOD = "PoolBlockingPeriod";
-#endif
//internal const string Password = Pwd;
internal const string Pwd = "pwd";
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.NetCoreApp.cs
index d678cbae61..c28fcfbb9b 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.NetCoreApp.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.NetCoreApp.cs
@@ -9,31 +9,5 @@ namespace Microsoft.Data.SqlClient
{
internal sealed partial class SqlConnectionString : DbConnectionOptions
{
- internal static partial class DEFAULT
- {
- internal const PoolBlockingPeriod PoolBlockingPeriod = DbConnectionStringDefaults.PoolBlockingPeriod;
- }
-
- private readonly PoolBlockingPeriod _poolBlockingPeriod;
-
- internal PoolBlockingPeriod PoolBlockingPeriod { get { return _poolBlockingPeriod; } }
-
- internal Microsoft.Data.SqlClient.PoolBlockingPeriod ConvertValueToPoolBlockingPeriod()
- {
- string value;
- if (!TryGetParsetableValue(KEY.PoolBlockingPeriod, out value))
- {
- return DEFAULT.PoolBlockingPeriod;
- }
-
- try
- {
- return DbConnectionStringBuilderUtil.ConvertToPoolBlockingPeriod(KEY.PoolBlockingPeriod, value);
- }
- catch (Exception e) when (e is FormatException || e is OverflowException)
- {
- throw ADP.InvalidConnectionOptionValue(KEY.PoolBlockingPeriod, e);
- }
- }
}
}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.cs
index d7c38b4ac0..96a0e65583 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.cs
@@ -41,6 +41,7 @@ internal static partial class DEFAULT
internal const int Packet_Size = 8000;
internal const string Password = _emptyString;
internal const bool Persist_Security_Info = false;
+ internal const PoolBlockingPeriod PoolBlockingPeriod = DbConnectionStringDefaults.PoolBlockingPeriod;
internal const bool Pooling = true;
internal const bool TrustServerCertificate = false;
internal const string Type_System_Version = _emptyString;
@@ -63,9 +64,7 @@ internal static class KEY
internal const string ApplicationIntent = "application intent";
internal const string Application_Name = "application name";
internal const string AttachDBFilename = "attachdbfilename";
-#if NETCOREAPP
internal const string PoolBlockingPeriod = "pool blocking period";
-#endif
internal const string ColumnEncryptionSetting = "column encryption setting";
internal const string EnclaveAttestationUrl = "enclave attestation url";
internal const string AttestationProtocol = "attestation protocol";
@@ -143,10 +142,8 @@ private static class SYNONYM
// network library
internal const string NET = "net";
internal const string NETWORK = "network";
-#if NETCOREAPP
// pool blocking period
internal const string POOLBLOCKINGPERIOD = "poolblockingperiod";
-#endif
// password
internal const string Pwd = "pwd";
// persist security info
@@ -161,11 +158,7 @@ private static class SYNONYM
// make sure to update SynonymCount value below when adding or removing synonyms
}
-#if NETCOREAPP
internal const int SynonymCount = 26;
-#else
- internal const int SynonymCount = 25;
-#endif
internal const int DeprecatedSynonymCount = 2;
internal enum TypeSystem
@@ -207,6 +200,7 @@ internal static class TRANSACTIONBINDING
private readonly bool _enlist;
private readonly bool _mars;
private readonly bool _persistSecurityInfo;
+ private readonly PoolBlockingPeriod _poolBlockingPeriod;
private readonly bool _pooling;
private readonly bool _replication;
private readonly bool _userInstance;
@@ -260,9 +254,7 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G
}
_integratedSecurity = ConvertValueToIntegratedSecurity();
-#if NETCOREAPP
_poolBlockingPeriod = ConvertValueToPoolBlockingPeriod();
-#endif
_encrypt = ConvertValueToBoolean(KEY.Encrypt, DEFAULT.Encrypt);
_enlist = ConvertValueToBoolean(KEY.Enlist, DEFAULT.Enlist);
_mars = ConvertValueToBoolean(KEY.MARS, DEFAULT.MARS);
@@ -519,9 +511,7 @@ internal SqlConnectionString(SqlConnectionString connectionOptions, string dataS
_commandTimeout = connectionOptions._commandTimeout;
_connectTimeout = connectionOptions._connectTimeout;
_loadBalanceTimeout = connectionOptions._loadBalanceTimeout;
-#if NETCOREAPP
_poolBlockingPeriod = connectionOptions._poolBlockingPeriod;
-#endif
_maxPoolSize = connectionOptions._maxPoolSize;
_minPoolSize = connectionOptions._minPoolSize;
_multiSubnetFailover = connectionOptions._multiSubnetFailover;
@@ -593,6 +583,7 @@ internal SqlConnectionString(SqlConnectionString connectionOptions, string dataS
internal string Password { get { return _password; } }
internal string UserID { get { return _userID; } }
internal string WorkstationId { get { return _workstationId; } }
+ internal PoolBlockingPeriod PoolBlockingPeriod { get { return _poolBlockingPeriod; } }
internal TypeSystem TypeSystemVersion { get { return _typeSystemVersion; } }
internal Version TypeSystemAssemblyVersion { get { return _typeSystemAssemblyVersion; } }
@@ -658,9 +649,7 @@ internal static Dictionary GetParseSynonyms()
{ KEY.ApplicationIntent, KEY.ApplicationIntent },
{ KEY.Application_Name, KEY.Application_Name },
{ KEY.AttachDBFilename, KEY.AttachDBFilename },
-#if NETCOREAPP
{ KEY.PoolBlockingPeriod, KEY.PoolBlockingPeriod},
-#endif
{ KEY.Command_Timeout, KEY.Command_Timeout },
{ KEY.Connect_Timeout, KEY.Connect_Timeout },
{ KEY.Connection_Reset, KEY.Connection_Reset },
@@ -711,9 +700,7 @@ internal static Dictionary GetParseSynonyms()
{ SYNONYM.MULTIPLEACTIVERESULTSETS, KEY.MARS },
{ SYNONYM.MULTISUBNETFAILOVER, KEY.MultiSubnetFailover },
{ SYNONYM.NETWORK_ADDRESS, KEY.Data_Source },
-#if NETCOREAPP
{ SYNONYM.POOLBLOCKINGPERIOD, KEY.PoolBlockingPeriod},
-#endif
{ SYNONYM.SERVER, KEY.Data_Source },
{ SYNONYM.DATABASE, KEY.Initial_Catalog },
{ SYNONYM.TRUSTED_CONNECTION, KEY.Integrated_Security },
@@ -932,5 +919,23 @@ internal SqlConnectionIPAddressPreference ConvertValueToIPAddressPreference()
throw ADP.InvalidConnectionOptionValue(KEY.IPAddressPreference, e);
}
}
+
+ internal Microsoft.Data.SqlClient.PoolBlockingPeriod ConvertValueToPoolBlockingPeriod()
+ {
+ string value;
+ if (!TryGetParsetableValue(KEY.PoolBlockingPeriod, out value))
+ {
+ return DEFAULT.PoolBlockingPeriod;
+ }
+
+ try
+ {
+ return DbConnectionStringBuilderUtil.ConvertToPoolBlockingPeriod(KEY.PoolBlockingPeriod, value);
+ }
+ catch (Exception e) when (e is FormatException || e is OverflowException)
+ {
+ throw ADP.InvalidConnectionOptionValue(KEY.PoolBlockingPeriod, e);
+ }
+ }
}
}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.NetCoreApp.cs
deleted file mode 100644
index cbf55f7a8c..0000000000
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.NetCoreApp.cs
+++ /dev/null
@@ -1,42 +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;
-using System.Diagnostics;
-using Microsoft.Data.Common;
-
-namespace Microsoft.Data.SqlClient
-{
- public sealed partial class SqlConnectionStringBuilder : DbConnectionStringBuilder
- {
- private PoolBlockingPeriod _poolBlockingPeriod = DbConnectionStringDefaults.PoolBlockingPeriod;
-
- private void SetPoolBlockingPeriodValue(PoolBlockingPeriod value)
- {
- Debug.Assert(DbConnectionStringBuilderUtil.IsValidPoolBlockingPeriodValue(value), "Invalid value for PoolBlockingPeriod");
- base[DbConnectionStringKeywords.PoolBlockingPeriod] = DbConnectionStringBuilderUtil.PoolBlockingPeriodToString(value);
- }
-
- private static PoolBlockingPeriod ConvertToPoolBlockingPeriod(string keyword, object value)
- {
- return DbConnectionStringBuilderUtil.ConvertToPoolBlockingPeriod(keyword, value);
- }
-
- ///
- public PoolBlockingPeriod PoolBlockingPeriod
- {
- get { return _poolBlockingPeriod; }
- set
- {
- if (!DbConnectionStringBuilderUtil.IsValidPoolBlockingPeriodValue(value))
- {
- throw ADP.InvalidEnumerationValue(typeof(PoolBlockingPeriod), (int)value);
- }
-
- SetPoolBlockingPeriodValue(value);
- _poolBlockingPeriod = value;
- }
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs
index a9f12d9c46..e476a3b131 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs
@@ -33,9 +33,7 @@ private enum Keywords
Pooling,
MinPoolSize,
MaxPoolSize,
-#if NETCOREAPP
PoolBlockingPeriod,
-#endif
MultipleActiveResultSets,
Replication,
ConnectTimeout,
@@ -101,6 +99,7 @@ private enum Keywords
private bool _multipleActiveResultSets = DbConnectionStringDefaults.MultipleActiveResultSets;
private bool _multiSubnetFailover = DbConnectionStringDefaults.MultiSubnetFailover;
private bool _persistSecurityInfo = DbConnectionStringDefaults.PersistSecurityInfo;
+ private PoolBlockingPeriod _poolBlockingPeriod = DbConnectionStringDefaults.PoolBlockingPeriod;
private bool _pooling = DbConnectionStringDefaults.Pooling;
private bool _replication = DbConnectionStringDefaults.Replication;
private bool _userInstance = DbConnectionStringDefaults.UserInstance;
@@ -116,9 +115,7 @@ private static string[] CreateValidKeywords()
validKeywords[(int)Keywords.ApplicationIntent] = DbConnectionStringKeywords.ApplicationIntent;
validKeywords[(int)Keywords.ApplicationName] = DbConnectionStringKeywords.ApplicationName;
validKeywords[(int)Keywords.AttachDBFilename] = DbConnectionStringKeywords.AttachDBFilename;
-#if NETCOREAPP
validKeywords[(int)Keywords.PoolBlockingPeriod] = DbConnectionStringKeywords.PoolBlockingPeriod;
-#endif
validKeywords[(int)Keywords.CommandTimeout] = DbConnectionStringKeywords.CommandTimeout;
validKeywords[(int)Keywords.ConnectTimeout] = DbConnectionStringKeywords.ConnectTimeout;
validKeywords[(int)Keywords.CurrentLanguage] = DbConnectionStringKeywords.CurrentLanguage;
@@ -161,9 +158,7 @@ private static Dictionary CreateKeywordsDictionary()
hash.Add(DbConnectionStringKeywords.ApplicationIntent, Keywords.ApplicationIntent);
hash.Add(DbConnectionStringKeywords.ApplicationName, Keywords.ApplicationName);
hash.Add(DbConnectionStringKeywords.AttachDBFilename, Keywords.AttachDBFilename);
-#if NETCOREAPP
hash.Add(DbConnectionStringKeywords.PoolBlockingPeriod, Keywords.PoolBlockingPeriod);
-#endif
hash.Add(DbConnectionStringKeywords.CommandTimeout, Keywords.CommandTimeout);
hash.Add(DbConnectionStringKeywords.ConnectTimeout, Keywords.ConnectTimeout);
hash.Add(DbConnectionStringKeywords.CurrentLanguage, Keywords.CurrentLanguage);
@@ -213,9 +208,7 @@ private static Dictionary CreateKeywordsDictionary()
hash.Add(DbConnectionStringSynonyms.MULTIPLEACTIVERESULTSETS, Keywords.MultipleActiveResultSets);
hash.Add(DbConnectionStringSynonyms.MULTISUBNETFAILOVER, Keywords.MultiSubnetFailover);
hash.Add(DbConnectionStringSynonyms.NETWORKADDRESS, Keywords.DataSource);
-#if NETCOREAPP
hash.Add(DbConnectionStringSynonyms.POOLBLOCKINGPERIOD, Keywords.PoolBlockingPeriod);
-#endif
hash.Add(DbConnectionStringSynonyms.SERVER, Keywords.DataSource);
hash.Add(DbConnectionStringSynonyms.DATABASE, Keywords.InitialCatalog);
hash.Add(DbConnectionStringSynonyms.TRUSTEDCONNECTION, Keywords.IntegratedSecurity);
@@ -334,9 +327,9 @@ public override object this[string keyword]
case Keywords.IPAddressPreference:
IPAddressPreference = ConvertToIPAddressPreference(keyword, value);
break;
-#if NETCOREAPP
- case Keywords.PoolBlockingPeriod: PoolBlockingPeriod = ConvertToPoolBlockingPeriod(keyword, value); break;
-#endif
+ case Keywords.PoolBlockingPeriod:
+ PoolBlockingPeriod = ConvertToPoolBlockingPeriod(keyword, value);
+ break;
case Keywords.Encrypt:
Encrypt = ConvertToBoolean(value);
break;
@@ -764,6 +757,22 @@ public bool PersistSecurityInfo
}
}
+ ///
+ public PoolBlockingPeriod PoolBlockingPeriod
+ {
+ get { return _poolBlockingPeriod; }
+ set
+ {
+ if (!DbConnectionStringBuilderUtil.IsValidPoolBlockingPeriodValue(value))
+ {
+ throw ADP.InvalidEnumerationValue(typeof(PoolBlockingPeriod), (int)value);
+ }
+
+ SetPoolBlockingPeriodValue(value);
+ _poolBlockingPeriod = value;
+ }
+ }
+
///
public bool Pooling
{
@@ -936,6 +945,9 @@ private static SqlConnectionAttestationProtocol ConvertToAttestationProtocol(str
private static SqlConnectionIPAddressPreference ConvertToIPAddressPreference(string keyword, object value)
=> DbConnectionStringBuilderUtil.ConvertToIPAddressPreference(keyword, value);
+ private static PoolBlockingPeriod ConvertToPoolBlockingPeriod(string keyword, object value)
+ => DbConnectionStringBuilderUtil.ConvertToPoolBlockingPeriod(keyword, value);
+
private object GetAt(Keywords index)
{
switch (index)
@@ -946,9 +958,8 @@ private object GetAt(Keywords index)
return ApplicationName;
case Keywords.AttachDBFilename:
return AttachDBFilename;
-#if NETCOREAPP
- case Keywords.PoolBlockingPeriod: return PoolBlockingPeriod;
-#endif
+ case Keywords.PoolBlockingPeriod:
+ return PoolBlockingPeriod;
case Keywords.CommandTimeout:
return CommandTimeout;
case Keywords.ConnectTimeout:
@@ -1063,11 +1074,9 @@ private void Reset(Keywords index)
case Keywords.Authentication:
_authentication = DbConnectionStringDefaults.Authentication;
break;
-#if NETCOREAPP
case Keywords.PoolBlockingPeriod:
_poolBlockingPeriod = DbConnectionStringDefaults.PoolBlockingPeriod;
break;
-#endif
case Keywords.CommandTimeout:
_commandTimeout = DbConnectionStringDefaults.CommandTimeout;
break;
@@ -1212,6 +1221,12 @@ private void SetAuthenticationValue(SqlAuthenticationMethod value)
base[DbConnectionStringKeywords.Authentication] = DbConnectionStringBuilderUtil.AuthenticationTypeToString(value);
}
+ private void SetPoolBlockingPeriodValue(PoolBlockingPeriod value)
+ {
+ Debug.Assert(DbConnectionStringBuilderUtil.IsValidPoolBlockingPeriodValue(value), "Invalid value for PoolBlockingPeriod");
+ base[DbConnectionStringKeywords.PoolBlockingPeriod] = DbConnectionStringBuilderUtil.PoolBlockingPeriodToString(value);
+ }
+
///
public override bool ShouldSerialize(string keyword)
{
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj
index aa1ae4ac4d..aa53998e99 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj
@@ -11,9 +11,6 @@
$(ObjFolder)$(Configuration).$(Platform).$(AssemblyName)
$(BinFolder)$(Configuration).$(Platform).$(AssemblyName)
-
-
-
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderPoolBlockingTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderPoolBlockingTest.cs
deleted file mode 100644
index d2922ba23d..0000000000
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderPoolBlockingTest.cs
+++ /dev/null
@@ -1,21 +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 Xunit;
-
-namespace Microsoft.Data.SqlClient.Tests
-{
- public partial class SqlConnectionStringBuilderTest
- {
-
- [Theory]
- // PoolBlockingPeriod is not supported in .NET Standard
- [InlineData("PoolBlockingPeriod = Auto")]
- [InlineData("PoolBlockingperiod = NeverBlock")]
- public void ConnectionStringTestsNetStandard(string connectionString)
- {
- ExecuteConnectionStringTests(connectionString);
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs
index c9a2bfe658..5ad2d85615 100644
--- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs
@@ -70,6 +70,8 @@ public partial class SqlConnectionStringBuilderTest
[InlineData("Password = some@pass#!@123")]
[InlineData("Persist Security Info = false")]
[InlineData("PersistSecurityInfo = true")]
+ [InlineData("PoolBlockingPeriod = Auto")]
+ [InlineData("PoolBlockingperiod = NeverBlock")]
[InlineData("Pooling = no")]
[InlineData("Pooling = false")]
[InlineData("Replication = true")]
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj
index a8e23c7e75..ec16e4f34b 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj
@@ -126,6 +126,7 @@
+
@@ -260,7 +261,6 @@
-
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/PoolBlockPeriodTest.netcoreapp.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/PoolBlockPeriodTest.cs
similarity index 100%
rename from src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/PoolBlockPeriodTest.netcoreapp.cs
rename to src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/PoolBlockPeriodTest.cs