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 a6be328a3a..313351fd26 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -457,8 +457,8 @@
Microsoft\Data\SqlClient\SqlUdtInfo.cs
-
- Microsoft\Data\SqlClient\SqlUtil.cs
+
+ Microsoft\Data\SqlClient\SqlReliabilityUtil.cs
Microsoft\Data\SqlClient\TdsEnums.cs
@@ -515,7 +515,7 @@
-
+
@@ -562,18 +562,16 @@
Microsoft\Data\SqlClient\SqlDependencyUtils.AssemblyLoadContext.cs
-
+
-
+
-
- Resources\StringsHelper.NetCore.cs
-
+
True
True
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIStreams.Task.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIStreams.Task.NetStandard.cs
similarity index 100%
rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIStreams.Task.cs
rename to src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIStreams.Task.NetStandard.cs
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIStreams.ValueTask.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIStreams.ValueTask.NetCoreApp.cs
similarity index 100%
rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIStreams.ValueTask.cs
rename to src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIStreams.ValueTask.NetCoreApp.cs
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.AssemblyLoadContext.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.AssemblyLoadContext.NetCoreApp.cs
similarity index 100%
rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.AssemblyLoadContext.cs
rename to src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionFactory.AssemblyLoadContext.NetCoreApp.cs
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Resources/StringsHelper.cs b/src/Microsoft.Data.SqlClient/netcore/src/Resources/StringsHelper.NetCore.cs
similarity index 100%
rename from src/Microsoft.Data.SqlClient/netcore/src/Resources/StringsHelper.cs
rename to src/Microsoft.Data.SqlClient/netcore/src/Resources/StringsHelper.NetCore.cs
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Common/src/Microsoft/Data/Common/DBDataPermissionAttribute.cs b/src/Microsoft.Data.SqlClient/netfx/src/Common/src/Microsoft/Data/Common/DBDataPermissionAttribute.cs
deleted file mode 100644
index 73ac712ddf..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Common/src/Microsoft/Data/Common/DBDataPermissionAttribute.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;
-
-namespace Microsoft.Data.Common {
-
- using System.ComponentModel;
- using System.Security.Permissions;
-
- /* derived class pattern
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = true, Inherited = false )]
- [Serializable] sealed public class XPermissionAttribute : DBDataPermissionAttribute {
- public XPermissionAttribute(SecurityAction action) : base(action) {
- }
- override public IPermission CreatePermission() {
- return new XPermission(this);
- }
- }
- */
-
- [Serializable(), AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = true, Inherited = false )]
- public abstract class DBDataPermissionAttribute : CodeAccessSecurityAttribute { // V1.0.3300
- private bool _allowBlankPassword;// = false;
- private string _connectionString;// = ADP.StrEmpty;
- private string _restrictions;// = ADP.StrEmpty;
- private KeyRestrictionBehavior _behavior;// = KeyRestrictionBehavior.AllowOnly;
-
- protected DBDataPermissionAttribute(SecurityAction action) : base(action) {
- }
-
- public bool AllowBlankPassword { // V1.0.3300
- get {
- return _allowBlankPassword;
- }
- set {
- _allowBlankPassword = value;
- }
- }
-
- public string ConnectionString { // V1.0.5000
- get {
- string value = _connectionString;
- return ((null != value) ? value : String.Empty);
- }
- set {
- _connectionString = value;
- }
- }
-
- public KeyRestrictionBehavior KeyRestrictionBehavior { // V1.0.5000, default AllowOnly
- get {
- return _behavior;
- }
- set {
- switch(value) {
- case KeyRestrictionBehavior.PreventUsage:
- case KeyRestrictionBehavior.AllowOnly:
- _behavior = value;
- break;
- default:
- throw ADP.InvalidKeyRestrictionBehavior(value);
- }
- }
- }
-
- public string KeyRestrictions { // V1.0.5000
- get {
- string value = _restrictions;
- return (null != value) ? value : ADP.StrEmpty;
- }
- set {
- _restrictions = value;
- }
- }
-
- [ EditorBrowsableAttribute(EditorBrowsableState.Never) ]
- public bool ShouldSerializeConnectionString() { // V1.2.3300
- return (null != _connectionString);
- }
-
- [ EditorBrowsableAttribute(EditorBrowsableState.Never) ]
- public bool ShouldSerializeKeyRestrictions() { // V1.2.3300
- return (null != _restrictions);
- }
- }
-}
-
-namespace Microsoft.Data { // MDAC 83087
-
-[Serializable]
-
- public enum KeyRestrictionBehavior { // V1.0.5000
- AllowOnly = 0,
- PreventUsage = 1,
- }
-}
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 ef7d6892ed..64f33e1070 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -1,10 +1,8 @@
-
-
-
+
{407890AC-9876-4FEF-A6F1-F36A876BAADE}
SqlClient
- v4.6.2
+ net462
true
Strings
SqlClient.Resources.$(ResxFileName)
@@ -16,6 +14,8 @@
$(BinPath)$(AssemblyName)\netfx\
$(OutputPath)\Microsoft.Data.SqlClient.xml
$(ObjPath)$(AssemblyName)\netfx\
+ false
+ false
Framework $(BaseProduct)
@@ -61,8 +61,6 @@
-
-
$(DefineConstants);DEBUG;DBG;_DEBUG;_LOGGING;RESOURCE_ANNOTATION_WORK;
Full
@@ -89,598 +87,24 @@
-
- Microsoft\Data\Common\ActivityCorrelator.cs
+
+ Microsoft\%(RecursiveDir)%(Filename).common%(Extension)
-
- Microsoft\Data\Common\AdapterUtil.cs
-
-
- Microsoft\Data\Common\AdapterUtil.Windows.cs
-
-
- Microsoft\Data\Common\DbConnectionStringCommon.cs
-
-
- Microsoft\Data\Common\DbConnectionOptions.Common.cs
-
-
- Microsoft\Data\Common\DbConnectionPoolKey.cs
-
-
- Microsoft\Data\Common\MultipartIdentifier.cs
-
-
- Microsoft\Data\Common\NameValuePair.cs
-
-
- Microsoft\Data\DataException.cs
-
-
- Microsoft\Data\OperationAbortedException.cs
-
-
- Microsoft\Data\ProviderBase\DbConnectionPoolAuthenticationContext.cs
-
-
- Microsoft\Data\ProviderBase\DbConnectionPoolAuthenticationContextKey.cs
-
-
- Microsoft\Data\ProviderBase\DbConnectionPoolGroup.cs
-
-
- Microsoft\Data\ProviderBase\DbConnectionPoolGroupProviderInfo.cs
-
-
- Microsoft\Data\ProviderBase\DbConnectionPoolOptions.cs
-
-
- Microsoft\Data\ProviderBase\DbConnectionPoolProviderInfo.cs
-
-
- Microsoft\Data\ProviderBase\DbMetaDataFactory.cs
-
-
- Microsoft\Data\ProviderBase\FieldNameLookup.cs
-
-
- Microsoft\Data\ProviderBase\TimeoutTimer.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumerator.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumerator.Windows.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumeratorNativeHelper.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumeratorUtil.cs
-
-
- Microsoft\Data\Sql\SqlNotificationRequest.cs
-
-
- Microsoft\Data\SqlClient\ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
-
-
- Microsoft\Data\SqlClient\ApplicationIntent.cs
-
-
- Microsoft\Data\SqlClient\AssemblyRef.cs
-
-
- Microsoft\Data\SqlClient\ActiveDirectoryAuthenticationProvider.cs
-
-
- Microsoft\Data\SqlClient\AlwaysEncryptedEnclaveProviderUtils.cs
-
-
- Microsoft\Data\SqlClient\AzureAttestationBasedEnclaveProvider.cs
-
-
- Microsoft\Data\SqlClient\ColumnEncryptionKeyInfo.cs
-
-
- Microsoft\Data\SqlClient\DataClassification\SensitivityClassification.cs
-
-
- Microsoft\Data\SqlClient\DisposableTemporaryOnStack.cs
-
-
- Microsoft\Data\SqlClient\EnclaveDelegate.cs
-
-
- Microsoft\Data\SqlClient\EnclaveDelegate.Crypto.cs
-
-
- Microsoft\Data\SqlClient\EnclavePackage.cs
-
-
- Microsoft\Data\SqlClient\EnclaveProviderBase.cs
-
-
- Microsoft\Data\SqlClient\EnclaveSessionCache.cs
-
-
- Microsoft\Data\SqlClient\LocalAppContextSwitches.cs
-
-
- Microsoft\Data\SqlClient\NoneAttestationEnclaveProvider.cs
-
-
- Microsoft\Data\SqlClient\OnChangedEventHandler.cs
-
-
- Microsoft\Data\SqlClient\ParameterPeekAheadValue.cs
-
-
- Microsoft\Data\SqlClient\PoolBlockingPeriod.cs
-
-
- Microsoft\Data\SqlClient\Reliability\AppConfigManager.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlRetryingEventArgs.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlRetryIntervalBaseEnumerator.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogic.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogicBase.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogicBaseProvider.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogicProvider.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryFactory.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryLogicLoader.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryLogicManager.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlRetryIntervalEnumerators.cs
-
-
- Microsoft\Data\SqlClient\RowsCopiedEventArgs.cs
-
-
- Microsoft\Data\SqlClient\RowsCopiedEventHandler.cs
-
-
- Microsoft\Data\SqlClient\Server\ExtendedClrTypeCode.cs
-
-
- Microsoft\Data\SqlClient\Server\ITypedGetters.cs
-
-
- Microsoft\Data\SqlClient\Server\ITypedGettersV3.cs
-
-
- Microsoft\Data\SqlClient\Server\ITypedSetters.cs
-
-
- Microsoft\Data\SqlClient\Server\ITypedSettersV3.cs
-
-
- Microsoft\Data\SqlClient\Server\MemoryRecordBuffer.cs
-
-
- Microsoft\Data\SqlClient\Server\MetadataUtilsSmi.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiEventSink.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiEventSink_Default.Common.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiEventSink_Default.netfx.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiGettersStream.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiMetaData.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiMetaDataProperty.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiRecordBuffer.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiSettersStream.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiTypedGetterSetter.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiXetterAccess.Common.cs
-
-
- Microsoft\Data\SqlClient\Server\SmiXetterTypeCode.cs
-
-
- Microsoft\Data\SqlClient\Server\SqlDataRecord.cs
-
-
- Microsoft\Data\SqlClient\Server\SqlDataRecord.netfx.cs
-
-
- Microsoft\Data\SqlClient\Server\SqlMetaData.cs
-
-
- Microsoft\Data\SqlClient\Server\SqlNormalizer.cs
-
-
- Microsoft\Data\SqlClient\Server\SqlRecordBuffer.cs
-
-
- Microsoft\Data\SqlClient\SqlTransaction.Common.cs
-
-
- Microsoft\Data\SqlClient\Server\ValueUtilsSmi.cs
-
-
- Microsoft\Data\SqlClient\Server\ValueUtilsSmi.netfx.cs
-
-
- Microsoft\Data\SqlClient\Server\SqlSer.cs
-
-
- Microsoft\Data\SqlClient\SignatureVerificationCache.cs
-
-
- Microsoft\Data\SqlClient\SortOrder.cs
-
-
- Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Algorithm.cs
-
-
- Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256EncryptionKey.cs
-
-
- Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Factory.cs
-
-
- Microsoft\Data\SqlClient\SqlAuthenticationParameters.cs
-
-
- Microsoft\Data\SqlClient\SqlAuthenticationProvider.cs
-
-
- Microsoft\Data\SqlClient\SqlBuffer.cs
-
-
- Microsoft\Data\SqlClient\SqlAuthenticationToken.cs
-
-
- Microsoft\Data\SqlClient\SqlBulkCopyColumnMapping.cs
-
-
- Microsoft\Data\SqlClient\SqlBulkCopyColumnMappingCollection.cs
-
-
- Microsoft\Data\SqlClient\SqlBulkCopyColumnOrderHint.cs
-
-
- Microsoft\Data\SqlClient\SqlBulkCopyColumnOrderHintCollection.cs
-
-
- Microsoft\Data\SqlClient\SqlBulkCopyOptions.cs
-
-
- Microsoft\Data\SqlClient\SqlCachedBuffer.cs
-
-
- Microsoft\Data\SqlClient\SqlClientEncryptionAlgorithm.cs
-
-
- Microsoft\Data\SqlClient\SqlClientEncryptionAlgorithmFactory.cs
-
-
- Microsoft\Data\SqlClient\SqlClientEncryptionAlgorithmFactoryList.cs
-
-
- Microsoft\Data\SqlClient\SqlClientEncryptionType.cs
-
-
- Microsoft\Data\SqlClient\SqlClientEventSource.cs
-
-
- Microsoft\Data\SqlClient\SqlClientLogger.cs
-
-
- Microsoft\Data\SqlClient\SqlClientMetaDataCollectionNames.cs
-
-
- Microsoft\Data\SqlClient\SqlClientSymmetricKey.cs
-
-
- Microsoft\Data\SqlClient\SqlCollation.cs
-
-
- Microsoft\Data\SqlClient\SqlColumnEncryptionKeyStoreProvider.cs
-
-
- Microsoft\Data\SqlClient\SqlCommandBuilder.cs
-
-
- Microsoft\Data\SqlClient\SqlCommandSet.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionEncryptOption.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionPoolGroupProviderInfo.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionPoolKey.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionPoolProviderInfo.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionString.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionStringBuilder.cs
-
-
- Microsoft\Data\SqlClient\SqlConnectionTimeoutErrorInternal.cs
-
-
- Microsoft\Data\SqlClient\SqlCredential.cs
-
-
- Microsoft\Data\SqlClient\SqlDataAdapter.cs
-
-
- Microsoft\Data\SqlClient\SqlDependency.cs
-
-
- Microsoft\Data\SqlClient\SqlDependencyListener.cs
-
-
- Microsoft\Data\SqlClient\SqlDependencyUtils.cs
-
-
- Microsoft\Data\SqlClient\SqlEnclaveAttestationParameters.Crypto.cs
-
-
- Microsoft\Data\SqlClient\SqlEnclaveSession.cs
-
-
- Microsoft\Data\SqlClient\SqlEnums.cs
-
-
- Microsoft\Data\SqlClient\SqlEnvChange.cs
-
-
- Microsoft\Data\SqlClient\SqlError.cs
-
-
- Microsoft\Data\SqlClient\SqlErrorCollection.cs
-
-
- Microsoft\Data\SqlClient\SqlException.cs
-
-
- Microsoft\Data\SqlClient\SQLFallbackDNSCache.cs
-
-
- Microsoft\Data\SqlClient\SqlInfoMessageEvent.cs
-
-
- Microsoft\Data\SqlClient\SqlInfoMessageEventHandler.cs
-
-
- Microsoft\Data\SqlClient\SqlInternalConnection.cs
-
-
- Microsoft\Data\SqlClient\SqlInternalTransaction.cs
-
-
- Microsoft\Data\SqlClient\SqlMetaDataFactory.cs
-
-
- Microsoft\Data\SqlClient\SqlNotificationEventArgs.cs
-
-
- Microsoft\Data\SqlClient\SqlNotificationInfo.cs
-
-
- Microsoft\Data\SqlClient\SqlNotificationSource.cs
-
-
- Microsoft\Data\SqlClient\SqlNotificationType.cs
-
-
- Microsoft\Data\SqlClient\SqlParameterCollection.cs
-
-
- Microsoft\Data\SqlClient\SqlParameter.cs
-
-
- Microsoft\Data\SqlClient\SqlQueryMetadataCache.cs
-
-
- Microsoft\Data\SqlClient\SqlReferenceCollection.cs
-
-
- Microsoft\Data\SqlClient\SqlRowUpdatedEvent.cs
-
-
- Microsoft\Data\SqlClient\SqlRowUpdatedEventHandler.cs
-
-
- Microsoft\Data\SqlClient\SqlRowUpdatingEvent.cs
-
-
- Microsoft\Data\SqlClient\SqlRowUpdatingEventHandler.cs
-
-
- Microsoft\Data\SqlClient\SqlSecurityUtility.cs
-
-
- Microsoft\Data\SqlClient\SqlSequentialStream.cs
-
-
- Microsoft\Data\SqlClient\SqlStream.cs
-
-
- Microsoft\Data\SqlClient\SqlStatistics.cs
-
-
- Microsoft\Data\SqlClient\SqlSequentialTextReader.cs
-
-
- Microsoft\Data\SqlClient\SqlSymmetricKeyCache.cs
-
-
- Microsoft\Data\SqlClient\SqlUdtInfo.cs
-
-
- Microsoft\Data\SqlClient\SqlUtil.cs
-
-
- Microsoft\Data\SqlClient\TdsEnums.cs
-
-
- Microsoft\Data\SqlClient\TdsParameterSetter.cs
-
-
- Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs
-
-
- Microsoft\Data\SqlClient\TdsParserStateObject.cs
-
-
- Microsoft\Data\SqlClient\TdsParserStaticMethods.cs
-
-
- Microsoft\Data\SqlClient\TdsRecordBufferSetter.cs
-
-
- Microsoft\Data\SqlClient\TdsParserSessionPool.cs
-
-
- Microsoft\Data\SqlClient\TdsValueSetter.cs
-
-
- Microsoft\Data\SqlClient\VirtualSecureModeEnclaveProvider.cs
-
-
- Microsoft\Data\SqlClient\VirtualSecureModeEnclaveProviderBase.cs
-
-
- Microsoft\Data\SqlTypes\SQLResource.cs
-
-
- Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs
-
-
- Resources\ResCategoryAttribute.cs
-
-
- Resources\ResDescriptionAttribute.cs
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
- True
- True
- Strings.resx
-
-
- Resources\StringsHelper.cs
-
Microsoft.Data.SqlClient.Resources.Strings.resources
System
@@ -739,7 +163,6 @@
$(SystemIOVersion)
-
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiXetterAccessMap.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiXetterAccessMap.cs
deleted file mode 100644
index a5b9f2004d..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiXetterAccessMap.cs
+++ /dev/null
@@ -1,63 +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.Diagnostics;
-
-namespace Microsoft.Data.SqlClient.Server
-{
-
- // Formal encoding of SMI's metadata-to-ITypedSetter/-from-ITypedGetter validity rules
- internal partial class SmiXetterAccessMap
- {
-
- private static bool[,] __isGetterAccessValid = {
- // Getters as columns (abbreviated from XetterTypeCode names)
- // SqlDbTypes as rows
- // bool, byte, bytes, chars, strng, int16, int32, int64, singl, doubl, sqldec, date, guid, varmd, Xetr, time, dtost
-/*BigInt*/ { _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Binary*/ { _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Bit*/ { X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Char*/ { _ , _ , X , X , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*DTime*/ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , },
-/*Decimal*/ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , _ , },
-/*Float*/ { _ , _ , _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , _ , _ , },
-/*Image*/ { _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Int*/ { _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Money*/ { _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*NChar*/ { _ , _ , X , X , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*NText*/ { _ , _ , X , X , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*NVarChar*/{ _ , _ , X , X , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Real*/ { _ , _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*UniqueId*/{ _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , },
-/*SmDTime*/ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , },
-/*SmInt*/ { _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*SmMoney*/ { _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Text*/ { _ , _ , X , X , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Tstamp*/ { _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*TinyInt*/ { _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*VarBin*/ { _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*VarChar*/ { _ , _ , X , X , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Variant*/ { X , X , X , X , X , X , X , X , X , X , X , X , X , X , _ , X , X , },
-/* 24 */ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Xml*/ { _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/* 26 */ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/* 27 */ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/* 28 */ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Udt*/ { _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , },
-/*Struct*/ { _ , _ , X , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , X , _ , _ , },
-/*Date*/ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , },
-/*Time*/ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , X , _ , },
-/*DTime2*/ { _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , X , _ , _ , _ , _ , _ , },
-/*DTOffset*/{ _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , _ , X , },
- };
-
- internal static bool IsGetterAccessValid(SmiMetaData metaData, SmiXetterTypeCode xetterType)
- {
- // Make sure no-one adds a new xetter type without updating this file!
- Debug.Assert(SmiXetterTypeCode.XetBoolean <= xetterType && SmiXetterTypeCode.XetDateTimeOffset >= xetterType);
-
- return __isGetterAccessValid[(int)metaData.SqlDbType, (int)xetterType];
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopyColumnMapping.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopyColumnMapping.cs
deleted file mode 100644
index 601fd144ba..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopyColumnMapping.cs
+++ /dev/null
@@ -1,138 +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 Microsoft.Data.Common;
-
-namespace Microsoft.Data.SqlClient
-{
- // -------------------------------------------------------------------------------------------------
- // this class helps allows the user to create association between source- and targetcolumns
- //
- //
- ///
- public sealed class SqlBulkCopyColumnMapping
- {
- internal string _destinationColumnName;
- internal int _destinationColumnOrdinal;
- internal string _sourceColumnName;
- internal int _sourceColumnOrdinal;
-
- // devnote: we don't want the user to detect the columnordinal after WriteToServer call.
- // _sourceColumnOrdinal(s) will be copied to _internalSourceColumnOrdinal when WriteToServer executes.
- internal int _internalDestinationColumnOrdinal;
- internal int _internalSourceColumnOrdinal; // -1 indicates an undetermined value
-
- ///
- public string DestinationColumn
- {
- get
- {
- if (_destinationColumnName != null)
- {
- return _destinationColumnName;
- }
- return string.Empty;
- }
- set
- {
- _destinationColumnOrdinal = _internalDestinationColumnOrdinal = -1;
- _destinationColumnName = value;
- }
- }
-
- ///
- public int DestinationOrdinal
- {
- get
- {
- return _destinationColumnOrdinal;
- }
- set
- {
- if (value >= 0)
- {
- _destinationColumnName = null;
- _destinationColumnOrdinal = _internalDestinationColumnOrdinal = value;
- }
- else
- {
- throw ADP.IndexOutOfRange(value);
- }
- }
- }
-
- ///
- public string SourceColumn
- {
- get
- {
- if (_sourceColumnName != null)
- {
- return _sourceColumnName;
- }
- return string.Empty;
- }
- set
- {
- _sourceColumnOrdinal = _internalSourceColumnOrdinal = -1;
- _sourceColumnName = value;
- }
- }
-
- ///
- public int SourceOrdinal
- {
- get
- {
- return _sourceColumnOrdinal;
- }
- set
- {
- if (value >= 0)
- {
- _sourceColumnName = null;
- _sourceColumnOrdinal = _internalSourceColumnOrdinal = value;
- }
- else
- {
- throw ADP.IndexOutOfRange(value);
- }
- }
- }
-
- ///
- public SqlBulkCopyColumnMapping()
- {
- _internalSourceColumnOrdinal = -1;
- }
-
- ///
- public SqlBulkCopyColumnMapping(string sourceColumn, string destinationColumn)
- {
- SourceColumn = sourceColumn;
- DestinationColumn = destinationColumn;
- }
-
- ///
- public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, string destinationColumn)
- {
- SourceOrdinal = sourceColumnOrdinal;
- DestinationColumn = destinationColumn;
- }
-
- ///
- public SqlBulkCopyColumnMapping(string sourceColumn, int destinationOrdinal)
- {
- SourceColumn = sourceColumn;
- DestinationOrdinal = destinationOrdinal;
- }
-
- ///
- public SqlBulkCopyColumnMapping(int sourceColumnOrdinal, int destinationOrdinal)
- {
- SourceOrdinal = sourceColumnOrdinal;
- DestinationOrdinal = destinationOrdinal;
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs
deleted file mode 100644
index 6f91683a4d..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs
+++ /dev/null
@@ -1,709 +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.Collections.Generic;
-using System.Diagnostics;
-using System.Threading;
-using Microsoft.Data.Common;
-
-namespace Microsoft.Data.SqlClient
-{
- // This is a singleton instance per AppDomain that acts as the notification dispatcher for
- // that AppDomain. It receives calls from the SqlDependencyProcessDispatcher with an ID or a server name
- // to invalidate matching dependencies in the given AppDomain.
-
- internal class SqlDependencyPerAppDomainDispatcher : MarshalByRefObject
- { // MBR, since ref'ed by ProcessDispatcher.
-
- // ----------------
- // Instance members
- // ----------------
-
- internal static readonly SqlDependencyPerAppDomainDispatcher
- SingletonInstance = new SqlDependencyPerAppDomainDispatcher(); // singleton object
-
- // Dependency ID -> Dependency hashtable. 1 -> 1 mapping.
- // 1) Used for ASP.NET to map from ID to dependency.
- // 2) Used to enumerate dependencies to invalidate based on server.
- private Dictionary _dependencyIdToDependencyHash;
-
- // holds dependencies list per notification and the command hash from which this notification was generated
- // command hash is needed to remove its entry from _commandHashToNotificationId when the notification is removed
- sealed class DependencyList : List
- {
- public readonly string CommandHash;
-
- internal DependencyList(string commandHash)
- {
- this.CommandHash = commandHash;
- }
- }
-
- // notificationId -> Dependencies hashtable: 1 -> N mapping. notificationId == appDomainKey + commandHash.
- // More than one dependency can be using the same command hash values resulting in a hash to the same value.
- // We use this to cache mapping between command to dependencies such that we may reduce the notification
- // resource effect on SQL Server. The Guid identifier is sent to the server during notification enlistment,
- // and returned during the notification event. Dependencies look up existing Guids, if one exists, to ensure
- // they are re-using notification ids.
- private Dictionary _notificationIdToDependenciesHash;
-
- // CommandHash value -> notificationId associated with it: 1->1 mapping. This map is used to quickly find if we need to create
- // new notification or hookup into existing one.
- // CommandHash is built from connection string, command text and parameters
- private Dictionary _commandHashToNotificationId;
-
- // TIMEOUT LOGIC DESCRIPTION
- //
- // Every time we add a dependency we compute the next, earlier timeout.
- //
- // We setup a timer to get a callback every 15 seconds. In the call back:
- // - If there are no active dependencies, we just return.
- // - If there are dependencies but none of them timed-out (compared to the "next timeout"),
- // we just return.
- // - Otherwise we Invalidate() those that timed-out.
- //
- // So the client-generated timeouts have a granularity of 15 seconds. This allows
- // for a simple and low-resource-consumption implementation.
- //
- // LOCKS: don't update _nextTimeout outside of the _dependencyHash.SyncRoot lock.
-
- private bool _SqlDependencyTimeOutTimerStarted = false;
- // Next timeout for any of the dependencies in the dependency table.
- private DateTime _nextTimeout;
- // Timer to periodically check the dependencies in the table and see if anyone needs
- // a timeout. We'll enable this only on demand.
- private Timer _timeoutTimer;
-
- // -----------
- // BID members
- // -----------
-
- private readonly int _objectID = System.Threading.Interlocked.Increment(ref _objectTypeCount);
- private static int _objectTypeCount; // EventSource Counter
- internal int ObjectID
- {
- get
- {
- return _objectID;
- }
- }
-
- private SqlDependencyPerAppDomainDispatcher()
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}", ObjectID);
- try
- {
- _dependencyIdToDependencyHash = new Dictionary();
- _notificationIdToDependenciesHash = new Dictionary();
- _commandHashToNotificationId = new Dictionary();
-
- _timeoutTimer = new Timer(new TimerCallback(TimeoutTimerCallback), null, Timeout.Infinite, Timeout.Infinite);
-
- // If rude abort - we'll leak. This is acceptable for now.
- AppDomain.CurrentDomain.DomainUnload += new EventHandler(this.UnloadEventHandler);
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- // SQL Hotfix 236
- // When remoted across appdomains, MarshalByRefObject links by default time out if there is no activity
- // within a few minutes. Add this override to prevent marshaled links from timing out.
- public override object InitializeLifetimeService()
- {
- return null;
- }
-
- // ------
- // Events
- // ------
-
- private void UnloadEventHandler(object sender, EventArgs e)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}", ObjectID);
- try
- {
- // Make non-blocking call to ProcessDispatcher to ThreadPool.QueueUserWorkItem to complete
- // stopping of all start calls in this AppDomain. For containers shared among various AppDomains,
- // this will just be a ref-count subtract. For non-shared containers, we will close the container
- // and clean-up.
- SqlDependencyProcessDispatcher dispatcher = SqlDependency.ProcessDispatcher;
- if (null != dispatcher)
- {
- dispatcher.QueueAppDomainUnloading(SqlDependency.AppDomainKey);
- }
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- // ----------------------------------------------------
- // Methods for dependency hash manipulation and firing.
- // ----------------------------------------------------
-
- // This method is called upon SqlDependency constructor.
- internal void AddDependencyEntry(SqlDependency dep)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, SqlDependency: {1}", ObjectID, dep.ObjectID);
- try
- {
- lock (this)
- {
- _dependencyIdToDependencyHash.Add(dep.Id, dep);
- }
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- // This method is called upon Execute of a command associated with a SqlDependency object.
- internal string AddCommandEntry(string commandHash, SqlDependency dep)
- {
- string notificationId = string.Empty;
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, commandHash: '{1}', SqlDependency: {2}", ObjectID, commandHash, dep.ObjectID);
- try
- {
- lock (this)
- {
- if (!_dependencyIdToDependencyHash.ContainsKey(dep.Id))
- {
- // Determine if depId->dep hashtable contains dependency. If not, it's been invalidated.
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Dependency not present in depId->dep hash, must have been invalidated.");
- }
- else
- {
- // check if we already have notification associated with given command hash
- if (_commandHashToNotificationId.TryGetValue(commandHash, out notificationId))
- {
- // we have one or more SqlDependency instances with same command hash
-
- DependencyList dependencyList = null;
- if (!_notificationIdToDependenciesHash.TryGetValue(notificationId, out dependencyList))
- {
- // this should not happen since _commandHashToNotificationId and _notificationIdToDependenciesHash are always
- // updated together
- Debug.Assert(false, "_commandHashToNotificationId has entries that were removed from _notificationIdToDependenciesHash. Remember to keep them in sync");
- throw ADP.InternalError(ADP.InternalErrorCode.SqlDependencyCommandHashIsNotAssociatedWithNotification);
- }
-
- // join the new dependency to the list
- if (!dependencyList.Contains(dep))
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Dependency not present for commandHash, adding.");
- dependencyList.Add(dep);
- }
- else
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Dependency already present for commandHash.");
- }
- }
- else
- {
- // we did not find notification ID with the same app domain and command hash, create a new one
- // use unique guid to avoid duplicate IDs
- // prepend app domain ID to the key - SqlConnectionContainer::ProcessNotificationResults (SqlDependencyListener.cs)
- // uses this app domain ID to route the message back to the app domain in which this SqlDependency was created
- notificationId = string.Format(System.Globalization.CultureInfo.InvariantCulture,
- "{0};{1}",
- SqlDependency.AppDomainKey, // must be first
- Guid.NewGuid().ToString("D", System.Globalization.CultureInfo.InvariantCulture)
- );
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Creating new Dependencies list for commandHash.");
- DependencyList dependencyList = new DependencyList(commandHash);
- dependencyList.Add(dep);
-
- // map command hash to notification we just created to reuse it for the next client
- // do it inside finally block to avoid ThreadAbort exception interrupt this operation
- try
- { }
- finally
- {
- _commandHashToNotificationId.Add(commandHash, notificationId);
- _notificationIdToDependenciesHash.Add(notificationId, dependencyList);
- }
- }
-
-
- Debug.Assert(_notificationIdToDependenciesHash.Count == _commandHashToNotificationId.Count, "always keep these maps in sync!");
- }
- }
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
-
- return notificationId;
- }
-
- // This method is called by the ProcessDispatcher upon a notification for this AppDomain.
- internal void InvalidateCommandID(SqlNotification sqlNotification)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, commandHash: '{1}'", ObjectID, sqlNotification.Key);
- try
- {
- List dependencyList = null;
-
- lock (this)
- {
- dependencyList = LookupCommandEntryWithRemove(sqlNotification.Key);
-
- if (null != dependencyList)
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" commandHash found in hashtable.");
- foreach (SqlDependency dependency in dependencyList)
- {
- // Ensure we remove from process static app domain hash for dependency initiated invalidates.
- LookupDependencyEntryWithRemove(dependency.Id);
-
- // Completely remove Dependency from commandToDependenciesHash.
- RemoveDependencyFromCommandToDependenciesHash(dependency);
- }
- }
- else
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" commandHash NOT found in hashtable.");
- }
- }
-
- if (null != dependencyList)
- {
- // After removal from hashtables, invalidate.
- foreach (SqlDependency dependency in dependencyList)
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Dependency found in commandHash dependency ArrayList - calling invalidate.");
- try
- {
- dependency.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source);
- }
- catch (Exception e)
- {
- // Since we are looping over dependencies, do not allow one Invalidate
- // that results in a throw prevent us from invalidating all dependencies
- // related to this server.
- if (!ADP.IsCatchableExceptionType(e))
- {
- throw;
- }
- ADP.TraceExceptionWithoutRethrow(e);
- }
- }
- }
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- // This method is called when a connection goes down or other unknown error occurs in the ProcessDispatcher.
- internal void InvalidateServer(string server, SqlNotification sqlNotification)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, server: '{1}'", ObjectID, server);
- try
- {
- List dependencies = new List();
-
- lock (this)
- { // Copy inside of lock, but invalidate outside of lock.
- foreach (KeyValuePair entry in _dependencyIdToDependencyHash)
- {
- SqlDependency dependency = entry.Value;
- if (dependency.ContainsServer(server))
- {
- dependencies.Add(dependency);
- }
- }
-
- foreach (SqlDependency dependency in dependencies)
- { // Iterate over resulting list removing from our hashes.
- // Ensure we remove from process static app domain hash for dependency initiated invalidates.
- LookupDependencyEntryWithRemove(dependency.Id);
-
- // Completely remove Dependency from commandToDependenciesHash.
- RemoveDependencyFromCommandToDependenciesHash(dependency);
- }
- }
-
- foreach (SqlDependency dependency in dependencies)
- { // Iterate and invalidate.
- try
- {
- dependency.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source);
- }
- catch (Exception e)
- {
- // Since we are looping over dependencies, do not allow one Invalidate
- // that results in a throw prevent us from invalidating all dependencies
- // related to this server.
- if (!ADP.IsCatchableExceptionType(e))
- {
- throw;
- }
- ADP.TraceExceptionWithoutRethrow(e);
- }
- }
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- // This method is called by SqlCommand to enable ASP.NET scenarios - map from ID to Dependency.
- internal SqlDependency LookupDependencyEntry(string id)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, Key: '{1}'", ObjectID, id);
- try
- {
- if (null == id)
- {
- throw ADP.ArgumentNull("id");
- }
- if (ADP.IsEmpty(id))
- {
- throw SQL.SqlDependencyIdMismatch();
- }
-
- SqlDependency entry = null;
-
- lock (this)
- {
- if (_dependencyIdToDependencyHash.ContainsKey(id))
- {
- entry = _dependencyIdToDependencyHash[id];
- }
- else
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" ERROR - dependency ID mismatch - not throwing.");
- }
- }
-
- return entry;
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- // Remove the dependency from the hashtable with the passed id.
- private void LookupDependencyEntryWithRemove(string id)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, id: '{1}'", ObjectID, id);
- try
- {
- lock (this)
- {
- if (_dependencyIdToDependencyHash.ContainsKey(id))
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Entry found in hashtable - removing.");
- _dependencyIdToDependencyHash.Remove(id);
-
- // if there are no more dependencies then we can dispose the timer.
- if (0 == _dependencyIdToDependencyHash.Count)
- {
- _timeoutTimer.Change(Timeout.Infinite, Timeout.Infinite);
- _SqlDependencyTimeOutTimerStarted = false;
- }
- }
- else
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Entry NOT found in hashtable.");
- }
- }
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- // Find and return arraylist, and remove passed hash value.
- private List LookupCommandEntryWithRemove(string notificationId)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, commandHash: '{1}'", ObjectID, notificationId);
- try
- {
- DependencyList entry = null;
-
- lock (this)
- {
- if (_notificationIdToDependenciesHash.TryGetValue(notificationId, out entry))
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Entries found in hashtable - removing.");
-
- // update the tables - do it inside finally block to avoid ThreadAbort exception interrupt this operation
- try
- { }
- finally
- {
- _notificationIdToDependenciesHash.Remove(notificationId);
- // VSTS 216991: cleanup the map between the command hash and associated notification ID
- _commandHashToNotificationId.Remove(entry.CommandHash);
- }
- }
- else
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Entries NOT found in hashtable.");
- }
-
- Debug.Assert(_notificationIdToDependenciesHash.Count == _commandHashToNotificationId.Count, "always keep these maps in sync!");
- }
-
- return entry; // DependencyList inherits from List
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- // Remove from commandToDependenciesHash all references to the passed dependency.
- private void RemoveDependencyFromCommandToDependenciesHash(SqlDependency dependency)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, SqlDependency: {1}", ObjectID, dependency.ObjectID);
- try
- {
- lock (this)
- {
- List notificationIdsToRemove = new List();
- List commandHashesToRemove = new List();
-
- foreach (KeyValuePair entry in _notificationIdToDependenciesHash)
- {
- DependencyList dependencies = entry.Value;
- if (dependencies.Remove(dependency))
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Removed SqlDependency: {0}, with ID: '{1}'.", dependency.ObjectID, dependency.Id);
- if (dependencies.Count == 0)
- {
- // this dependency was the last associated with this notification ID, remove the entry
- // note: cannot do it inside foreach over dictionary
- notificationIdsToRemove.Add(entry.Key);
- commandHashesToRemove.Add(entry.Value.CommandHash);
- }
- }
-
- // same SqlDependency can be associated with more than one command, so we have to continue till the end...
- }
-
- Debug.Assert(commandHashesToRemove.Count == notificationIdsToRemove.Count, "maps should be kept in sync");
- for (int i = 0; i < notificationIdsToRemove.Count; i++)
- {
- // cleanup the entry outside of foreach
- // do it inside finally block to avoid ThreadAbort exception interrupt this operation
- try
- { }
- finally
- {
- _notificationIdToDependenciesHash.Remove(notificationIdsToRemove[i]);
- // VSTS 216991: cleanup the map between the command hash and associated notification ID
- _commandHashToNotificationId.Remove(commandHashesToRemove[i]);
- }
- }
-
- Debug.Assert(_notificationIdToDependenciesHash.Count == _commandHashToNotificationId.Count, "always keep these maps in sync!");
- }
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- // -----------------------------------------
- // Methods for Timer maintenance and firing.
- // -----------------------------------------
-
- internal void StartTimer(SqlDependency dep)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" {0}, SqlDependency: {1}", ObjectID, dep.ObjectID);
- try
- {
- // If this dependency expires sooner than the current next timeout, change
- // the timeout and enable timer callback as needed. Note that we change _nextTimeout
- // only inside the hashtable syncroot.
- lock (this)
- {
- // Enable the timer if needed (disable when empty, enable on the first addition).
- if (!_SqlDependencyTimeOutTimerStarted)
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Timer not yet started, starting.");
- _timeoutTimer.Change(15000 /* 15 secs */, 15000 /* 15 secs */);
-
- // Save this as the earlier timeout to come.
- _nextTimeout = dep.ExpirationTime;
- _SqlDependencyTimeOutTimerStarted = true;
- }
- else if (_nextTimeout > dep.ExpirationTime)
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" Timer already started, resetting time.");
-
- // Save this as the earlier timeout to come.
- _nextTimeout = dep.ExpirationTime;
- }
- }
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
-
- private static void TimeoutTimerCallback(object state)
- {
- long scopeID = SqlClientEventSource.Log.TryNotificationScopeEnterEvent(" AppDomainKey: '{0}'", SqlDependency.AppDomainKey);
- try
- {
- SqlDependency[] dependencies;
-
- // Only take the lock for checking whether there is work to do
- // if we do have work, we'll copy the hashtable and scan it after releasing
- // the lock.
- lock (SingletonInstance)
- {
- if (0 == SingletonInstance._dependencyIdToDependencyHash.Count)
- {
- // Nothing to check.
- SqlClientEventSource.Log.TryNotificationTraceEvent(" No dependencies, exiting.");
- return;
- }
- if (SingletonInstance._nextTimeout > DateTime.UtcNow)
- {
- SqlClientEventSource.Log.TryNotificationTraceEvent(" No timeouts expired, exiting.");
-
- // No dependency timed-out yet.
- return;
- }
-
- // If at least one dependency timed-out do a scan of the table.
- // NOTE: we could keep a shadow table sorted by expiration time, but
- // given the number of typical simultaneously alive dependencies it's
- // probably not worth the optimization.
- dependencies = new SqlDependency[SingletonInstance._dependencyIdToDependencyHash.Count];
- SingletonInstance._dependencyIdToDependencyHash.Values.CopyTo(dependencies, 0);
- }
-
- // Scan the active dependencies if needed.
- DateTime now = DateTime.UtcNow;
- DateTime newNextTimeout = DateTime.MaxValue;
-
- for (int i = 0; i < dependencies.Length; i++)
- {
- // If expired fire the change notification.
- if (dependencies[i].ExpirationTime <= now)
- {
- try
- {
- // This invokes user-code which may throw exceptions.
- // NOTE: this is intentionally outside of the lock, we don't want
- // to invoke user-code while holding an internal lock.
- dependencies[i].Invalidate(SqlNotificationType.Change, SqlNotificationInfo.Error, SqlNotificationSource.Timeout);
- }
- catch (Exception e)
- {
- if (!ADP.IsCatchableExceptionType(e))
- {
- throw;
- }
-
- // This is an exception in user code, and we're in a thread-pool thread
- // without user's code up in the stack, no much we can do other than
- // eating the exception.
- ADP.TraceExceptionWithoutRethrow(e);
- }
- }
- else
- {
- if (dependencies[i].ExpirationTime < newNextTimeout)
- {
- newNextTimeout = dependencies[i].ExpirationTime; // Track the next earlier timeout.
- }
- dependencies[i] = null; // Null means "don't remove it from the hashtable" in the loop below.
- }
- }
-
- // Remove timed-out dependencies from the hashtable.
- lock (SingletonInstance)
- {
- for (int i = 0; i < dependencies.Length; i++)
- {
- if (null != dependencies[i])
- {
- SingletonInstance._dependencyIdToDependencyHash.Remove(dependencies[i].Id);
- }
- }
- if (newNextTimeout < SingletonInstance._nextTimeout)
- {
- SingletonInstance._nextTimeout = newNextTimeout; // We're inside the lock so ok to update.
- }
- }
- }
- finally
- {
- SqlClientEventSource.Log.TryNotificationScopeLeaveEvent(scopeID);
- }
- }
- }
-
- // Simple class used to encapsulate all data in a notification.
- internal class SqlNotification : MarshalByRefObject
- {
- // This class could be Serializable rather than MBR...
-
- private readonly SqlNotificationInfo _info;
- private readonly SqlNotificationSource _source;
- private readonly SqlNotificationType _type;
- private readonly string _key;
-
- internal SqlNotification(SqlNotificationInfo info, SqlNotificationSource source, SqlNotificationType type, string key)
- {
- _info = info;
- _source = source;
- _type = type;
- _key = key;
- }
-
- internal SqlNotificationInfo Info
- {
- get
- {
- return _info;
- }
- }
-
- internal string Key
- {
- get
- {
- return _key;
- }
- }
-
- internal SqlNotificationSource Source
- {
- get
- {
- return _source;
- }
- }
-
- internal SqlNotificationType Type
- {
- get
- {
- return _type;
- }
- }
- }
-}
-
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserSafeHandles.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserSafeHandles.cs
deleted file mode 100644
index 276a353141..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserSafeHandles.cs
+++ /dev/null
@@ -1,315 +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.Collections.Generic;
-using System.Diagnostics;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Threading;
-using Microsoft.Data.Common;
-
-namespace Microsoft.Data.SqlClient
-{
- internal sealed class SNILoadHandle : SafeHandle
- {
- internal static readonly SNILoadHandle SingletonInstance = new SNILoadHandle();
-
- internal readonly SNINativeMethodWrapper.SqlAsyncCallbackDelegate ReadAsyncCallbackDispatcher = new SNINativeMethodWrapper.SqlAsyncCallbackDelegate(ReadDispatcher);
- internal readonly SNINativeMethodWrapper.SqlAsyncCallbackDelegate WriteAsyncCallbackDispatcher = new SNINativeMethodWrapper.SqlAsyncCallbackDelegate(WriteDispatcher);
-
- private readonly UInt32 _sniStatus = TdsEnums.SNI_UNINITIALIZED;
- private readonly EncryptionOptions _encryptionOption = EncryptionOptions.OFF;
- private bool? _clientOSEncryptionSupport = null;
-
- private SNILoadHandle() : base(IntPtr.Zero, true)
- {
- // SQL BU DT 346588 - from security review - SafeHandle guarantees this is only called once.
- // The reason for the safehandle is guaranteed initialization and termination of SNI to
- // ensure SNI terminates and cleans up properly.
- RuntimeHelpers.PrepareConstrainedRegions();
- try
- { }
- finally
- {
- _sniStatus = SNINativeMethodWrapper.SNIInitialize();
- base.handle = (IntPtr)1; // Initialize to non-zero dummy variable.
- }
- }
-
- ///
- /// Verify client encryption possibility.
- ///
- public bool ClientOSEncryptionSupport
- {
- get
- {
- if (_clientOSEncryptionSupport is null)
- {
- // VSDevDiv 479597: If initialize fails, don't call QueryInfo.
- if (TdsEnums.SNI_SUCCESS == _sniStatus)
- {
- try
- {
- UInt32 value = 0;
- // Query OS to find out whether encryption is supported.
- SNINativeMethodWrapper.SNIQueryInfo(SNINativeMethodWrapper.QTypes.SNI_QUERY_CLIENT_ENCRYPT_POSSIBLE, ref value);
- _clientOSEncryptionSupport = value != 0;
- }
- catch (Exception e)
- {
- SqlClientEventSource.Log.TryTraceEvent(" Exception occurs during resolving encryption possibility: {0}", e.Message);
- }
- }
- }
- return _clientOSEncryptionSupport.Value;
- }
- }
-
- public override bool IsInvalid => (IntPtr.Zero == base.handle);
-
- override protected bool ReleaseHandle()
- {
- if (base.handle != IntPtr.Zero)
- {
- if (TdsEnums.SNI_SUCCESS == _sniStatus)
- {
- LocalDBAPI.ReleaseDLLHandles();
- SNINativeMethodWrapper.SNITerminate();
- }
- base.handle = IntPtr.Zero;
- }
-
- return true;
- }
-
- public UInt32 SNIStatus => _sniStatus;
-
- public EncryptionOptions Options => _encryptionOption;
-
- static private void ReadDispatcher(IntPtr key, IntPtr packet, UInt32 error)
- {
- // This is the app-domain dispatcher for all async read callbacks, It
- // simply gets the state object from the key that it is passed, and
- // calls the state object's read callback.
- Debug.Assert(IntPtr.Zero != key, "no key passed to read callback dispatcher?");
- if (IntPtr.Zero != key)
- {
- // NOTE: we will get a null ref here if we don't get a key that
- // contains a GCHandle to TDSParserStateObject; that is
- // very bad, and we want that to occur so we can catch it.
- GCHandle gcHandle = (GCHandle)key;
- TdsParserStateObject stateObj = (TdsParserStateObject)gcHandle.Target;
-
- if (null != stateObj)
- {
- stateObj.ReadAsyncCallback(IntPtr.Zero, packet, error);
- }
- }
- }
-
- static private void WriteDispatcher(IntPtr key, IntPtr packet, UInt32 error)
- {
- // This is the app-domain dispatcher for all async write callbacks, It
- // simply gets the state object from the key that it is passed, and
- // calls the state object's write callback.
- Debug.Assert(IntPtr.Zero != key, "no key passed to write callback dispatcher?");
- if (IntPtr.Zero != key)
- {
- // NOTE: we will get a null ref here if we don't get a key that
- // contains a GCHandle to TDSParserStateObject; that is
- // very bad, and we want that to occur so we can catch it.
- GCHandle gcHandle = (GCHandle)key;
- TdsParserStateObject stateObj = (TdsParserStateObject)gcHandle.Target;
-
- if (null != stateObj)
- {
- stateObj.WriteAsyncCallback(IntPtr.Zero, packet, error);
- }
- }
- }
- }
-
- internal sealed class SNIHandle : SafeHandle
- {
- private readonly UInt32 _status = TdsEnums.SNI_UNINITIALIZED;
- private readonly bool _fSync = false;
-
- // creates a physical connection
- internal SNIHandle(
- SNINativeMethodWrapper.ConsumerInfo myInfo,
- string serverName,
- byte[] spnBuffer,
- bool ignoreSniOpenTimeout,
- int timeout,
- out byte[] instanceName,
- bool flushCache,
- bool fSync,
- bool fParallel,
- TransparentNetworkResolutionState transparentNetworkResolutionState,
- int totalTimeout,
- SqlConnectionIPAddressPreference ipPreference,
- SQLDNSInfo cachedDNSInfo,
- string hostNameInCertificate)
- : base(IntPtr.Zero, true)
- {
-
- RuntimeHelpers.PrepareConstrainedRegions();
- try
- { }
- finally
- {
- _fSync = fSync;
- instanceName = new byte[256]; // Size as specified by netlibs.
- if (ignoreSniOpenTimeout)
- {
- // UNDONE: ITEM12001110 (DB Mirroring Reconnect) Old behavior of not truly honoring timeout presevered
- // for non-failover scenarios to avoid breaking changes as part of a QFE. Consider fixing timeout
- // handling in next full release and removing ignoreSniOpenTimeout parameter.
- timeout = Timeout.Infinite; // -1 == native SNIOPEN_TIMEOUT_VALUE / INFINITE
- }
-
- int transparentNetworkResolutionStateNo = (int)transparentNetworkResolutionState;
- _status = SNINativeMethodWrapper.SNIOpenSyncEx(myInfo, serverName, ref base.handle,
- spnBuffer, instanceName, flushCache, fSync, timeout, fParallel, transparentNetworkResolutionStateNo, totalTimeout,
- ADP.IsAzureSqlServerEndpoint(serverName), ipPreference, cachedDNSInfo, hostNameInCertificate);
- }
- }
-
- // constructs SNI Handle for MARS session
- internal SNIHandle(SNINativeMethodWrapper.ConsumerInfo myInfo, SNIHandle parent, SqlConnectionIPAddressPreference ipPreference, SQLDNSInfo cachedDNSInfo) : base(IntPtr.Zero, true)
- {
- RuntimeHelpers.PrepareConstrainedRegions();
- try
- { }
- finally
- {
- _status = SNINativeMethodWrapper.SNIOpenMarsSession(myInfo, parent, ref base.handle, parent._fSync, ipPreference, cachedDNSInfo);
- }
- }
-
- public override bool IsInvalid
- {
- get
- {
- return (IntPtr.Zero == base.handle);
- }
- }
-
- override protected bool ReleaseHandle()
- {
- // NOTE: The SafeHandle class guarantees this will be called exactly once.
- IntPtr ptr = base.handle;
- base.handle = IntPtr.Zero;
- if (IntPtr.Zero != ptr)
- {
- if (0 != SNINativeMethodWrapper.SNIClose(ptr))
- {
- return false; // SNIClose should never fail.
- }
- }
- return true;
- }
-
- internal UInt32 Status
- {
- get
- {
- return _status;
- }
- }
- }
-
- internal sealed class SNIPacket : SafeHandle
- {
-
- internal SNIPacket(SafeHandle sniHandle) : base(IntPtr.Zero, true)
- {
- SNINativeMethodWrapper.SNIPacketAllocate(sniHandle, SNINativeMethodWrapper.IOType.WRITE, ref base.handle);
- if (IntPtr.Zero == base.handle)
- {
- throw SQL.SNIPacketAllocationFailure();
- }
- }
-
- public override bool IsInvalid
- {
- get
- {
- return (IntPtr.Zero == base.handle);
- }
- }
-
- override protected bool ReleaseHandle()
- {
- // NOTE: The SafeHandle class guarantees this will be called exactly once.
- IntPtr ptr = base.handle;
- base.handle = IntPtr.Zero;
- if (IntPtr.Zero != ptr)
- {
- SNINativeMethodWrapper.SNIPacketRelease(ptr);
- }
- return true;
- }
- }
-
- internal sealed class WritePacketCache : IDisposable
- {
- private bool _disposed;
- private Stack _packets;
-
- public WritePacketCache()
- {
- _disposed = false;
- _packets = new Stack();
- }
-
- public SNIPacket Take(SNIHandle sniHandle)
- {
- SNIPacket packet;
- if (_packets.Count > 0)
- {
- // Success - reset the packet
- packet = _packets.Pop();
- SNINativeMethodWrapper.SNIPacketReset(sniHandle, SNINativeMethodWrapper.IOType.WRITE, packet, SNINativeMethodWrapper.ConsumerNumber.SNI_Consumer_SNI);
- }
- else
- {
- // Failed to take a packet - create a new one
- packet = new SNIPacket(sniHandle);
- }
- return packet;
- }
-
- public void Add(SNIPacket packet)
- {
- if (!_disposed)
- {
- _packets.Push(packet);
- }
- else
- {
- // If we're disposed, then get rid of any packets added to us
- packet.Dispose();
- }
- }
-
- public void Clear()
- {
- while (_packets.Count > 0)
- {
- _packets.Pop().Dispose();
- }
- }
-
- public void Dispose()
- {
- if (!_disposed)
- {
- _disposed = true;
- Clear();
- }
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlReliabilityUtil.cs
similarity index 100%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlReliabilityUtil.cs
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlCommandReliabilityTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlCommandReliabilityTest.cs
index 9e3ed81af4..9f95c1a360 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlCommandReliabilityTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/RetryLogic/SqlCommandReliabilityTest.cs
@@ -264,7 +264,7 @@ public void DropDatabaseWithActiveConnection(string cnnString, SqlRetryLogicBase
cnn2.Open();
cnn3.Open();
- // kill the active connection to the database after the first faliure.
+ // kill the active connection to the database after the first failure.
provider.Retrying += (s, e) =>
{
currentRetries = e.RetryCount;
@@ -274,7 +274,7 @@ public void DropDatabaseWithActiveConnection(string cnnString, SqlRetryLogicBase
using (var cmd3 = cnn3.CreateCommand())
{
cmd3.CommandText = $"KILL {cnn2.ServerProcessId}";
- cmd3.ExecuteNonQueryAsync();
+ cmd3.ExecuteNonQuery();
}
cnn2.Close();
}