From 57e04bbb44132179482cb4630c0d85be2fa83536 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Mon, 20 Apr 2020 19:34:24 -0700 Subject: [PATCH 1/9] Remove Diagnostic Source from .NET Standard DLL as it's not supported --- .../src/Microsoft.Data.SqlClient.csproj | 4 +- .../Microsoft/Data/SqlClient/SqlCommand.cs | 76 +++++++++++++++---- .../Microsoft/Data/SqlClient/SqlConnection.cs | 45 ++++++++--- .../Data/SqlClient/SqlTransaction.cs | 20 +++-- tools/specs/Microsoft.Data.SqlClient.nuspec | 1 - 5 files changed, 109 insertions(+), 37 deletions(-) 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 102d6325b1..17de55e26f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -139,6 +139,7 @@ + @@ -262,7 +263,6 @@ - @@ -654,7 +654,7 @@ - + diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs index 9f71f8a5b3..0d83ce5e1c 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs @@ -69,8 +69,10 @@ public sealed partial class SqlCommand : DbCommand, ICloneable private static bool _forceInternalEndQuery = false; #endif +#if netcoreapp private static readonly DiagnosticListener _diagnosticListener = new DiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); private bool _parentOperationStarted = false; +#endif internal static readonly Action s_cancelIgnoreFailure = CancelIgnoreFailureCallback; @@ -460,8 +462,12 @@ internal SqlStatistics Statistics { if (null != _activeConnection) { - if (_activeConnection.StatisticsEnabled || - _diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand)) + if (_activeConnection.StatisticsEnabled +#if netcoreapp + || _diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand)) +#else + ) +#endif { return _activeConnection.Statistics; } @@ -942,9 +948,9 @@ override public object ExecuteScalar() // Reset _pendingCancel upon entry into any Execute - used to synchronize state // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; - +#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); - +#endif SqlStatistics statistics = null; long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); @@ -979,6 +985,7 @@ override public object ExecuteScalar() SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); WriteEndExecuteEvent(success, sqlExceptionNumber, synchronous: true); +#if netcoreapp if (e != null) { _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); @@ -987,6 +994,7 @@ override public object ExecuteScalar() { _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); } +#endif } } @@ -1026,9 +1034,9 @@ override public int ExecuteNonQuery() // Reset _pendingCancel upon entry into any Execute - used to synchronize state // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; - +#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); - +#endif SqlStatistics statistics = null; long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); @@ -1049,6 +1057,7 @@ override public int ExecuteNonQuery() { SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); +#if netcoreapp if (e != null) { _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); @@ -1057,6 +1066,7 @@ override public int ExecuteNonQuery() { _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); } +#endif } } @@ -1516,9 +1526,9 @@ public XmlReader ExecuteXmlReader() // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; bool success = false; - +#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); - +#endif SqlStatistics statistics = null; long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); @@ -1551,6 +1561,7 @@ public XmlReader ExecuteXmlReader() SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); WriteEndExecuteEvent(success, sqlExceptionNumber, synchronous: true); +#if netcoreapp if (e != null) { _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); @@ -1559,6 +1570,7 @@ public XmlReader ExecuteXmlReader() { _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); } +#endif } } @@ -1843,9 +1855,9 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) // Reset _pendingCancel upon entry into any Execute - used to synchronize state // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; - +#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); - +#endif SqlStatistics statistics = null; bool success = false; int? sqlExceptionNumber = null; @@ -1870,7 +1882,7 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { SqlStatistics.StopTimer(statistics); WriteEndExecuteEvent(success, sqlExceptionNumber, synchronous: true); - +#if netcoreapp if (e != null) { _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); @@ -1879,6 +1891,7 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); } +#endif } } @@ -2248,8 +2261,9 @@ private SqlDataReader InternalEndExecuteReader(IAsyncResult asyncResult, bool is public override Task ExecuteNonQueryAsync(CancellationToken cancellationToken) { SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); +#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); - +#endif TaskCompletionSource source = new TaskCompletionSource(); CancellationTokenRegistration registration = new CancellationTokenRegistration(); @@ -2274,7 +2288,9 @@ public override Task ExecuteNonQueryAsync(CancellationToken cancellationTok if (t.IsFaulted) { Exception e = t.Exception.InnerException; +#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); +#endif source.SetException(e); } else @@ -2287,13 +2303,17 @@ public override Task ExecuteNonQueryAsync(CancellationToken cancellationTok { source.SetResult(t.Result); } +#if netcoreapp _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); +#endif } }, TaskScheduler.Default); } catch (Exception e) { +#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); +#endif source.SetException(e); } @@ -2335,10 +2355,11 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b new public Task ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) { SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); +#if netcoreapp Guid operationId = default(Guid); if (!_parentOperationStarted) operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); - +#endif TaskCompletionSource source = new TaskCompletionSource(); CancellationTokenRegistration registration = new CancellationTokenRegistration(); @@ -2363,8 +2384,10 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b if (t.IsFaulted) { Exception e = t.Exception.InnerException; +#if netcoreapp if (!_parentOperationStarted) _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); +#endif source.SetException(e); } else @@ -2377,16 +2400,19 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b { source.SetResult(t.Result); } +#if netcoreapp if (!_parentOperationStarted) _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); +#endif } }, TaskScheduler.Default); } catch (Exception e) { +#if netcoreapp if (!_parentOperationStarted) _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); - +#endif source.SetException(e); } @@ -2396,9 +2422,10 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b /// public override Task ExecuteScalarAsync(CancellationToken cancellationToken) { +#if netcoreapp _parentOperationStarted = true; Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); - +#endif return ExecuteReaderAsync(cancellationToken).ContinueWith((executeTask) => { TaskCompletionSource source = new TaskCompletionSource(); @@ -2408,7 +2435,9 @@ public override Task ExecuteScalarAsync(CancellationToken cancellationTo } else if (executeTask.IsFaulted) { +#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, executeTask.Exception.InnerException); +#endif source.SetException(executeTask.Exception.InnerException); } else @@ -2426,7 +2455,9 @@ public override Task ExecuteScalarAsync(CancellationToken cancellationTo else if (readTask.IsFaulted) { reader.Dispose(); +#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, readTask.Exception.InnerException); +#endif source.SetException(readTask.Exception.InnerException); } else @@ -2454,12 +2485,16 @@ public override Task ExecuteScalarAsync(CancellationToken cancellationTo } if (exception != null) { +#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, exception); +#endif source.SetException(exception); } else { +#if netcoreapp _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); +#endif source.SetResult(result); } } @@ -2471,7 +2506,9 @@ public override Task ExecuteScalarAsync(CancellationToken cancellationTo } }, TaskScheduler.Default); } +#if netcoreapp _parentOperationStarted = false; +#endif return source.Task; }, TaskScheduler.Default).Unwrap(); } @@ -2486,8 +2523,9 @@ public Task ExecuteXmlReaderAsync() public Task ExecuteXmlReaderAsync(CancellationToken cancellationToken) { SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); +#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); - +#endif TaskCompletionSource source = new TaskCompletionSource(); CancellationTokenRegistration registration = new CancellationTokenRegistration(); @@ -2512,7 +2550,9 @@ public Task ExecuteXmlReaderAsync(CancellationToken cancellationToken if (t.IsFaulted) { Exception e = t.Exception.InnerException; +#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); +#endif source.SetException(e); } else @@ -2525,13 +2565,17 @@ public Task ExecuteXmlReaderAsync(CancellationToken cancellationToken { source.SetResult(t.Result); } +#if netcoreapp _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); +#endif } }, TaskScheduler.Default); } catch (Exception e) { +#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); +#endif source.SetException(e); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs index 4f847bc1a7..5730651d7f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -59,10 +59,10 @@ private enum CultureCheckState : uint internal SessionData _recoverySessionData; internal bool _suppressStateChangeForReconnection; private int _reconnectCount; - +#if netcoreapp // diagnostics listener private static readonly DiagnosticListener s_diagnosticListener = new DiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); - +#endif // Transient Fault handling flag. This is needed to convey to the downstream mechanism of connection establishment, if Transient Fault handling should be used or not // The downstream handling of Connection open is the same for idle connection resiliency. Currently we want to apply transient fault handling only to the connections opened // using SqlConnection.Open() method. @@ -890,7 +890,9 @@ public override void Close() try { ConnectionState previousState = State; +#if netcoreapp Guid operationId = default(Guid); +#endif Guid clientConnectionId = default(Guid); // during the call to Dispose() there is a redundant call to @@ -900,7 +902,9 @@ public override void Close() // log entries if (previousState != ConnectionState.Closed) { +#if netcoreapp operationId = s_diagnosticListener.WriteConnectionCloseBefore(this); +#endif // we want to cache the ClientConnectionId for After/Error logging, as when the connection // is closed then we will lose this identifier // @@ -951,6 +955,7 @@ public override void Close() // connection is open, as that's the valid use-case if (previousState != ConnectionState.Closed) { +#if netcoreapp if (e != null) { s_diagnosticListener.WriteConnectionCloseError(operationId, clientConnectionId, this, e); @@ -959,6 +964,7 @@ public override void Close() { s_diagnosticListener.WriteConnectionCloseAfter(operationId, clientConnectionId, this); } +#endif } } } @@ -1003,8 +1009,9 @@ public override void Open() SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); try { +#if netcoreapp Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this); - +#endif PrepareStatisticsForNewConnection(); SqlStatistics statistics = null; @@ -1027,7 +1034,7 @@ public override void Open() finally { SqlStatistics.StopTimer(statistics); - +#if netcoreapp if (e != null) { s_diagnosticListener.WriteConnectionOpenError(operationId, this, e); @@ -1036,6 +1043,7 @@ public override void Open() { s_diagnosticListener.WriteConnectionOpenAfter(operationId, this); } +#endif } } finally @@ -1271,8 +1279,9 @@ public override Task OpenAsync(CancellationToken cancellationToken) SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); try { +#if netcoreapp Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this); - +#endif PrepareStatisticsForNewConnection(); SqlStatistics statistics = null; @@ -1283,7 +1292,7 @@ public override Task OpenAsync(CancellationToken cancellationToken) System.Transactions.Transaction transaction = ADP.GetCurrentTransaction(); TaskCompletionSource completion = new TaskCompletionSource(transaction); TaskCompletionSource result = new TaskCompletionSource(); - +#if netcoreapp if (s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterOpenConnection) || s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlErrorOpenConnection)) { @@ -1299,7 +1308,7 @@ public override Task OpenAsync(CancellationToken cancellationToken) } }, TaskScheduler.Default); } - +#endif if (cancellationToken.IsCancellationRequested) { result.SetCanceled(); @@ -1315,7 +1324,9 @@ public override Task OpenAsync(CancellationToken cancellationToken) } catch (Exception e) { +#if netcoreapp s_diagnosticListener.WriteConnectionOpenError(operationId, this, e); +#endif result.SetException(e); return result.Task; } @@ -1341,8 +1352,10 @@ public override Task OpenAsync(CancellationToken cancellationToken) } catch (Exception ex) { +#if netcoreapp s_diagnosticListener.WriteConnectionOpenError(operationId, this, ex); - throw; +#endif + throw ex; } finally { @@ -1454,9 +1467,13 @@ internal void Retry(Task retryTask) private void PrepareStatisticsForNewConnection() { - if (StatisticsEnabled || - s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) || + if (StatisticsEnabled +#if netcoreapp + || s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) || s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterOpenConnection)) +#else + ) +#endif { if (null == _statistics) { @@ -1527,8 +1544,12 @@ private bool TryOpen(TaskCompletionSource retry) // The _statistics can change with StatisticsEnabled. Copying to a local variable before checking for a null value. SqlStatistics statistics = _statistics; - if (StatisticsEnabled || - (s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) && statistics != null)) + if (StatisticsEnabled +#if netcoreapp + || (s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) && statistics != null)) +#else + ) +#endif { ADP.TimerCurrent(out _statistics._openTimestamp); tdsInnerConnection.Parser.Statistics = _statistics; diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs index fb34462779..35d7f61461 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs @@ -14,8 +14,9 @@ namespace Microsoft.Data.SqlClient /// public sealed class SqlTransaction : DbTransaction { +#if netcoreapp private static readonly DiagnosticListener s_diagnosticListener = new DiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); - +#endif private static int _objectTypeCount; // EventSource Counter internal readonly int _objectID = System.Threading.Interlocked.Increment(ref _objectTypeCount); internal readonly IsolationLevel _isolationLevel = IsolationLevel.ReadCommitted; @@ -137,8 +138,9 @@ internal SqlStatistics Statistics override public void Commit() { Exception e = null; +#if netcoreapp Guid operationId = s_diagnosticListener.WriteTransactionCommitBefore(_isolationLevel, _connection, InternalTransaction); - +#endif ZombieCheck(); SqlStatistics statistics = null; @@ -174,6 +176,7 @@ override public void Commit() { SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); +#if netcoreapp if (e != null) { s_diagnosticListener.WriteTransactionCommitError(operationId, _isolationLevel, _connection, InternalTransaction, e); @@ -182,7 +185,7 @@ override public void Commit() { s_diagnosticListener.WriteTransactionCommitAfter(operationId, _isolationLevel, _connection, InternalTransaction); } - +#endif _isFromAPI = false; } } @@ -204,8 +207,9 @@ protected override void Dispose(bool disposing) override public void Rollback() { Exception e = null; +#if netcoreapp Guid operationId = s_diagnosticListener.WriteTransactionRollbackBefore(_isolationLevel, _connection, InternalTransaction); - +#endif if (IsYukonPartialZombie) { // Put something in the trace in case a customer has an issue @@ -236,6 +240,7 @@ override public void Rollback() { SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); +#if netcoreapp if (e != null) { s_diagnosticListener.WriteTransactionRollbackError(operationId, _isolationLevel, _connection, InternalTransaction, e); @@ -244,6 +249,7 @@ override public void Rollback() { s_diagnosticListener.WriteTransactionRollbackAfter(operationId, _isolationLevel, _connection, InternalTransaction); } +#endif _isFromAPI = false; } } @@ -253,8 +259,9 @@ override public void Rollback() public void Rollback(string transactionName) { Exception e = null; +#if netcoreapp Guid operationId = s_diagnosticListener.WriteTransactionRollbackBefore(_isolationLevel, _connection, InternalTransaction, transactionName); - +#endif ZombieCheck(); long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} transactionName='{1}'", ObjectID, transactionName); SqlStatistics statistics = null; @@ -275,6 +282,7 @@ public void Rollback(string transactionName) { SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); +#if netcoreapp if (e != null) { s_diagnosticListener.WriteTransactionRollbackError(operationId, _isolationLevel, _connection, InternalTransaction, e, transactionName); @@ -283,7 +291,7 @@ public void Rollback(string transactionName) { s_diagnosticListener.WriteTransactionRollbackAfter(operationId, _isolationLevel, _connection, InternalTransaction, transactionName); } - +#endif _isFromAPI = false; } diff --git a/tools/specs/Microsoft.Data.SqlClient.nuspec b/tools/specs/Microsoft.Data.SqlClient.nuspec index 5466991bb1..b4aaf443ac 100644 --- a/tools/specs/Microsoft.Data.SqlClient.nuspec +++ b/tools/specs/Microsoft.Data.SqlClient.nuspec @@ -60,7 +60,6 @@ When using NuGet 3.x this package requires at least version 3.4. - From 80249acf8f785096ca17e1b6ed50dd5cb1a83320 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Tue, 21 Apr 2020 18:00:41 -0700 Subject: [PATCH 2/9] Remove dependency on Configuration Manager for .NET Standard --- .../src/Microsoft.Data.SqlClient.csproj | 7 +- .../SqlAuthenticationProviderManager.cs | 117 +++--------------- ...uthenticationProviderManager.netcoreapp.cs | 110 ++++++++++++++++ .../SqlClient/SqlInternalConnectionTds.cs | 8 +- .../src/Microsoft/Data/SqlClient/TdsParser.cs | 3 +- 5 files changed, 135 insertions(+), 110 deletions(-) create mode 100644 src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.netcoreapp.cs 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 17de55e26f..7d6a183434 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -33,7 +33,7 @@ Microsoft\Data\SqlClient\SqlClientEventSource.cs - + Microsoft\Data\SqlClient\SqlClientLogger.cs @@ -57,7 +57,7 @@ Microsoft\Data\SqlClient\ColumnEncryptionKeyInfo.cs - + Microsoft\Data\SqlClient\OnChangedEventHandler.cs @@ -136,6 +136,7 @@ + @@ -649,7 +650,7 @@ - + diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs index 0d382aa512..bc46d77972 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs @@ -14,16 +14,25 @@ namespace Microsoft.Data.SqlClient /// /// Authentication provider manager. /// - internal class SqlAuthenticationProviderManager + internal partial class SqlAuthenticationProviderManager { private const string ActiveDirectoryPassword = "active directory password"; private const string ActiveDirectoryIntegrated = "active directory integrated"; private const string ActiveDirectoryInteractive = "active directory interactive"; + private readonly string _typeName; + private readonly IReadOnlyCollection _authenticationsWithAppSpecifiedProvider; + private readonly ConcurrentDictionary _providers; + private readonly SqlClientLogger _sqlAuthLogger = new SqlClientLogger(); + + public static readonly SqlAuthenticationProviderManager Instance; + static SqlAuthenticationProviderManager() { var activeDirectoryAuthNativeProvider = new ActiveDirectoryNativeAuthenticationProvider(); +#if netcoreapp SqlAuthenticationProviderConfigurationSection configurationSection; + try { configurationSection = (SqlAuthenticationProviderConfigurationSection)ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); @@ -32,84 +41,23 @@ static SqlAuthenticationProviderManager() { throw SQL.CannotGetAuthProviderConfig(e); } + Instance = new SqlAuthenticationProviderManager(configurationSection); +#else + Instance = new SqlAuthenticationProviderManager(); +#endif Instance.SetProvider(SqlAuthenticationMethod.ActiveDirectoryPassword, activeDirectoryAuthNativeProvider); } - public static readonly SqlAuthenticationProviderManager Instance; - - private readonly string _typeName; - private readonly SqlAuthenticationInitializer _initializer; - private readonly IReadOnlyCollection _authenticationsWithAppSpecifiedProvider; - private readonly ConcurrentDictionary _providers; - private readonly SqlClientLogger _sqlAuthLogger = new SqlClientLogger(); /// /// Constructor. /// - public SqlAuthenticationProviderManager(SqlAuthenticationProviderConfigurationSection configSection) + public SqlAuthenticationProviderManager() { _typeName = GetType().Name; - var methodName = "Ctor"; _providers = new ConcurrentDictionary(); - var authenticationsWithAppSpecifiedProvider = new HashSet(); - _authenticationsWithAppSpecifiedProvider = authenticationsWithAppSpecifiedProvider; - - if (configSection == null) - { - _sqlAuthLogger.LogInfo(_typeName, methodName, "No SqlAuthProviders configuration section found."); - return; - } - - // Create user-defined auth initializer, if any. - // - if (!string.IsNullOrEmpty(configSection.InitializerType)) - { - try - { - var initializerType = Type.GetType(configSection.InitializerType, true); - _initializer = (SqlAuthenticationInitializer)Activator.CreateInstance(initializerType); - _initializer.Initialize(); - } - catch (Exception e) - { - throw SQL.CannotCreateSqlAuthInitializer(configSection.InitializerType, e); - } - _sqlAuthLogger.LogInfo(_typeName, methodName, "Created user-defined SqlAuthenticationInitializer."); - } - else - { - _sqlAuthLogger.LogInfo(_typeName, methodName, "No user-defined SqlAuthenticationInitializer found."); - } - - // add user-defined providers, if any. - // - if (configSection.Providers != null && configSection.Providers.Count > 0) - { - foreach (ProviderSettings providerSettings in configSection.Providers) - { - SqlAuthenticationMethod authentication = AuthenticationEnumFromString(providerSettings.Name); - SqlAuthenticationProvider provider; - try - { - var providerType = Type.GetType(providerSettings.Type, true); - provider = (SqlAuthenticationProvider)Activator.CreateInstance(providerType); - } - catch (Exception e) - { - throw SQL.CannotCreateAuthProvider(authentication.ToString(), providerSettings.Type, e); - } - if (!provider.IsSupported(authentication)) - throw SQL.UnsupportedAuthenticationByProvider(authentication.ToString(), providerSettings.Type); - - _providers[authentication] = provider; - authenticationsWithAppSpecifiedProvider.Add(authentication); - _sqlAuthLogger.LogInfo(_typeName, methodName, string.Format("Added user-defined auth provider: {0} for authentication {1}.", providerSettings?.Type, authentication)); - } - } - else - { - _sqlAuthLogger.LogInfo(_typeName, methodName, "No user-defined auth providers."); - } + _authenticationsWithAppSpecifiedProvider = new HashSet(); + _sqlAuthLogger.LogInfo(_typeName, "Ctor", "No SqlAuthProviders configuration section found."); } /// @@ -156,17 +104,6 @@ public bool SetProvider(SqlAuthenticationMethod authenticationMethod, SqlAuthent return true; } - private static SqlAuthenticationMethod AuthenticationEnumFromString(string authentication) - { - switch (authentication.ToLowerInvariant()) - { - case ActiveDirectoryPassword: - return SqlAuthenticationMethod.ActiveDirectoryPassword; - default: - throw SQL.UnsupportedAuthentication(authentication); - } - } - private static string GetProviderType(SqlAuthenticationProvider provider) { if (provider == null) @@ -175,26 +112,6 @@ private static string GetProviderType(SqlAuthenticationProvider provider) } } - /// - /// The configuration section definition for reading app.config. - /// - internal class SqlAuthenticationProviderConfigurationSection : ConfigurationSection - { - public const string Name = "SqlAuthenticationProviders"; - - /// - /// User-defined auth providers. - /// - [ConfigurationProperty("providers")] - public ProviderSettingsCollection Providers => (ProviderSettingsCollection)base["providers"]; - - /// - /// User-defined initializer. - /// - [ConfigurationProperty("initializerType")] - public string InitializerType => base["initializerType"] as string; - } - /// public abstract class SqlAuthenticationInitializer { diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.netcoreapp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.netcoreapp.cs new file mode 100644 index 0000000000..b2899f60ca --- /dev/null +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.netcoreapp.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Configuration; + +namespace Microsoft.Data.SqlClient +{ + internal partial class SqlAuthenticationProviderManager + { + private readonly SqlAuthenticationInitializer _initializer; + + /// + /// Constructor. + /// + public SqlAuthenticationProviderManager(SqlAuthenticationProviderConfigurationSection configSection = null) + { + var methodName = "Ctor"; + _typeName = GetType().Name; + _providers = new ConcurrentDictionary(); + var authenticationsWithAppSpecifiedProvider = new HashSet(); + _authenticationsWithAppSpecifiedProvider = authenticationsWithAppSpecifiedProvider; + + if (configSection == null) + { + _sqlAuthLogger.LogInfo(_typeName, methodName, "No SqlAuthProviders configuration section found."); + return; + } + + // Create user-defined auth initializer, if any. + if (!string.IsNullOrEmpty(configSection.InitializerType)) + { + try + { + var initializerType = Type.GetType(configSection.InitializerType, true); + _initializer = (SqlAuthenticationInitializer)Activator.CreateInstance(initializerType); + _initializer.Initialize(); + } + catch (Exception e) + { + throw SQL.CannotCreateSqlAuthInitializer(configSection.InitializerType, e); + } + _sqlAuthLogger.LogInfo(_typeName, methodName, "Created user-defined SqlAuthenticationInitializer."); + } + else + { + _sqlAuthLogger.LogInfo(_typeName, methodName, "No user-defined SqlAuthenticationInitializer found."); + } + + // add user-defined providers, if any. + if (configSection.Providers != null && configSection.Providers.Count > 0) + { + foreach (ProviderSettings providerSettings in configSection.Providers) + { + SqlAuthenticationMethod authentication = AuthenticationEnumFromString(providerSettings.Name); + SqlAuthenticationProvider provider; + try + { + var providerType = Type.GetType(providerSettings.Type, true); + provider = (SqlAuthenticationProvider)Activator.CreateInstance(providerType); + } + catch (Exception e) + { + throw SQL.CannotCreateAuthProvider(authentication.ToString(), providerSettings.Type, e); + } + if (!provider.IsSupported(authentication)) + throw SQL.UnsupportedAuthenticationByProvider(authentication.ToString(), providerSettings.Type); + + _providers[authentication] = provider; + authenticationsWithAppSpecifiedProvider.Add(authentication); + _sqlAuthLogger.LogInfo(_typeName, methodName, string.Format("Added user-defined auth provider: {0} for authentication {1}.", providerSettings?.Type, authentication)); + } + } + else + { + _sqlAuthLogger.LogInfo(_typeName, methodName, "No user-defined auth providers."); + } + } + + private static SqlAuthenticationMethod AuthenticationEnumFromString(string authentication) + { + switch (authentication.ToLowerInvariant()) + { + case ActiveDirectoryPassword: + return SqlAuthenticationMethod.ActiveDirectoryPassword; + default: + throw SQL.UnsupportedAuthentication(authentication); + } + } + + /// + /// The configuration section definition for reading app.config. + /// + internal class SqlAuthenticationProviderConfigurationSection : ConfigurationSection + { + public const string Name = "SqlAuthenticationProviders"; + + /// + /// User-defined auth providers. + /// + [ConfigurationProperty("providers")] + public ProviderSettingsCollection Providers => (ProviderSettingsCollection)base["providers"]; + + /// + /// User-defined initializer. + /// + [ConfigurationProperty("initializerType")] + public string InitializerType => base["initializerType"] as string; + } + } +} diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs index c43c10471c..0021538d70 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs @@ -367,8 +367,7 @@ internal SqlInternalConnectionTds( SessionData reconnectSessionData = null, bool applyTransientFaultHandling = false, string accessToken = null, - DbConnectionPool pool = null, - SqlAuthenticationProviderManager sqlAuthProviderManager = null + DbConnectionPool pool = null ) : base(connectionOptions) { @@ -403,7 +402,7 @@ internal SqlInternalConnectionTds( } _activeDirectoryAuthTimeoutRetryHelper = new ActiveDirectoryAuthenticationTimeoutRetryHelper(); - _sqlAuthenticationProviderManager = sqlAuthProviderManager ?? SqlAuthenticationProviderManager.Instance; + _sqlAuthenticationProviderManager = SqlAuthenticationProviderManager.Instance; _identity = identity; Debug.Assert(newSecurePassword != null || newPassword != null, "cannot have both new secure change password and string based change password to be null"); @@ -1753,8 +1752,7 @@ private void AttemptOneLogin( ConnectionOptions.TrustServerCertificate, ConnectionOptions.IntegratedSecurity, withFailover, - ConnectionOptions.Authentication, - _sqlAuthenticationProviderManager); + ConnectionOptions.Authentication); _timeoutErrorInternal.EndPhase(SqlConnectionTimeoutErrorPhase.ConsumePreLoginHandshake); _timeoutErrorInternal.SetAndBeginPhase(SqlConnectionTimeoutErrorPhase.LoginBegin); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs index 02f05a7822..07c5c56a7c 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -344,8 +344,7 @@ internal void Connect( bool trustServerCert, bool integratedSecurity, bool withFailover, - SqlAuthenticationMethod authType, - SqlAuthenticationProviderManager sqlAuthProviderManager) + SqlAuthenticationMethod authType) { if (_state != TdsParserState.Closed) { From fc9d5f73756e06acd221bfc06986439ee561b59f Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Tue, 21 Apr 2020 18:32:31 -0700 Subject: [PATCH 3/9] Rename file --- ...tcoreapp.cs => SqlAuthenticationProviderManager.NetCoreApp.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/{SqlAuthenticationProviderManager.netcoreapp.cs => SqlAuthenticationProviderManager.NetCoreApp.cs} (100%) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.netcoreapp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs similarity index 100% rename from src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.netcoreapp.cs rename to src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs From 5030f4377de76d3dd3e6e5e00dd80274a297abf1 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Tue, 21 Apr 2020 18:33:25 -0700 Subject: [PATCH 4/9] Add header to file --- .../SqlAuthenticationProviderManager.NetCoreApp.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index b2899f60ca..7ece9e9844 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -1,4 +1,8 @@ -using System; +// 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.Concurrent; using System.Collections.Generic; using System.Configuration; From 24ce82373a58ce4dc93084e469a50eeec17d4ff9 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Wed, 22 Apr 2020 17:18:20 -0700 Subject: [PATCH 5/9] Improvements --- .../src/Microsoft.Data.SqlClient.csproj | 4 +- .../SqlClientDiagnosticListenerExtensions.cs | 30 ++++----- .../Microsoft/Data/SqlClient/SqlCommand.cs | 66 ++----------------- .../Microsoft/Data/SqlClient/SqlConnection.cs | 35 ++-------- .../SqlDiagnosticListener.NetCoreApp.cs | 11 ++++ .../SqlDiagnosticListener.NetStandard.cs | 32 +++++++++ .../Data/SqlClient/SqlTransaction.cs | 17 +---- 7 files changed, 73 insertions(+), 122 deletions(-) create mode 100644 src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetCoreApp.cs create mode 100644 src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetStandard.cs 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 7d6a183434..1588f56424 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -131,6 +131,7 @@ + @@ -139,8 +140,8 @@ + - @@ -264,6 +265,7 @@ + diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientDiagnosticListenerExtensions.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientDiagnosticListenerExtensions.cs index d8b8b073c3..7bcd7cffb5 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientDiagnosticListenerExtensions.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientDiagnosticListenerExtensions.cs @@ -38,7 +38,7 @@ internal static class SqlClientDiagnosticListenerExtensions public const string SqlAfterRollbackTransaction = SqlClientPrefix + nameof(WriteTransactionRollbackAfter); public const string SqlErrorRollbackTransaction = SqlClientPrefix + nameof(WriteTransactionRollbackError); - public static Guid WriteCommandBefore(this DiagnosticListener @this, SqlCommand sqlCommand, SqlTransaction transaction, [CallerMemberName] string operation = "") + public static Guid WriteCommandBefore(this SqlDiagnosticListener @this, SqlCommand sqlCommand, SqlTransaction transaction, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlBeforeExecuteCommand)) { @@ -62,7 +62,7 @@ public static Guid WriteCommandBefore(this DiagnosticListener @this, SqlCommand return Guid.Empty; } - public static void WriteCommandAfter(this DiagnosticListener @this, Guid operationId, SqlCommand sqlCommand, SqlTransaction transaction, [CallerMemberName] string operation = "") + public static void WriteCommandAfter(this SqlDiagnosticListener @this, Guid operationId, SqlCommand sqlCommand, SqlTransaction transaction, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlAfterExecuteCommand)) { @@ -81,7 +81,7 @@ public static void WriteCommandAfter(this DiagnosticListener @this, Guid operati } } - public static void WriteCommandError(this DiagnosticListener @this, Guid operationId, SqlCommand sqlCommand, SqlTransaction transaction, Exception ex, [CallerMemberName] string operation = "") + public static void WriteCommandError(this SqlDiagnosticListener @this, Guid operationId, SqlCommand sqlCommand, SqlTransaction transaction, Exception ex, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlErrorExecuteCommand)) { @@ -100,7 +100,7 @@ public static void WriteCommandError(this DiagnosticListener @this, Guid operati } } - public static Guid WriteConnectionOpenBefore(this DiagnosticListener @this, SqlConnection sqlConnection, [CallerMemberName] string operation = "") + public static Guid WriteConnectionOpenBefore(this SqlDiagnosticListener @this, SqlConnection sqlConnection, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlBeforeOpenConnection)) { @@ -123,7 +123,7 @@ public static Guid WriteConnectionOpenBefore(this DiagnosticListener @this, SqlC return Guid.Empty; } - public static void WriteConnectionOpenAfter(this DiagnosticListener @this, Guid operationId, SqlConnection sqlConnection, [CallerMemberName] string operation = "") + public static void WriteConnectionOpenAfter(this SqlDiagnosticListener @this, Guid operationId, SqlConnection sqlConnection, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlAfterOpenConnection)) { @@ -142,7 +142,7 @@ public static void WriteConnectionOpenAfter(this DiagnosticListener @this, Guid } } - public static void WriteConnectionOpenError(this DiagnosticListener @this, Guid operationId, SqlConnection sqlConnection, Exception ex, [CallerMemberName] string operation = "") + public static void WriteConnectionOpenError(this SqlDiagnosticListener @this, Guid operationId, SqlConnection sqlConnection, Exception ex, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlErrorOpenConnection)) { @@ -161,7 +161,7 @@ public static void WriteConnectionOpenError(this DiagnosticListener @this, Guid } } - public static Guid WriteConnectionCloseBefore(this DiagnosticListener @this, SqlConnection sqlConnection, [CallerMemberName] string operation = "") + public static Guid WriteConnectionCloseBefore(this SqlDiagnosticListener @this, SqlConnection sqlConnection, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlBeforeCloseConnection)) { @@ -185,7 +185,7 @@ public static Guid WriteConnectionCloseBefore(this DiagnosticListener @this, Sql return Guid.Empty; } - public static void WriteConnectionCloseAfter(this DiagnosticListener @this, Guid operationId, Guid clientConnectionId, SqlConnection sqlConnection, [CallerMemberName] string operation = "") + public static void WriteConnectionCloseAfter(this SqlDiagnosticListener @this, Guid operationId, Guid clientConnectionId, SqlConnection sqlConnection, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlAfterCloseConnection)) { @@ -203,7 +203,7 @@ public static void WriteConnectionCloseAfter(this DiagnosticListener @this, Guid } } - public static void WriteConnectionCloseError(this DiagnosticListener @this, Guid operationId, Guid clientConnectionId, SqlConnection sqlConnection, Exception ex, [CallerMemberName] string operation = "") + public static void WriteConnectionCloseError(this SqlDiagnosticListener @this, Guid operationId, Guid clientConnectionId, SqlConnection sqlConnection, Exception ex, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlErrorCloseConnection)) { @@ -222,7 +222,7 @@ public static void WriteConnectionCloseError(this DiagnosticListener @this, Guid } } - public static Guid WriteTransactionCommitBefore(this DiagnosticListener @this, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, [CallerMemberName] string operation = "") + public static Guid WriteTransactionCommitBefore(this SqlDiagnosticListener @this, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlBeforeCommitTransaction)) { @@ -246,7 +246,7 @@ public static Guid WriteTransactionCommitBefore(this DiagnosticListener @this, I return Guid.Empty; } - public static void WriteTransactionCommitAfter(this DiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, [CallerMemberName] string operation = "") + public static void WriteTransactionCommitAfter(this SqlDiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlAfterCommitTransaction)) { @@ -264,7 +264,7 @@ public static void WriteTransactionCommitAfter(this DiagnosticListener @this, Gu } } - public static void WriteTransactionCommitError(this DiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, Exception ex, [CallerMemberName] string operation = "") + public static void WriteTransactionCommitError(this SqlDiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, Exception ex, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlErrorCommitTransaction)) { @@ -283,7 +283,7 @@ public static void WriteTransactionCommitError(this DiagnosticListener @this, Gu } } - public static Guid WriteTransactionRollbackBefore(this DiagnosticListener @this, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, string transactionName = null, [CallerMemberName] string operation = "") + public static Guid WriteTransactionRollbackBefore(this SqlDiagnosticListener @this, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, string transactionName = null, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlBeforeRollbackTransaction)) { @@ -308,7 +308,7 @@ public static Guid WriteTransactionRollbackBefore(this DiagnosticListener @this, return Guid.Empty; } - public static void WriteTransactionRollbackAfter(this DiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, string transactionName = null, [CallerMemberName] string operation = "") + public static void WriteTransactionRollbackAfter(this SqlDiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, string transactionName = null, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlAfterRollbackTransaction)) { @@ -327,7 +327,7 @@ public static void WriteTransactionRollbackAfter(this DiagnosticListener @this, } } - public static void WriteTransactionRollbackError(this DiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, Exception ex, string transactionName = null, [CallerMemberName] string operation = "") + public static void WriteTransactionRollbackError(this SqlDiagnosticListener @this, Guid operationId, IsolationLevel isolationLevel, SqlConnection connection, SqlInternalTransaction transaction, Exception ex, string transactionName = null, [CallerMemberName] string operation = "") { if (@this.IsEnabled(SqlErrorRollbackTransaction)) { diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs index 0d83ce5e1c..0808f1ac6b 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs @@ -69,10 +69,8 @@ public sealed partial class SqlCommand : DbCommand, ICloneable private static bool _forceInternalEndQuery = false; #endif -#if netcoreapp - private static readonly DiagnosticListener _diagnosticListener = new DiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); + private static readonly SqlDiagnosticListener _diagnosticListener = new SqlDiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); private bool _parentOperationStarted = false; -#endif internal static readonly Action s_cancelIgnoreFailure = CancelIgnoreFailureCallback; @@ -463,11 +461,7 @@ internal SqlStatistics Statistics if (null != _activeConnection) { if (_activeConnection.StatisticsEnabled -#if netcoreapp || _diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand)) -#else - ) -#endif { return _activeConnection.Statistics; } @@ -948,9 +942,7 @@ override public object ExecuteScalar() // Reset _pendingCancel upon entry into any Execute - used to synchronize state // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; -#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); -#endif SqlStatistics statistics = null; long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); @@ -985,7 +977,6 @@ override public object ExecuteScalar() SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); WriteEndExecuteEvent(success, sqlExceptionNumber, synchronous: true); -#if netcoreapp if (e != null) { _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); @@ -994,7 +985,6 @@ override public object ExecuteScalar() { _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); } -#endif } } @@ -1034,9 +1024,7 @@ override public int ExecuteNonQuery() // Reset _pendingCancel upon entry into any Execute - used to synchronize state // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; -#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); -#endif SqlStatistics statistics = null; long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); @@ -1057,7 +1045,6 @@ override public int ExecuteNonQuery() { SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); -#if netcoreapp if (e != null) { _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); @@ -1066,7 +1053,6 @@ override public int ExecuteNonQuery() { _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); } -#endif } } @@ -1526,9 +1512,7 @@ public XmlReader ExecuteXmlReader() // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; bool success = false; -#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); -#endif SqlStatistics statistics = null; long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); @@ -1561,7 +1545,6 @@ public XmlReader ExecuteXmlReader() SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); WriteEndExecuteEvent(success, sqlExceptionNumber, synchronous: true); -#if netcoreapp if (e != null) { _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); @@ -1570,7 +1553,6 @@ public XmlReader ExecuteXmlReader() { _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); } -#endif } } @@ -1855,9 +1837,7 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) // Reset _pendingCancel upon entry into any Execute - used to synchronize state // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; -#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); -#endif SqlStatistics statistics = null; bool success = false; int? sqlExceptionNumber = null; @@ -1882,7 +1862,6 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { SqlStatistics.StopTimer(statistics); WriteEndExecuteEvent(success, sqlExceptionNumber, synchronous: true); -#if netcoreapp if (e != null) { _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); @@ -1891,7 +1870,6 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); } -#endif } } @@ -2261,9 +2239,7 @@ private SqlDataReader InternalEndExecuteReader(IAsyncResult asyncResult, bool is public override Task ExecuteNonQueryAsync(CancellationToken cancellationToken) { SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); -#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); -#endif TaskCompletionSource source = new TaskCompletionSource(); CancellationTokenRegistration registration = new CancellationTokenRegistration(); @@ -2288,9 +2264,7 @@ public override Task ExecuteNonQueryAsync(CancellationToken cancellationTok if (t.IsFaulted) { Exception e = t.Exception.InnerException; -#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); -#endif source.SetException(e); } else @@ -2303,17 +2277,13 @@ public override Task ExecuteNonQueryAsync(CancellationToken cancellationTok { source.SetResult(t.Result); } -#if netcoreapp _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); -#endif } }, TaskScheduler.Default); } catch (Exception e) { -#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); -#endif source.SetException(e); } @@ -2355,14 +2325,13 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b new public Task ExecuteReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken) { SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); -#if netcoreapp Guid operationId = default(Guid); if (!_parentOperationStarted) operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); -#endif - TaskCompletionSource source = new TaskCompletionSource(); + TaskCompletionSource source = new TaskCompletionSource(); CancellationTokenRegistration registration = new CancellationTokenRegistration(); + if (cancellationToken.CanBeCanceled) { if (cancellationToken.IsCancellationRequested) @@ -2384,10 +2353,8 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b if (t.IsFaulted) { Exception e = t.Exception.InnerException; -#if netcoreapp if (!_parentOperationStarted) _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); -#endif source.SetException(e); } else @@ -2400,19 +2367,15 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b { source.SetResult(t.Result); } -#if netcoreapp if (!_parentOperationStarted) _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); -#endif } }, TaskScheduler.Default); } catch (Exception e) { -#if netcoreapp if (!_parentOperationStarted) _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); -#endif source.SetException(e); } @@ -2422,10 +2385,8 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b /// public override Task ExecuteScalarAsync(CancellationToken cancellationToken) { -#if netcoreapp _parentOperationStarted = true; Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); -#endif return ExecuteReaderAsync(cancellationToken).ContinueWith((executeTask) => { TaskCompletionSource source = new TaskCompletionSource(); @@ -2435,9 +2396,7 @@ public override Task ExecuteScalarAsync(CancellationToken cancellationTo } else if (executeTask.IsFaulted) { -#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, executeTask.Exception.InnerException); -#endif source.SetException(executeTask.Exception.InnerException); } else @@ -2455,9 +2414,7 @@ public override Task ExecuteScalarAsync(CancellationToken cancellationTo else if (readTask.IsFaulted) { reader.Dispose(); -#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, readTask.Exception.InnerException); -#endif source.SetException(readTask.Exception.InnerException); } else @@ -2485,16 +2442,12 @@ public override Task ExecuteScalarAsync(CancellationToken cancellationTo } if (exception != null) { -#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, exception); -#endif source.SetException(exception); } else { -#if netcoreapp _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); -#endif source.SetResult(result); } } @@ -2506,9 +2459,7 @@ public override Task ExecuteScalarAsync(CancellationToken cancellationTo } }, TaskScheduler.Default); } -#if netcoreapp _parentOperationStarted = false; -#endif return source.Task; }, TaskScheduler.Default).Unwrap(); } @@ -2523,12 +2474,11 @@ public Task ExecuteXmlReaderAsync() public Task ExecuteXmlReaderAsync(CancellationToken cancellationToken) { SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); -#if netcoreapp Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); -#endif - TaskCompletionSource source = new TaskCompletionSource(); + TaskCompletionSource source = new TaskCompletionSource(); CancellationTokenRegistration registration = new CancellationTokenRegistration(); + if (cancellationToken.CanBeCanceled) { if (cancellationToken.IsCancellationRequested) @@ -2550,9 +2500,7 @@ public Task ExecuteXmlReaderAsync(CancellationToken cancellationToken if (t.IsFaulted) { Exception e = t.Exception.InnerException; -#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); -#endif source.SetException(e); } else @@ -2565,17 +2513,13 @@ public Task ExecuteXmlReaderAsync(CancellationToken cancellationToken { source.SetResult(t.Result); } -#if netcoreapp _diagnosticListener.WriteCommandAfter(operationId, this, _transaction); -#endif } }, TaskScheduler.Default); } catch (Exception e) { -#if netcoreapp _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); -#endif source.SetException(e); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs index 5730651d7f..35b625d99a 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -59,10 +59,10 @@ private enum CultureCheckState : uint internal SessionData _recoverySessionData; internal bool _suppressStateChangeForReconnection; private int _reconnectCount; -#if netcoreapp + // diagnostics listener - private static readonly DiagnosticListener s_diagnosticListener = new DiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); -#endif + private static readonly SqlDiagnosticListener s_diagnosticListener = new SqlDiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); + // Transient Fault handling flag. This is needed to convey to the downstream mechanism of connection establishment, if Transient Fault handling should be used or not // The downstream handling of Connection open is the same for idle connection resiliency. Currently we want to apply transient fault handling only to the connections opened // using SqlConnection.Open() method. @@ -890,9 +890,7 @@ public override void Close() try { ConnectionState previousState = State; -#if netcoreapp Guid operationId = default(Guid); -#endif Guid clientConnectionId = default(Guid); // during the call to Dispose() there is a redundant call to @@ -902,9 +900,7 @@ public override void Close() // log entries if (previousState != ConnectionState.Closed) { -#if netcoreapp operationId = s_diagnosticListener.WriteConnectionCloseBefore(this); -#endif // we want to cache the ClientConnectionId for After/Error logging, as when the connection // is closed then we will lose this identifier // @@ -955,7 +951,6 @@ public override void Close() // connection is open, as that's the valid use-case if (previousState != ConnectionState.Closed) { -#if netcoreapp if (e != null) { s_diagnosticListener.WriteConnectionCloseError(operationId, clientConnectionId, this, e); @@ -964,7 +959,6 @@ public override void Close() { s_diagnosticListener.WriteConnectionCloseAfter(operationId, clientConnectionId, this); } -#endif } } } @@ -1009,9 +1003,8 @@ public override void Open() SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); try { -#if netcoreapp Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this); -#endif + PrepareStatisticsForNewConnection(); SqlStatistics statistics = null; @@ -1034,7 +1027,6 @@ public override void Open() finally { SqlStatistics.StopTimer(statistics); -#if netcoreapp if (e != null) { s_diagnosticListener.WriteConnectionOpenError(operationId, this, e); @@ -1043,7 +1035,6 @@ public override void Open() { s_diagnosticListener.WriteConnectionOpenAfter(operationId, this); } -#endif } } finally @@ -1279,9 +1270,7 @@ public override Task OpenAsync(CancellationToken cancellationToken) SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); try { -#if netcoreapp Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this); -#endif PrepareStatisticsForNewConnection(); SqlStatistics statistics = null; @@ -1292,7 +1281,7 @@ public override Task OpenAsync(CancellationToken cancellationToken) System.Transactions.Transaction transaction = ADP.GetCurrentTransaction(); TaskCompletionSource completion = new TaskCompletionSource(transaction); TaskCompletionSource result = new TaskCompletionSource(); -#if netcoreapp + if (s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterOpenConnection) || s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlErrorOpenConnection)) { @@ -1308,14 +1297,12 @@ public override Task OpenAsync(CancellationToken cancellationToken) } }, TaskScheduler.Default); } -#endif if (cancellationToken.IsCancellationRequested) { result.SetCanceled(); return result.Task; } - bool completed; try @@ -1324,9 +1311,7 @@ public override Task OpenAsync(CancellationToken cancellationToken) } catch (Exception e) { -#if netcoreapp s_diagnosticListener.WriteConnectionOpenError(operationId, this, e); -#endif result.SetException(e); return result.Task; } @@ -1352,9 +1337,7 @@ public override Task OpenAsync(CancellationToken cancellationToken) } catch (Exception ex) { -#if netcoreapp s_diagnosticListener.WriteConnectionOpenError(operationId, this, ex); -#endif throw ex; } finally @@ -1468,12 +1451,8 @@ internal void Retry(Task retryTask) private void PrepareStatisticsForNewConnection() { if (StatisticsEnabled -#if netcoreapp || s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) || s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterOpenConnection)) -#else - ) -#endif { if (null == _statistics) { @@ -1545,11 +1524,7 @@ private bool TryOpen(TaskCompletionSource retry) // The _statistics can change with StatisticsEnabled. Copying to a local variable before checking for a null value. SqlStatistics statistics = _statistics; if (StatisticsEnabled -#if netcoreapp || (s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) && statistics != null)) -#else - ) -#endif { ADP.TimerCurrent(out _statistics._openTimestamp); tdsInnerConnection.Parser.Statistics = _statistics; diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetCoreApp.cs new file mode 100644 index 0000000000..4cf358d032 --- /dev/null +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetCoreApp.cs @@ -0,0 +1,11 @@ +using System.Diagnostics; + +namespace Microsoft.Data.SqlClient +{ + internal sealed class SqlDiagnosticListener : DiagnosticListener + { + public SqlDiagnosticListener(string name) : base(name) + { + } + } +} diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetStandard.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetStandard.cs new file mode 100644 index 0000000000..b62efb6588 --- /dev/null +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetStandard.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; + +namespace Microsoft.Data.SqlClient +{ + internal sealed class SqlDiagnosticListener : IObservable> + { + public SqlDiagnosticListener(string name) + { + } + + public IDisposable Subscribe(IObserver> observer) + { + throw new NotSupportedException(); + } + + public bool IsEnabled() + { + return false; + } + + public bool IsEnabled(string name) + { + return false; + } + + internal void Write(string sqlBeforeExecuteCommand, object p) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs index 35d7f61461..f104c4b873 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs @@ -14,9 +14,7 @@ namespace Microsoft.Data.SqlClient /// public sealed class SqlTransaction : DbTransaction { -#if netcoreapp - private static readonly DiagnosticListener s_diagnosticListener = new DiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); -#endif + private static readonly SqlDiagnosticListener s_diagnosticListener = new SqlDiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName); private static int _objectTypeCount; // EventSource Counter internal readonly int _objectID = System.Threading.Interlocked.Increment(ref _objectTypeCount); internal readonly IsolationLevel _isolationLevel = IsolationLevel.ReadCommitted; @@ -138,9 +136,8 @@ internal SqlStatistics Statistics override public void Commit() { Exception e = null; -#if netcoreapp Guid operationId = s_diagnosticListener.WriteTransactionCommitBefore(_isolationLevel, _connection, InternalTransaction); -#endif + ZombieCheck(); SqlStatistics statistics = null; @@ -176,7 +173,6 @@ override public void Commit() { SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); -#if netcoreapp if (e != null) { s_diagnosticListener.WriteTransactionCommitError(operationId, _isolationLevel, _connection, InternalTransaction, e); @@ -185,7 +181,6 @@ override public void Commit() { s_diagnosticListener.WriteTransactionCommitAfter(operationId, _isolationLevel, _connection, InternalTransaction); } -#endif _isFromAPI = false; } } @@ -207,9 +202,7 @@ protected override void Dispose(bool disposing) override public void Rollback() { Exception e = null; -#if netcoreapp Guid operationId = s_diagnosticListener.WriteTransactionRollbackBefore(_isolationLevel, _connection, InternalTransaction); -#endif if (IsYukonPartialZombie) { // Put something in the trace in case a customer has an issue @@ -240,7 +233,6 @@ override public void Rollback() { SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); -#if netcoreapp if (e != null) { s_diagnosticListener.WriteTransactionRollbackError(operationId, _isolationLevel, _connection, InternalTransaction, e); @@ -249,7 +241,6 @@ override public void Rollback() { s_diagnosticListener.WriteTransactionRollbackAfter(operationId, _isolationLevel, _connection, InternalTransaction); } -#endif _isFromAPI = false; } } @@ -259,9 +250,7 @@ override public void Rollback() public void Rollback(string transactionName) { Exception e = null; -#if netcoreapp Guid operationId = s_diagnosticListener.WriteTransactionRollbackBefore(_isolationLevel, _connection, InternalTransaction, transactionName); -#endif ZombieCheck(); long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} transactionName='{1}'", ObjectID, transactionName); SqlStatistics statistics = null; @@ -282,7 +271,6 @@ public void Rollback(string transactionName) { SqlStatistics.StopTimer(statistics); SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); -#if netcoreapp if (e != null) { s_diagnosticListener.WriteTransactionRollbackError(operationId, _isolationLevel, _connection, InternalTransaction, e, transactionName); @@ -291,7 +279,6 @@ public void Rollback(string transactionName) { s_diagnosticListener.WriteTransactionRollbackAfter(operationId, _isolationLevel, _connection, InternalTransaction, transactionName); } -#endif _isFromAPI = false; } From 91a1f151f5359c4d4de724660849bc01116dd62b Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Wed, 22 Apr 2020 17:24:54 -0700 Subject: [PATCH 6/9] Fix spaces --- .../Microsoft/Data/SqlClient/SqlCommand.cs | 20 +++++++++++++++---- .../Microsoft/Data/SqlClient/SqlConnection.cs | 14 +++++++------ .../Data/SqlClient/SqlTransaction.cs | 5 ++++- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs index 0808f1ac6b..a862d74bcf 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs @@ -460,8 +460,8 @@ internal SqlStatistics Statistics { if (null != _activeConnection) { - if (_activeConnection.StatisticsEnabled - || _diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand)) + if (_activeConnection.StatisticsEnabled || + _diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand)) { return _activeConnection.Statistics; } @@ -942,7 +942,9 @@ override public object ExecuteScalar() // Reset _pendingCancel upon entry into any Execute - used to synchronize state // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; + Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); + SqlStatistics statistics = null; long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); @@ -1024,7 +1026,9 @@ override public int ExecuteNonQuery() // Reset _pendingCancel upon entry into any Execute - used to synchronize state // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; + Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); + SqlStatistics statistics = null; long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); @@ -1512,7 +1516,9 @@ public XmlReader ExecuteXmlReader() // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; bool success = false; + Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); + SqlStatistics statistics = null; long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); @@ -1837,7 +1843,9 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) // Reset _pendingCancel upon entry into any Execute - used to synchronize state // between entry into Execute* API and the thread obtaining the stateObject. _pendingCancel = false; + Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); + SqlStatistics statistics = null; bool success = false; int? sqlExceptionNumber = null; @@ -1862,6 +1870,7 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { SqlStatistics.StopTimer(statistics); WriteEndExecuteEvent(success, sqlExceptionNumber, synchronous: true); + if (e != null) { _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); @@ -2240,6 +2249,7 @@ public override Task ExecuteNonQueryAsync(CancellationToken cancellationTok { SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); + TaskCompletionSource source = new TaskCompletionSource(); CancellationTokenRegistration registration = new CancellationTokenRegistration(); @@ -2330,8 +2340,8 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); TaskCompletionSource source = new TaskCompletionSource(); - CancellationTokenRegistration registration = new CancellationTokenRegistration(); + CancellationTokenRegistration registration = new CancellationTokenRegistration(); if (cancellationToken.CanBeCanceled) { if (cancellationToken.IsCancellationRequested) @@ -2376,6 +2386,7 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b { if (!_parentOperationStarted) _diagnosticListener.WriteCommandError(operationId, this, _transaction, e); + source.SetException(e); } @@ -2387,6 +2398,7 @@ public override Task ExecuteScalarAsync(CancellationToken cancellationTo { _parentOperationStarted = true; Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); + return ExecuteReaderAsync(cancellationToken).ContinueWith((executeTask) => { TaskCompletionSource source = new TaskCompletionSource(); @@ -2477,8 +2489,8 @@ public Task ExecuteXmlReaderAsync(CancellationToken cancellationToken Guid operationId = _diagnosticListener.WriteCommandBefore(this, _transaction); TaskCompletionSource source = new TaskCompletionSource(); - CancellationTokenRegistration registration = new CancellationTokenRegistration(); + CancellationTokenRegistration registration = new CancellationTokenRegistration(); if (cancellationToken.CanBeCanceled) { if (cancellationToken.IsCancellationRequested) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs index 35b625d99a..c0d7965fe3 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -1027,6 +1027,7 @@ public override void Open() finally { SqlStatistics.StopTimer(statistics); + if (e != null) { s_diagnosticListener.WriteConnectionOpenError(operationId, this, e); @@ -1271,6 +1272,7 @@ public override Task OpenAsync(CancellationToken cancellationToken) try { Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this); + PrepareStatisticsForNewConnection(); SqlStatistics statistics = null; @@ -1297,12 +1299,14 @@ public override Task OpenAsync(CancellationToken cancellationToken) } }, TaskScheduler.Default); } + if (cancellationToken.IsCancellationRequested) { result.SetCanceled(); return result.Task; } + bool completed; try @@ -1450,8 +1454,8 @@ internal void Retry(Task retryTask) private void PrepareStatisticsForNewConnection() { - if (StatisticsEnabled - || s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) || + if (StatisticsEnabled || + s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) || s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterOpenConnection)) { if (null == _statistics) @@ -1523,8 +1527,8 @@ private bool TryOpen(TaskCompletionSource retry) // The _statistics can change with StatisticsEnabled. Copying to a local variable before checking for a null value. SqlStatistics statistics = _statistics; - if (StatisticsEnabled - || (s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) && statistics != null)) + if (StatisticsEnabled || + (s_diagnosticListener.IsEnabled(SqlClientDiagnosticListenerExtensions.SqlAfterExecuteCommand) && statistics != null)) { ADP.TimerCurrent(out _statistics._openTimestamp); tdsInnerConnection.Parser.Statistics = _statistics; @@ -2052,5 +2056,3 @@ private SqlUdtInfo GetInfoFromType(Type t) } } } - - diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs index f104c4b873..4a936b4c7c 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlTransaction.cs @@ -181,6 +181,7 @@ override public void Commit() { s_diagnosticListener.WriteTransactionCommitAfter(operationId, _isolationLevel, _connection, InternalTransaction); } + _isFromAPI = false; } } @@ -203,6 +204,7 @@ override public void Rollback() { Exception e = null; Guid operationId = s_diagnosticListener.WriteTransactionRollbackBefore(_isolationLevel, _connection, InternalTransaction); + if (IsYukonPartialZombie) { // Put something in the trace in case a customer has an issue @@ -251,6 +253,7 @@ public void Rollback(string transactionName) { Exception e = null; Guid operationId = s_diagnosticListener.WriteTransactionRollbackBefore(_isolationLevel, _connection, InternalTransaction, transactionName); + ZombieCheck(); long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} transactionName='{1}'", ObjectID, transactionName); SqlStatistics statistics = null; @@ -279,6 +282,7 @@ public void Rollback(string transactionName) { s_diagnosticListener.WriteTransactionRollbackAfter(operationId, _isolationLevel, _connection, InternalTransaction, transactionName); } + _isFromAPI = false; } @@ -345,4 +349,3 @@ private void ZombieCheck() } } } - From 8f9d83a78570d43f34680294af874f352904b95b Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 23 Apr 2020 13:34:25 -0700 Subject: [PATCH 7/9] Address review feedback --- .../SqlAuthenticationProviderManager.NetCoreApp.cs | 2 ++ .../Data/SqlClient/SqlDiagnosticListener.NetCoreApp.cs | 6 +++++- .../Data/SqlClient/SqlDiagnosticListener.NetStandard.cs | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index 7ece9e9844..1bba2aef4b 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -67,7 +67,9 @@ public SqlAuthenticationProviderManager(SqlAuthenticationProviderConfigurationSe throw SQL.CannotCreateAuthProvider(authentication.ToString(), providerSettings.Type, e); } if (!provider.IsSupported(authentication)) + { throw SQL.UnsupportedAuthenticationByProvider(authentication.ToString(), providerSettings.Type); + } _providers[authentication] = provider; authenticationsWithAppSpecifiedProvider.Add(authentication); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetCoreApp.cs index 4cf358d032..ec3b6549b3 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetCoreApp.cs @@ -1,4 +1,8 @@ -using System.Diagnostics; +// 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 { diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetStandard.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetStandard.cs index b62efb6588..726a24c934 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetStandard.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDiagnosticListener.NetStandard.cs @@ -1,4 +1,8 @@ -using System; +// 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; namespace Microsoft.Data.SqlClient From f812e34c6759d828a4a7a9d22b1ad0dda1fbbb0f Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 24 Apr 2020 12:26:08 -0700 Subject: [PATCH 8/9] Address review feedback --- .../src/Microsoft.Data.SqlClient.csproj | 1 + ...uthenticationProviderManager.NetCoreApp.cs | 18 +++++++++++++++ ...thenticationProviderManager.NetStandard.cs | 16 +++++++++++++ .../SqlAuthenticationProviderManager.cs | 23 ------------------- .../Microsoft/Data/SqlClient/SqlConnection.cs | 2 +- 5 files changed, 36 insertions(+), 24 deletions(-) create mode 100644 src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetStandard.cs 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 f457ce8153..d1ddbf37af 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -143,6 +143,7 @@ + diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index 1bba2aef4b..c02a96e236 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -13,6 +13,24 @@ internal partial class SqlAuthenticationProviderManager { private readonly SqlAuthenticationInitializer _initializer; + static SqlAuthenticationProviderManager() + { + var activeDirectoryAuthNativeProvider = new ActiveDirectoryNativeAuthenticationProvider(); + SqlAuthenticationProviderConfigurationSection configurationSection; + + try + { + configurationSection = (SqlAuthenticationProviderConfigurationSection)ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); + } + catch (ConfigurationErrorsException e) + { + throw SQL.CannotGetAuthProviderConfig(e); + } + + Instance = new SqlAuthenticationProviderManager(configurationSection); + Instance.SetProvider(SqlAuthenticationMethod.ActiveDirectoryPassword, activeDirectoryAuthNativeProvider); + } + /// /// Constructor. /// diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetStandard.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetStandard.cs new file mode 100644 index 0000000000..ef6328af0d --- /dev/null +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetStandard.cs @@ -0,0 +1,16 @@ +// 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. + +namespace Microsoft.Data.SqlClient +{ + internal partial class SqlAuthenticationProviderManager + { + static SqlAuthenticationProviderManager() + { + var activeDirectoryAuthNativeProvider = new ActiveDirectoryNativeAuthenticationProvider(); + Instance = new SqlAuthenticationProviderManager(); + Instance.SetProvider(SqlAuthenticationMethod.ActiveDirectoryPassword, activeDirectoryAuthNativeProvider); + } + } +} diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs index bc46d77972..b9a002a240 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs @@ -10,7 +10,6 @@ namespace Microsoft.Data.SqlClient { - /// /// Authentication provider manager. /// @@ -27,28 +26,6 @@ internal partial class SqlAuthenticationProviderManager public static readonly SqlAuthenticationProviderManager Instance; - static SqlAuthenticationProviderManager() - { - var activeDirectoryAuthNativeProvider = new ActiveDirectoryNativeAuthenticationProvider(); -#if netcoreapp - SqlAuthenticationProviderConfigurationSection configurationSection; - - try - { - configurationSection = (SqlAuthenticationProviderConfigurationSection)ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); - } - catch (ConfigurationErrorsException e) - { - throw SQL.CannotGetAuthProviderConfig(e); - } - - Instance = new SqlAuthenticationProviderManager(configurationSection); -#else - Instance = new SqlAuthenticationProviderManager(); -#endif - Instance.SetProvider(SqlAuthenticationMethod.ActiveDirectoryPassword, activeDirectoryAuthNativeProvider); - } - /// /// Constructor. /// diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs index 461810a3dd..344702dae2 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -1348,7 +1348,7 @@ public override Task OpenAsync(CancellationToken cancellationToken) catch (Exception ex) { s_diagnosticListener.WriteConnectionOpenError(operationId, this, ex); - throw ex; + throw; } finally { From 3ee4e094eb8157be7b0eabaf2a4b34dcc14c018b Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 24 Apr 2020 14:45:00 -0700 Subject: [PATCH 9/9] Remove unnecessary parameter (NetFx) --- .../Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs | 9 +++------ .../netfx/src/Microsoft/Data/SqlClient/TdsParser.cs | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs index eb42d38f1a..5a778a1b43 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs @@ -363,9 +363,7 @@ internal SqlInternalConnectionTds( DbConnectionPool pool = null, string accessToken = null, SqlClientOriginalNetworkAddressInfo originalNetworkAddressInfo = null, - bool applyTransientFaultHandling = false, - SqlAuthenticationProviderManager sqlAuthProviderManager = null - ) : base(connectionOptions) + bool applyTransientFaultHandling = false) : base(connectionOptions) { #if DEBUG @@ -421,7 +419,7 @@ internal SqlInternalConnectionTds( } _activeDirectoryAuthTimeoutRetryHelper = new ActiveDirectoryAuthenticationTimeoutRetryHelper(); - _sqlAuthenticationProviderManager = sqlAuthProviderManager ?? SqlAuthenticationProviderManager.Instance; + _sqlAuthenticationProviderManager = SqlAuthenticationProviderManager.Instance; _serverCallback = serverCallback; _clientCallback = clientCallback; @@ -2203,8 +2201,7 @@ private void AttemptOneLogin(ServerInfo serverInfo, string newPassword, SecureSt _serverCallback, _clientCallback, _originalNetworkAddressInfo != null, - disableTnir, - _sqlAuthenticationProviderManager); + disableTnir); timeoutErrorInternal.EndPhase(SqlConnectionTimeoutErrorPhase.ConsumePreLoginHandshake); timeoutErrorInternal.SetAndBeginPhase(SqlConnectionTimeoutErrorPhase.LoginBegin); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs index 3ebf40d816..f23859b523 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -483,8 +483,7 @@ internal void Connect(ServerInfo serverInfo, ServerCertificateValidationCallback serverCallback, ClientCertificateRetrievalCallback clientCallback, bool useOriginalAddressInfo, - bool disableTnir, - SqlAuthenticationProviderManager sqlAuthProviderManager) + bool disableTnir) { if (_state != TdsParserState.Closed) {