diff --git a/CHANGELOG.md b/CHANGELOG.md index 255dde891c..ed4008a425 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,35 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +## [Preview Release 2.0.0-preview1.20084.1] - 2020-03-24 + +### Added +- Added support for capturing EventSource traces in .NET Framework, .NET Core, and .NET Standard applications [#399](https://github.com/dotnet/SqlClient/pull/399) [#461](https://github.com/dotnet/SqlClient/pull/461) [#479](https://github.com/dotnet/SqlClient/pull/479) [#483](https://github.com/dotnet/SqlClient/pull/483) [#484](https://github.com/dotnet/SqlClient/pull/484) +- Added support for Cross-platform TCP Keep Alive applicable to .NET Core 3.1+ applications [#395](https://github.com/dotnet/SqlClient/pull/395) +- Added support for enabling Managed networking implementation on Windows applicable to .NET Core and .NET Standard applications [#477](https://github.com/dotnet/SqlClient/pull/477) +- Added `RowsCopied` property in `SqlBulkCopy` to expose count of copied rows [#409](https://github.com/dotnet/SqlClient/pull/409) +- Added "NeutralResourcesLanguage" attribute for .NET Framework assembly [#433](https://github.com/dotnet/SqlClient/pull/433) +- Added caching for invariant culture check result [#376](https://github.com/dotnet/SqlClient/pull/376) +- Added cached `SqlReferenceCollection.FindLiveReaderContext` objects [#380](https://github.com/dotnet/SqlClient/pull/380) + +### Fixed +- Fixed Access Token behavior in connection pool to perform string comparison [#443](https://github.com/dotnet/SqlClient/pull/443) +- Fixed concurrent connection speed issues when connecting with Azure Active Directory Authentication modes in .NET Core [#466](https://github.com/dotnet/SqlClient/pull/466) +- Fixed issues with `Password` persistence in Connection String [#453](https://github.com/dotnet/SqlClient/pull/453) + +### Changes +- Updated all driver assemblies to be CLS Compliant [#396](https://github.com/dotnet/SqlClient/pull/396) +- Updated Bulk Copy error messages to also include Column, Row and non-encrypted Data information [#437](https://github.com/dotnet/SqlClient/pull/437) +- Updated error messages for "Always Encrypted - Secure Enclaves" to handle 'Attestation Protocol' and fixed typos [#421](https://github.com/dotnet/SqlClient/pull/421) [#397](https://github.com/dotnet/SqlClient/pull/397) +- Removed sync over async in `SNINpHandle.EnableSsl` [#474](https://github.com/dotnet/SqlClient/pull/474) +- Changed non-generic `ArrayList` to `List` in `SqlBulkCopy` [#457](https://github.com/dotnet/SqlClient/pull/457) +- Multiple performance improvements [#377](https://github.com/dotnet/SqlClient/pull/377) [#378](https://github.com/dotnet/SqlClient/pull/378) [#379](https://github.com/dotnet/SqlClient/pull/379) + +### Breaking Changes +- The driver will now perform Server Certificate validation when TLS encryption is enforced by the target Server, which is the default for Azure connections [#391](https://github.com/dotnet/SqlClient/pull/391) +- `SqlDataReader.GetSchemaTable()` now returns an empty `DataTable` instead of returning `null` [#419](https://github.com/dotnet/SqlClient/pull/419) + + ## [Stable Release 1.1.1] - 2020-02-14 ### Fixed diff --git a/release-notes/2.0/2.0.0-preview2.md b/release-notes/2.0/2.0.0-preview2.md new file mode 100644 index 0000000000..ca433c70e7 --- /dev/null +++ b/release-notes/2.0/2.0.0-preview2.md @@ -0,0 +1,123 @@ +# Release Notes + +## Microsoft.Data.SqlClient 2.0.0-preview2.20084.1 released 24 March 2020 + +This update brings the below changes over the previous release: + +### Added +- Added support for capturing EventSource traces in .NET Framework, .NET Core, and .NET Standard applications [#399](https://github.com/dotnet/SqlClient/pull/399) [#461](https://github.com/dotnet/SqlClient/pull/461) [#479](https://github.com/dotnet/SqlClient/pull/479) [#483](https://github.com/dotnet/SqlClient/pull/483) [#484](https://github.com/dotnet/SqlClient/pull/484) +- Added support for Cross-platform TCP Keep Alive applicable to .NET Core 3.1+ applications [#395](https://github.com/dotnet/SqlClient/pull/395) +- Added support for enabling Managed networking implementation on Windows applicable to .NET Core and .NET Standard applications [#477](https://github.com/dotnet/SqlClient/pull/477) +- Added `RowsCopied` property in `SqlBulkCopy` to expose count of copied rows [#409](https://github.com/dotnet/SqlClient/pull/409) +- Added "NeutralResourcesLanguage" attribute for .NET Framework assembly [#433](https://github.com/dotnet/SqlClient/pull/433) +- Added caching for invariant culture check result [#376](https://github.com/dotnet/SqlClient/pull/376) +- Added cached `SqlReferenceCollection.FindLiveReaderContext` objects [#380](https://github.com/dotnet/SqlClient/pull/380) + +### Fixed +- Fixed Access Token behavior in connection pool to perform string comparison [#443](https://github.com/dotnet/SqlClient/pull/443) +- Fixed concurrent connection speed issues when connecting with Azure Active Directory Authentication modes in .NET Core [#466](https://github.com/dotnet/SqlClient/pull/466) +- Fixed issues with `Password` persistence in Connection String [#453](https://github.com/dotnet/SqlClient/pull/453) + +### Changes +- Updated all driver assemblies to be CLS Compliant [#396](https://github.com/dotnet/SqlClient/pull/396) +- Updated Bulk Copy error messages to also include Column, Row and non-encrypted Data information [#437](https://github.com/dotnet/SqlClient/pull/437) +- Updated error messages for "Always Encrypted - Secure Enclaves" to handle 'Attestation Protocol' and fixed typos [#421](https://github.com/dotnet/SqlClient/pull/421) [#397](https://github.com/dotnet/SqlClient/pull/397) +- Removed sync over async in `SNINpHandle.EnableSsl` [#474](https://github.com/dotnet/SqlClient/pull/474) +- Changed non-generic `ArrayList` to `List` in `SqlBulkCopy` [#457](https://github.com/dotnet/SqlClient/pull/457) +- Multiple performance improvements [#377](https://github.com/dotnet/SqlClient/pull/377) [#378](https://github.com/dotnet/SqlClient/pull/378) [#379](https://github.com/dotnet/SqlClient/pull/379) + +### Breaking Changes +- The driver will now perform Server Certificate validation when TLS encryption is enforced by the target Server, which is the default for Azure connections [#391](https://github.com/dotnet/SqlClient/pull/391) +- `SqlDataReader.GetSchemaTable()` now returns empty `DataTable` instead of returning `null` [#419](https://github.com/dotnet/SqlClient/pull/419) + + +### Introducing EventSource tracing support +This release introduces support for capturing EventSource trace logs for debugging applications. In order to capture these traces, client applications must listen to events from SqlClient's EventSource implementation: + +"Microsoft.Data.SqlClient.EventSource" + +Supported Event Keywords are: + +| Keyword Name | Value | Description | +| ------------ | ----- | ----------- | +| ExecutionTrace | 1 | Turns on capturing Start/Stop events before and after command execution. | +| Trace | 2 | Turns on capturing basic application flow trace events. | +| Scope | 4 | Turns on capturing enter and exit events | +| NotificationTrace | 8 | Turns on capturing `SqlNotification` trace events | +| NotificationScope | 16 | Turns on capturing `SqlNotification` scope enter and exit events | +| PoolerTrace | 32 | Turns on capturing connection pooling flow trace events. | +| PoolerScope | 64 | Turns on capturing connection pooling scope trace events. | +| AdvancedTrace | 128 | Turns on capturing advanced flow trace events. | +| AdvancedTraceBin | 256 | Turns on capturing advanced flow trace events with additional information. | +| CorrelationTrace | 512 | Turns on capturing correlation flow trace events. | +| StateDump | 1024 | Turns on capturing full state dump of `SqlConnection` | +| SNITrace | 2048 | Turns on capturing flow trace events from Managed Networking implementation (only applicable in .NET Core) | +| SNIScope | 4096 | Turns on capturing scope events from Managed Networking implementation (only applicable in .NET Core) | +||| + +### Enabling Managed networking on Windows +This release introduces a new AppContext switch "Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows" that enables the use of Managed SNI on Windows for testing and debugging purposes. This switch will toggle the driver's behavior to use Managed SNI in .NET Core 2.1+ and .NET Standard 2.0+ projects on Windows. + +To set the switch from app startup, specify: + +```cs +AppContext.SetSwitch("Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows", true); +``` + +> [NOTE] **Known differences when compared to Native SNI.dll**: Managed SNI does not support non-domain Windows Authentication. + + +## Target Platform Support + +- .NET Framework 4.6+ +- .NET Core 2.1+ (Windows x86, Windows x64, Linux, macOS) +- .NET Standard 2.0+ (Windows x86, Windows x64, Linux, macOS) + +### Dependencies + +#### .NET Framework + +- Microsoft.Data.SqlClient.SNI 1.1.0+ +- Microsoft.Identity.Client 3.0.8 +- Microsoft.IdentityModel.Protocols.OpenIdConnect 5.6.0 +- Microsoft.IdentityModel.JsonWebTokens 5.6.0 + +#### .NET Core 2.1 + +- runtime.native.System.Data.SqlClient.sni 4.4.0 +- Microsoft.Win32.Registry 4.7.0 +- System.Security.Principal.Windows 4.7.0 +- System.Text.Encoding.CodePages 4.7.0 +- System.Diagnostics.DiagnosticSource 4.7.0 +- System.Configuration.ConfigurationManager 4.7.0 +- System.Runtime.Caching 4.7.0 +- Microsoft.Identity.Client 4.7.1 +- Microsoft.IdentityModel.Protocols.OpenIdConnect 5.6.0 +- Microsoft.IdentityModel.JsonWebTokens 5.6.0 + +#### .NET Core 3.1 + +- runtime.native.System.Data.SqlClient.sni 4.4.0 +- Microsoft.Win32.Registry 4.7.0 +- System.Security.Principal.Windows 4.7.0 +- System.Text.Encoding.CodePages 4.7.0 +- System.Diagnostics.DiagnosticSource 4.7.0 +- System.Configuration.ConfigurationManager 4.7.0 +- System.Runtime.Caching 4.7.0 +- Microsoft.Identity.Client 4.7.1 +- Microsoft.IdentityModel.Protocols.OpenIdConnect 5.6.0 +- Microsoft.IdentityModel.JsonWebTokens 5.6.0 + +#### .NET Standard + +- runtime.native.System.Data.SqlClient.sni 4.4.0 +- Microsoft.Win32.Registry 4.7.0 +- System.Buffers 4.5.0 +- System.Diagnostics.DiagnosticSource 4.7.0 +- System.Memory 4.5.3 +- System.Security.Principal.Windows 4.7.0 +- System.Text.Encoding.CodePages 4.7.0 +- System.Configuration.ConfigurationManager 4.7.0 +- Microsoft.Identity.Client 4.7.1 +- Microsoft.IdentityModel.Protocols.OpenIdConnect 5.6.0 +- Microsoft.IdentityModel.JsonWebTokens 5.6.0 diff --git a/release-notes/2.0/2.0.md b/release-notes/2.0/2.0.md index 3241ccb0fe..7b48fdeedf 100644 --- a/release-notes/2.0/2.0.md +++ b/release-notes/2.0/2.0.md @@ -5,3 +5,4 @@ The following Microsoft.Data.SqlClient 2.0 preview releases have been shipped: | Release Date | Version | Notes | | :-- | :-- | :--: | | 2020/01/21 | 2.0.0-preview1.20021.1 | [release notes](2.0.0-preview1.md) | +| 2020/03/24 | 2.0.0-preview2.20084.1 | [release notes](2.0.0-preview2.md) | diff --git a/release-notes/2.0/README.md b/release-notes/2.0/README.md index 3241ccb0fe..70dc4a465f 100644 --- a/release-notes/2.0/README.md +++ b/release-notes/2.0/README.md @@ -5,3 +5,4 @@ The following Microsoft.Data.SqlClient 2.0 preview releases have been shipped: | Release Date | Version | Notes | | :-- | :-- | :--: | | 2020/01/21 | 2.0.0-preview1.20021.1 | [release notes](2.0.0-preview1.md) | +| 2020/03/24 | 2.0.0-preview1.20084.1 | [release notes](2.0.0-preview2.md) | diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/Common/DbConnectionOptions.Common.cs b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/Common/DbConnectionOptions.Common.cs index 3714f41ccf..7dea455d0f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/Common/DbConnectionOptions.Common.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/Common/DbConnectionOptions.Common.cs @@ -161,7 +161,7 @@ internal static bool ConvertValueToBooleanInternal(string keyName, string string [System.Diagnostics.Conditional("DEBUG")] private static void DebugTraceKeyValuePair(string keyname, string keyvalue, Dictionary synonyms) { - if (SqlClientEventSource.Log.IsAdvanceTraceOn()) + if (SqlClientEventSource.Log.IsAdvancedTraceOn()) { Debug.Assert(string.Equals(keyname, keyname?.ToLower(), StringComparison.InvariantCulture), "missing ToLower"); string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname); @@ -171,11 +171,11 @@ private static void DebugTraceKeyValuePair(string keyname, string keyvalue, Dict // don't trace passwords ever! if (null != keyvalue) { - SqlClientEventSource.Log.AdvanceTrace(" KeyName='{0}', KeyValue='{1}'", keyname, keyvalue); + SqlClientEventSource.Log.AdvancedTraceEvent(" KeyName='{0}', KeyValue='{1}'", keyname, keyvalue); } else { - SqlClientEventSource.Log.AdvanceTrace(" KeyName='{0}'", keyname); + SqlClientEventSource.Log.AdvancedTraceEvent(" KeyName='{0}'", keyname); } } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs index bb5215baf1..cfbdd659eb 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs @@ -49,7 +49,7 @@ protected DbConnectionFactory() public void ClearAllPools() { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent("", "API"); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" connectionPoolGroups = _connectionPoolGroups; @@ -71,7 +71,7 @@ public void ClearAllPools() public void ClearPool(DbConnection connection) { ADP.CheckArgumentNull(connection, nameof(connection)); - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", GetObjectId(connection)); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", GetObjectId(connection)); try { DbConnectionPoolGroup poolGroup = GetConnectionPoolGroup(connection); @@ -126,7 +126,7 @@ internal DbConnectionInternal CreateNonPooledConnection(DbConnection owningConne { newConnection.MakeNonPooledObject(owningConnection); } - SqlClientEventSource.Log.TraceEvent(" {0}#, Non-pooled database connection created.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Non-pooled database connection created.", ObjectID); return newConnection; } @@ -140,7 +140,7 @@ internal DbConnectionInternal CreatePooledConnection(DbConnectionPool pool, DbCo { newConnection.MakePooledConnection(pool); } - SqlClientEventSource.Log.TraceEvent(" {0}#, Pooled database connection created.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Pooled database connection created.", ObjectID); return newConnection; } @@ -195,7 +195,7 @@ private DbConnectionPool GetConnectionPool(DbConnection owningObject, DbConnecti // however, don't rebuild connectionOptions if no pooling is involved - let new connections do that work if (connectionPoolGroup.IsDisabled && (null != connectionPoolGroup.PoolGroupOptions)) { - SqlClientEventSource.Log.TraceEvent(" {0}#, DisabledPoolGroup={1}#", ObjectID, connectionPoolGroup.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, DisabledPoolGroup={1}", ObjectID, connectionPoolGroup.ObjectID); // reusing existing pool option in case user originally used SetConnectionPoolOptions DbConnectionPoolGroupOptions poolOptions = connectionPoolGroup.PoolGroupOptions; @@ -303,7 +303,7 @@ internal DbConnectionPoolGroup GetConnectionPoolGroup(DbConnectionPoolKey key, D private void PruneConnectionPoolGroups(object state) { // when debugging this method, expect multiple threads at the same time - SqlClientEventSource.Log.AdvanceTrace(" {0}#", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}", ObjectID); // First, walk the pool release list and attempt to clear each // pool, when the pool is finally empty, we dispose of it. If the @@ -323,7 +323,7 @@ private void PruneConnectionPoolGroups(object state) if (0 == pool.Count) { _poolsToRelease.Remove(pool); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, ReleasePool={1}#", ObjectID, pool.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, ReleasePool={1}", ObjectID, pool.ObjectID); } } } @@ -347,7 +347,7 @@ private void PruneConnectionPoolGroups(object state) if (0 == poolsLeft) { _poolGroupsToRelease.Remove(poolGroup); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, ReleasePoolGroup={1}#", ObjectID, poolGroup.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, ReleasePoolGroup={1}", ObjectID, poolGroup.ObjectID); } } } @@ -410,7 +410,7 @@ internal void QueuePoolForRelease(DbConnectionPool pool, bool clearing) internal void QueuePoolGroupForRelease(DbConnectionPoolGroup poolGroup) { Debug.Assert(null != poolGroup, "null poolGroup?"); - SqlClientEventSource.Log.TraceEvent(" {0}#, poolGroup={1}#", ObjectID, poolGroup.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, poolGroup={1}", ObjectID, poolGroup.ObjectID); lock (_poolGroupsToRelease) { diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs index 8c73c45500..a1ba58d5d2 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs @@ -225,7 +225,7 @@ internal void DeactivateConnection() { // Internal method called from the connection pooler so we don't expose // the Deactivate method publicly. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Deactivating", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Deactivating", ObjectID); #if DEBUG int activateCount = Interlocked.Decrement(ref _activateCount); @@ -249,14 +249,14 @@ internal void DeactivateConnection() protected internal void DoNotPoolThisConnection() { _cannotBePooled = true; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Marking pooled object as non-poolable so it will be disposed", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Marking pooled object as non-poolable so it will be disposed", ObjectID); } /// Ensure that this connection cannot be put back into the pool. protected internal void DoomThisConnection() { _connectionIsDoomed = true; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Dooming", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Dooming", ObjectID); } protected internal virtual DataTable GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, string collectionName, string[] restrictions) @@ -377,7 +377,7 @@ internal void PrePush(object expectedOwner) throw ADP.InternalError(ADP.InternalErrorCode.PushingObjectSecondTime); // pushing object onto stack a second time } - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Preparing to push into pool, owning connection {1}#, pooledCount={2}", ObjectID, 0, _pooledCount); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Preparing to push into pool, owning connection {1}, pooledCount={2}", ObjectID, 0, _pooledCount); _pooledCount++; _owningObject.Target = null; // NOTE: doing this and checking for InternalError.PooledObjectHasOwner degrades the close by 2% } @@ -406,7 +406,7 @@ internal void PostPop(object newOwner) } _owningObject.Target = newOwner; _pooledCount--; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Preparing to pop from pool, owning connection {1}#, pooledCount={2}", ObjectID, 0, _pooledCount); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Preparing to pop from pool, owning connection {1}, pooledCount={2}", ObjectID, 0, _pooledCount); //3 // The following tests are retail assertions of things we can't allow to happen. if (null != Pool) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs index 9866d571ad..4c8e9adec6 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Common/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs @@ -229,7 +229,7 @@ private bool MarkPoolGroupAsActive() if (PoolGroupStateIdle == _state) { _state = PoolGroupStateActive; - SqlClientEventSource.Log.TraceEvent(" {0}#, Active", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Active", ObjectID); } return (PoolGroupStateActive == _state); } @@ -281,12 +281,12 @@ internal bool Prune() if (PoolGroupStateActive == _state) { _state = PoolGroupStateIdle; - SqlClientEventSource.Log.TraceEvent(" {0}#, Idle", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Idle", ObjectID); } else if (PoolGroupStateIdle == _state) { _state = PoolGroupStateDisabled; - SqlClientEventSource.Log.TraceEvent(" {0}#, Disabled", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Disabled", ObjectID); } } return (PoolGroupStateDisabled == _state); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/ActivityCorrelator.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/ActivityCorrelator.cs index d4f1c1ac6f..ef6b9b6cd2 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/ActivityCorrelator.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/ActivityCorrelator.cs @@ -14,30 +14,15 @@ namespace Microsoft.Data.Common internal static class ActivityCorrelator { - internal class ActivityId + internal sealed class ActivityId { - internal Guid Id { get; private set; } - internal uint Sequence { get; private set; } + internal readonly Guid Id; + internal readonly uint Sequence; - internal ActivityId() + internal ActivityId(uint sequence) { this.Id = Guid.NewGuid(); - this.Sequence = 0; // the first event will start 1 - } - - // copy-constructor - internal ActivityId(ActivityId activity) - { - this.Id = activity.Id; - this.Sequence = activity.Sequence; - } - - internal void Increment() - { - unchecked - { - ++this.Sequence; - } + this.Sequence = sequence; } public override string ToString() @@ -61,10 +46,9 @@ internal static ActivityId Current { if (t_tlsActivity == null) { - t_tlsActivity = new ActivityId(); + t_tlsActivity = new ActivityId(1); } - - return new ActivityId(t_tlsActivity); + return t_tlsActivity; } } @@ -74,14 +58,9 @@ internal static ActivityId Current /// ActivityId internal static ActivityId Next() { - if (t_tlsActivity == null) - { - t_tlsActivity = new ActivityId(); - } - - t_tlsActivity.Increment(); + t_tlsActivity = new ActivityId( (t_tlsActivity?.Sequence ?? 0) + 1); - return new ActivityId(t_tlsActivity); + return t_tlsActivity; } } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/DataException.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/DataException.cs index 66a8533e4b..905e3b8de5 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/DataException.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/DataException.cs @@ -31,8 +31,8 @@ internal static class ExceptionBuilder Debug.Assert(null != e, "TraceException: null Exception"); if (null != e) { - SqlClientEventSource.Log.AdvanceTrace(trace, e.Message); - SqlClientEventSource.Log.AdvanceTrace(" Environment StackTrace = '{0}'", Environment.StackTrace); + SqlClientEventSource.Log.AdvancedTraceEvent(trace, e.Message); + SqlClientEventSource.Log.AdvancedTraceEvent(" Environment StackTrace = '{0}'", Environment.StackTrace); } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs index 2fb7649b13..e42f08d963 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs @@ -163,7 +163,7 @@ internal bool TryGetConnection(DbConnection owningConnection, TaskCompletionSour // connection creation failed on semaphore waiting or if max pool reached if (connectionPool.IsRunning) { - SqlClientEventSource.Log.TraceEvent(" {0}#, GetConnection failed because a pool timeout occurred.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, GetConnection failed because a pool timeout occurred.", ObjectID); // If GetConnection failed while the pool is running, the pool timeout occurred. throw ADP.PooledOpenTimeout(); } @@ -181,7 +181,7 @@ internal bool TryGetConnection(DbConnection owningConnection, TaskCompletionSour if (connection == null) { - SqlClientEventSource.Log.TraceEvent(" {0}#, GetConnection failed because a pool timeout occurred and all retries were exhausted.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, GetConnection failed because a pool timeout occurred and all retries were exhausted.", ObjectID); // exhausted all retries or timed out - give up throw ADP.PooledOpenTimeout(); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs index 9cfbee338d..c500da0c23 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs @@ -105,7 +105,7 @@ protected internal Transaction EnlistedTransaction if (null != value) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Enlisting.", ObjectID, value.GetHashCode()); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Enlisting.", ObjectID, value.GetHashCode()); TransactionOutcomeEnlist(value); } } @@ -209,7 +209,7 @@ internal void ActivateConnection(Transaction transaction) { // Internal method called from the connection pooler so we don't expose // the Activate method publicly. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Activating", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Activating", ObjectID); #if DEBUG int activateCount = Interlocked.Increment(ref _activateCount); @@ -259,7 +259,7 @@ internal virtual void CloseConnection(DbConnection owningObject, DbConnectionFac //////////////////////////////////////////////////////////////// Debug.Assert(null != owningObject, "null owningObject"); Debug.Assert(null != connectionFactory, "null connectionFactory"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}# Closing.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0} Closing.", ObjectID); // if an exception occurs after the state change but before the try block // the connection will be stuck in OpenBusy state. The commented out try-catch @@ -334,7 +334,7 @@ virtual internal void DelegatedTransactionEnded() // IMPORTANT NOTE: You must have taken a lock on the object before // you call this method to prevent race conditions with Clear and // ReclaimEmancipatedObjects. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Delegated Transaction Completed.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Delegated Transaction Completed.", ObjectID); if (1 == _pooledCount) { @@ -426,7 +426,7 @@ internal void DetachCurrentTransactionIfEnded() // Detach transaction from connection. internal void DetachTransaction(Transaction transaction, bool isExplicitlyReleasing) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction Completed. (pooledCount={1})", ObjectID, _pooledCount); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction Completed. (pooledCount={1})", ObjectID, _pooledCount); // potentially a multi-threaded event, so lock the connection to make sure we don't enlist in a new // transaction between compare and assignment. No need to short circuit outside of lock, since failed comparisons should @@ -466,7 +466,7 @@ internal void CleanupConnectionOnTransactionCompletion(Transaction transaction) void TransactionCompletedEvent(object sender, TransactionEventArgs e) { Transaction transaction = e.Transaction; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction Completed. (pooledCount = {1})", ObjectID, _pooledCount); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction Completed. (pooledCount = {1})", ObjectID, _pooledCount); CleanupTransactionOnCompletion(transaction); CleanupConnectionOnTransactionCompletion(transaction); } @@ -479,18 +479,18 @@ private void TransactionOutcomeEnlist(Transaction transaction) internal void SetInStasis() { _isInStasis = true; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Non-Pooled Connection has Delegated Transaction, waiting to Dispose.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Non-Pooled Connection has Delegated Transaction, waiting to Dispose.", ObjectID); } private void TerminateStasis(bool returningToPool) { if (returningToPool) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Delegated Transaction has ended, connection is closed. Returning to general pool.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Delegated Transaction has ended, connection is closed. Returning to general pool.", ObjectID); } else { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Delegated Transaction has ended, connection is closed/leaked. Disposing.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Delegated Transaction has ended, connection is closed/leaked. Disposing.", ObjectID); } _isInStasis = false; } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs index 67492f5694..43cee90a07 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs @@ -74,7 +74,7 @@ internal TransactedConnectionPool(DbConnectionPool pool) _pool = pool; _transactedCxns = new Dictionary(); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Constructed for connection pool {1}#", ObjectID, _pool.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Constructed for connection pool {1}", ObjectID, _pool.ObjectID); } internal int ObjectID @@ -133,7 +133,7 @@ internal DbConnectionInternal GetTransactedObject(Transaction transaction) if (null != transactedObject) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Popped.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Popped.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); } return transactedObject; } @@ -160,7 +160,7 @@ internal void PutTransactedObject(Transaction transaction, DbConnectionInternal lock (connections) { Debug.Assert(0 > connections.IndexOf(transactedObject), "adding to pool a second time?"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); connections.Add(transactedObject); } } @@ -195,13 +195,13 @@ internal void PutTransactedObject(Transaction transaction, DbConnectionInternal lock (connections) { Debug.Assert(0 > connections.IndexOf(transactedObject), "adding to pool a second time?"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); connections.Add(transactedObject); } } else { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Adding List to transacted pool.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Adding List to transacted pool.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); // add the connection/transacted object to the list newConnections.Add(transactedObject); @@ -229,13 +229,13 @@ internal void PutTransactedObject(Transaction transaction, DbConnectionInternal } } } - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Added.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Added.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); } } internal void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); TransactedConnectionList connections; int entry = -1; @@ -269,7 +269,7 @@ internal void TransactionEnded(Transaction transaction, DbConnectionInternal tra // safely remove the list from the transacted pool. if (0 >= connections.Count) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Removing List from transacted pool.", ObjectID, transaction.GetHashCode()); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Removing List from transacted pool.", ObjectID, transaction.GetHashCode()); _transactedCxns.Remove(transaction); // we really need to dispose our connection list; it may have @@ -285,7 +285,7 @@ internal void TransactionEnded(Transaction transaction, DbConnectionInternal tra } else { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Transacted pool not yet created prior to transaction completing. Connection may be leaked.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Transacted pool not yet created prior to transaction completing. Connection may be leaked.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); } } @@ -443,7 +443,7 @@ internal WaitHandle[] GetHandles(bool withCreate) _poolCreateRequest = new WaitCallback(PoolCreateRequest); // used by CleanupCallback _state = State.Running; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Constructed.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Constructed.", ObjectID); //_cleanupTimer & QueuePoolCreateRequest is delayed until DbConnectionPoolGroup calls // StartBackgroundCallbacks after pool is actually in the collection @@ -586,7 +586,7 @@ private void CleanupCallback(object state) // // With this logic, objects are pruned from the pool if unused for // at least one period but not more than two periods. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}", ObjectID); // Destroy free objects that put us above MinPoolSize from old stack. while (Count > MinPoolSize) @@ -658,7 +658,7 @@ private void CleanupCallback(object state) break; Debug.Assert(obj != null, "null connection is not expected"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, ChangeStacks={1}#", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, ChangeStacks={1}", ObjectID, obj.ObjectID); Debug.Assert(!obj.IsEmancipated, "pooled object not in pool"); Debug.Assert(obj.CanBePooled, "pooled object is not poolable"); @@ -673,7 +673,7 @@ private void CleanupCallback(object state) internal void Clear() { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Clearing.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Clearing.", ObjectID); DbConnectionInternal obj; // First, quickly doom everything. @@ -707,7 +707,7 @@ internal void Clear() // Finally, reclaim everything that's emancipated (which, because // it's been doomed, will cause it to be disposed of as well) ReclaimEmancipatedObjects(); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Cleared.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Cleared.", ObjectID); } private Timer CreateCleanupTimer() => @@ -758,7 +758,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio } } } - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Added to pool.", ObjectID, newObj != null ? newObj?.ObjectID.ToString() ?? "null" : "null"); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Added to pool.", ObjectID, newObj != null ? newObj?.ObjectID.ToString() ?? "null" : "null"); // Reset the error wait: _errorWait = ERROR_WAIT_DEFAULT; @@ -816,7 +816,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio private void DeactivateObject(DbConnectionInternal obj) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Deactivating.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Deactivating.", ObjectID, obj.ObjectID); obj.DeactivateConnection(); bool returnToGeneralPool = false; @@ -951,11 +951,11 @@ internal void DestroyObject(DbConnectionInternal obj) // again. if (obj.IsTxRootWaitingForTxEnd) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Has Delegated Transaction, waiting to Dispose.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Has Delegated Transaction, waiting to Dispose.", ObjectID, obj.ObjectID); } else { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Removing from pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Removing from pool.", ObjectID, obj.ObjectID); bool removed = false; lock (_objectList) { @@ -966,16 +966,16 @@ internal void DestroyObject(DbConnectionInternal obj) if (removed) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Removed from pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Removed from pool.", ObjectID, obj.ObjectID); } obj.Dispose(); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Disposed.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Disposed.", ObjectID, obj.ObjectID); } } private void ErrorCallback(object state) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Resetting Error handling.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Resetting Error handling.", ObjectID); _errorOccurred = false; _waitHandles.ErrorEvent.Reset(); @@ -1106,7 +1106,7 @@ internal bool TryGetConnection(DbConnection owningObject, TaskCompletionSource {0}#, DbConnectionInternal State != Running.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, DbConnectionInternal State != Running.", ObjectID); connection = null; return true; } @@ -1146,7 +1146,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj { DbConnectionInternal obj = null; Transaction transaction = null; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Getting connection.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Getting connection.", ObjectID); // If automatic transaction enlistment is required, then we try to // get the connection from the transacted connection pool first. @@ -1181,19 +1181,19 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj switch (waitResult) { case WaitHandle.WaitTimeout: - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Wait timed out.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Wait timed out.", ObjectID); Interlocked.Decrement(ref _waitCount); connection = null; return false; case ERROR_HANDLE: // Throw the error that PoolCreateRequest stashed. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Errors are set.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Errors are set.", ObjectID); Interlocked.Decrement(ref _waitCount); throw TryCloneCachedException(); case CREATION_HANDLE: - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Creating new connection.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Creating new connection.", ObjectID); try { obj = UserCreateRequest(owningObject, userOptions); @@ -1243,7 +1243,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj if ((obj != null) && (!obj.IsConnectionAlive())) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, found dead and removed.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectID, obj.ObjectID); DestroyObject(obj); obj = null; // Setting to null in case creating a new object fails @@ -1253,7 +1253,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj { try { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Creating new connection.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Creating new connection.", ObjectID); obj = UserCreateRequest(owningObject, userOptions); } finally @@ -1264,7 +1264,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj else { // Timeout waiting for creation semaphore - return null - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Wait timed out.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Wait timed out.", ObjectID); connection = null; return false; } @@ -1273,7 +1273,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj break; default: - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, WaitForMultipleObjects={1}", ObjectID, waitResult); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, WaitForMultipleObjects={1}", ObjectID, waitResult); Interlocked.Decrement(ref _waitCount); throw ADP.InternalError(ADP.InternalErrorCode.UnexpectedWaitAnyResult); } @@ -1325,7 +1325,7 @@ private void PrepareConnection(DbConnection owningObject, DbConnectionInternal o /// A new inner connection that is attached to the internal DbConnectionInternal ReplaceConnection(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, replacing connection.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, replacing connection.", ObjectID); DbConnectionInternal newConnection = UserCreateRequest(owningObject, userOptions, oldConnection); if (newConnection != null) @@ -1366,7 +1366,7 @@ private DbConnectionInternal GetFromGeneralPool() if (null != obj) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Popped from general pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Popped from general pool.", ObjectID, obj.ObjectID); } return (obj); } @@ -1382,7 +1382,7 @@ private DbConnectionInternal GetFromTransactedPool(out Transaction transaction) if (null != obj) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Popped from transacted pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Popped from transacted pool.", ObjectID, obj.ObjectID); if (obj.IsTransactionRoot) { @@ -1392,14 +1392,14 @@ private DbConnectionInternal GetFromTransactedPool(out Transaction transaction) } catch { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, found dead and removed.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectID, obj.ObjectID); DestroyObject(obj); throw; } } else if (!obj.IsConnectionAlive()) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, found dead and removed.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectID, obj.ObjectID); DestroyObject(obj); obj = null; } @@ -1412,7 +1412,7 @@ private void PoolCreateRequest(object state) { // called by pooler to ensure pool requests are currently being satisfied - // creation mutex has not been obtained - long scopeID = SqlClientEventSource.Log.PoolerScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.PoolerScopeEnterEvent(" {0}", ObjectID); try { if (State.Running == _state) @@ -1496,7 +1496,7 @@ private void PoolCreateRequest(object state) } else { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, PoolCreateRequest called WaitForSingleObject failed {1}", ObjectID, waitResult); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, PoolCreateRequest called WaitForSingleObject failed {1}", ObjectID, waitResult); } } catch (Exception e) @@ -1509,7 +1509,7 @@ private void PoolCreateRequest(object state) // Now that CreateObject can throw, we need to catch the exception and discard it. // There is no further action we can take beyond tracing. The error will be // thrown to the user the next time they request a connection. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, PoolCreateRequest called CreateConnection which threw an exception: {1}", ObjectID, e); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, PoolCreateRequest called CreateConnection which threw an exception: {1}", ObjectID, e); } finally { @@ -1533,7 +1533,7 @@ internal void PutNewObject(DbConnectionInternal obj) { Debug.Assert(null != obj, "why are we adding a null object to the pool?"); // Debug.Assert(obj.CanBePooled, "non-poolable object in pool"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Pushing to general pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Pushing to general pool.", ObjectID, obj.ObjectID); _stackNew.Push(obj); _waitHandles.PoolSemaphore.Release(1); @@ -1577,7 +1577,7 @@ internal void PutObjectFromTransactedPool(DbConnectionInternal obj) // method, we can safely presume that the caller is the only person // that is using the connection, and that all pre-push logic has been // done and all transactions are ended. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Transaction has ended.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Transaction has ended.", ObjectID, obj.ObjectID); if (_state == State.Running && obj.CanBePooled) { @@ -1602,7 +1602,7 @@ private void QueuePoolCreateRequest() private bool ReclaimEmancipatedObjects() { bool emancipatedObjectFound = false; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}", ObjectID); List reclaimedObjects = new List(); int count; @@ -1654,7 +1654,7 @@ private bool ReclaimEmancipatedObjects() for (int i = 0; i < count; ++i) { DbConnectionInternal obj = reclaimedObjects[i]; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Reclaiming.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Reclaiming.", ObjectID, obj.ObjectID); emancipatedObjectFound = true; obj.DetachCurrentTransactionIfEnded(); @@ -1665,7 +1665,7 @@ private bool ReclaimEmancipatedObjects() internal void Startup() { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, CleanupWait={1}", ObjectID, _cleanupWait); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, CleanupWait={1}", ObjectID, _cleanupWait); _cleanupTimer = CreateCleanupTimer(); if (NeedToReplenish) { @@ -1675,7 +1675,7 @@ internal void Startup() internal void Shutdown() { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}", ObjectID); _state = State.ShuttingDown; // deactivate timer callbacks @@ -1697,7 +1697,7 @@ internal void TransactionEnded(Transaction transaction, DbConnectionInternal tra Debug.Assert(null != transactedObject, "null transactedObject?"); // Note: connection may still be associated with transaction due to Explicit Unbinding requirement. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); // called by the internal connection when it get's told that the // transaction is completed. We tell the transacted pool to remove diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/LocalDB.Windows.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/LocalDB.Windows.cs index 76fc48e984..7ff503bb87 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/LocalDB.Windows.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/LocalDB.Windows.cs @@ -64,26 +64,26 @@ internal static uint MapLocalDBErrorStateToCode(LocalDBErrorState errorState) switch (errorState) { case LocalDBErrorState.NO_INSTALLATION: - SqlClientEventSource.Log.SNITrace(" LocalDB is not installed. Error State ={0}", errorState); + SqlClientEventSource.Log.SNITraceEvent(" LocalDB is not installed. Error State ={0}", errorState); return SNICommon.LocalDBNoInstallation; case LocalDBErrorState.INVALID_CONFIG: - SqlClientEventSource.Log.SNITrace(" Invalid configuration. Error State ={0}", errorState); + SqlClientEventSource.Log.SNITraceEvent(" Invalid configuration. Error State ={0}", errorState); return SNICommon.LocalDBInvalidConfig; case LocalDBErrorState.NO_SQLUSERINSTANCEDLL_PATH: - SqlClientEventSource.Log.SNITrace(" No SQL user instance path. Error State ={0}", errorState); + SqlClientEventSource.Log.SNITraceEvent(" No SQL user instance path. Error State ={0}", errorState); return SNICommon.LocalDBNoSqlUserInstanceDllPath; case LocalDBErrorState.INVALID_SQLUSERINSTANCEDLL_PATH: - SqlClientEventSource.Log.SNITrace(" Invalid SQL user instance path. Error State ={0}", errorState); + SqlClientEventSource.Log.SNITraceEvent(" Invalid SQL user instance path. Error State ={0}", errorState); return SNICommon.LocalDBInvalidSqlUserInstanceDllPath; case LocalDBErrorState.NONE: return 0; default: - SqlClientEventSource.Log.SNITrace(" Invalid configuration. Error State ={0}", errorState); + SqlClientEventSource.Log.SNITraceEvent(" Invalid configuration. Error State ={0}", errorState); return SNICommon.LocalDBInvalidConfig; } } @@ -93,7 +93,7 @@ internal static uint MapLocalDBErrorStateToCode(LocalDBErrorState errorState) /// private bool LoadUserInstanceDll() { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { // Check in a non thread-safe way if the handle is already set for performance. @@ -118,7 +118,7 @@ private bool LoadUserInstanceDll() if (dllPath == null) { SNILoadHandle.SingletonInstance.LastError = new SNIError(SNIProviders.INVALID_PROV, 0, MapLocalDBErrorStateToCode(registryQueryErrorState), string.Empty); - SqlClientEventSource.Log.SNITrace("User instance DLL path is null."); + SqlClientEventSource.Log.SNITraceEvent("User instance DLL path is null."); return false; } @@ -126,7 +126,7 @@ private bool LoadUserInstanceDll() if (string.IsNullOrWhiteSpace(dllPath)) { SNILoadHandle.SingletonInstance.LastError = new SNIError(SNIProviders.INVALID_PROV, 0, SNICommon.LocalDBInvalidSqlUserInstanceDllPath, string.Empty); - SqlClientEventSource.Log.SNITrace(" User instance DLL path is invalid. DLL path ={0}", dllPath); + SqlClientEventSource.Log.SNITraceEvent(" User instance DLL path is invalid. DLL path ={0}", dllPath); return false; } @@ -136,7 +136,7 @@ private bool LoadUserInstanceDll() if (libraryHandle.IsInvalid) { SNILoadHandle.SingletonInstance.LastError = new SNIError(SNIProviders.INVALID_PROV, 0, SNICommon.LocalDBFailedToLoadDll, string.Empty); - SqlClientEventSource.Log.SNITrace(" Library Handle is invalid. Could not load the dll."); + SqlClientEventSource.Log.SNITraceEvent(" Library Handle is invalid. Could not load the dll."); libraryHandle.Dispose(); return false; } @@ -147,7 +147,7 @@ private bool LoadUserInstanceDll() if (_startInstanceHandle == IntPtr.Zero) { SNILoadHandle.SingletonInstance.LastError = new SNIError(SNIProviders.INVALID_PROV, 0, SNICommon.LocalDBBadRuntime, string.Empty); - SqlClientEventSource.Log.SNITrace(" Was not able to load the PROC from DLL. Bad Runtime."); + SqlClientEventSource.Log.SNITraceEvent(" Was not able to load the PROC from DLL. Bad Runtime."); libraryHandle.Dispose(); return false; } @@ -164,13 +164,13 @@ private bool LoadUserInstanceDll() } _sqlUserInstanceLibraryHandle = libraryHandle; - SqlClientEventSource.Log.SNITrace(" User Instance DLL was loaded successfully."); + SqlClientEventSource.Log.SNITraceEvent(" User Instance DLL was loaded successfully."); return true; } } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -181,7 +181,7 @@ private bool LoadUserInstanceDll() /// private string GetUserInstanceDllPath(out LocalDBErrorState errorState) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(" GetUserInstanceDllPath"); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(" GetUserInstanceDllPath"); try { string dllPath = null; @@ -190,7 +190,7 @@ private string GetUserInstanceDllPath(out LocalDBErrorState errorState) if (key == null) { errorState = LocalDBErrorState.NO_INSTALLATION; - SqlClientEventSource.Log.SNITrace(" not installed. Error state ={0}.", errorState); + SqlClientEventSource.Log.SNITraceEvent(" not installed. Error state ={0}.", errorState); return null; } @@ -205,7 +205,7 @@ private string GetUserInstanceDllPath(out LocalDBErrorState errorState) if (!Version.TryParse(subKey, out currentKeyVersion)) { errorState = LocalDBErrorState.INVALID_CONFIG; - SqlClientEventSource.Log.SNITrace(" Invalid Configuration. state ={0}.", errorState); + SqlClientEventSource.Log.SNITraceEvent(" Invalid Configuration. state ={0}.", errorState); return null; } @@ -219,7 +219,7 @@ private string GetUserInstanceDllPath(out LocalDBErrorState errorState) if (latestVersion.Equals(zeroVersion)) { errorState = LocalDBErrorState.INVALID_CONFIG; - SqlClientEventSource.Log.SNITrace(" Invalid Configuration. state ={0}.", errorState); + SqlClientEventSource.Log.SNITraceEvent(" Invalid Configuration. state ={0}.", errorState); return null; } @@ -232,7 +232,7 @@ private string GetUserInstanceDllPath(out LocalDBErrorState errorState) if (instanceAPIPathRegistryObject == null) { errorState = LocalDBErrorState.NO_SQLUSERINSTANCEDLL_PATH; - SqlClientEventSource.Log.SNITrace(" No SQL user instance DLL. Instance API Path REgistry Object Error. state ={0}.", errorState); + SqlClientEventSource.Log.SNITraceEvent(" No SQL user instance DLL. Instance API Path REgistry Object Error. state ={0}.", errorState); return null; } @@ -241,7 +241,7 @@ private string GetUserInstanceDllPath(out LocalDBErrorState errorState) if (valueKind != RegistryValueKind.String) { errorState = LocalDBErrorState.INVALID_SQLUSERINSTANCEDLL_PATH; - SqlClientEventSource.Log.SNITrace(" No SQL user instance DLL. state ={0}. Registry value kind error.", errorState); + SqlClientEventSource.Log.SNITraceEvent(" No SQL user instance DLL. state ={0}. Registry value kind error.", errorState); return null; } @@ -254,7 +254,7 @@ private string GetUserInstanceDllPath(out LocalDBErrorState errorState) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNICommon.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNICommon.cs index c5acfdf474..94ed2bece1 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNICommon.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNICommon.cs @@ -136,18 +136,18 @@ internal class SNICommon /// True if certificate is valid internal static bool ValidateSslServerCertificate(string targetServerName, object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { if (policyErrors == SslPolicyErrors.None) { - SqlClientEventSource.Log.SNITrace(" SSL Server certificate validated."); + SqlClientEventSource.Log.SNITraceEvent(" SSL Server certificate validated."); return true; } if ((policyErrors & SslPolicyErrors.RemoteCertificateNameMismatch) != 0) { - SqlClientEventSource.Log.SNITrace(" SSL Remote certificate name mismatched."); + SqlClientEventSource.Log.SNITraceEvent(" SSL Remote certificate name mismatched."); string certServerName = cert.Subject.Substring(cert.Subject.IndexOf('=') + 1); // Verify that target server name matches subject in the certificate @@ -189,7 +189,7 @@ internal static bool ValidateSslServerCertificate(string targetServerName, objec } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -203,7 +203,7 @@ internal static bool ValidateSslServerCertificate(string targetServerName, objec /// internal static uint ReportSNIError(SNIProviders provider, uint nativeError, uint sniError, string errorMessage) { - SqlClientEventSource.Log.SNITrace(" Provider ={0}, native Error ={1}, SNI Error ={2}, Error Message ={3}", provider, nativeError, sniError, errorMessage); + SqlClientEventSource.Log.SNITraceEvent(" Provider ={0}, native Error ={1}, SNI Error ={2}, Error Message ={3}", provider, nativeError, sniError, errorMessage); return ReportSNIError(new SNIError(provider, nativeError, sniError, errorMessage)); } @@ -216,7 +216,7 @@ internal static uint ReportSNIError(SNIProviders provider, uint nativeError, uin /// internal static uint ReportSNIError(SNIProviders provider, uint sniError, Exception sniException) { - SqlClientEventSource.Log.SNITrace(" Provider ={0}, SNI Error ={2}, Exception ={3}", provider, sniError, sniException.Message); + SqlClientEventSource.Log.SNITraceEvent(" Provider ={0}, SNI Error ={1}, Exception ={2}", provider, sniError, sniException.Message); return ReportSNIError(new SNIError(provider, sniError, sniException)); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNILoadHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNILoadHandle.cs index 90734a2f1a..2488e8a8a6 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNILoadHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNILoadHandle.cs @@ -30,7 +30,7 @@ public SNIError LastError set { - SqlClientEventSource.Log.SNITrace(" Last Error Value = {0}", value); + SqlClientEventSource.Log.SNITraceEvent(" Last Error Value = {0}", value); _lastError.Value = value; } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIMarsConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIMarsConnection.cs index e6774fcf8d..f45b687cd7 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIMarsConnection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIMarsConnection.cs @@ -62,22 +62,22 @@ public SNIMarsHandle CreateMarsSession(object callbackObject, bool async) /// public uint StartReceive() { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(" StartReceive"); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(" StartReceive"); try { SNIPacket packet = null; if (ReceiveAsync(ref packet) == TdsEnums.SNI_SUCCESS_IO_PENDING) { - SqlClientEventSource.Log.SNITrace(" Success IO pending."); + SqlClientEventSource.Log.SNITraceEvent(" Success IO pending."); return TdsEnums.SNI_SUCCESS_IO_PENDING; } - SqlClientEventSource.Log.SNITrace(" Connection not useable."); + SqlClientEventSource.Log.SNITraceEvent(" Connection not useable."); return SNICommon.ReportSNIError(SNIProviders.SMUX_PROV, 0, SNICommon.ConnNotUsableError, string.Empty); } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -88,7 +88,7 @@ public uint StartReceive() /// SNI error code public uint Send(SNIPacket packet) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(" Send"); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(" Send"); try { lock (this) @@ -98,7 +98,7 @@ public uint Send(SNIPacket packet) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -110,7 +110,7 @@ public uint Send(SNIPacket packet) /// SNI error code public uint SendAsync(SNIPacket packet, SNIAsyncCallback callback) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(" SendAsync"); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(" SendAsync"); try { lock (this) @@ -120,7 +120,7 @@ public uint SendAsync(SNIPacket packet, SNIAsyncCallback callback) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -131,7 +131,7 @@ public uint SendAsync(SNIPacket packet, SNIAsyncCallback callback) /// SNI error code public uint ReceiveAsync(ref SNIPacket packet) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(" SendAsync"); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(" SendAsync"); try { if (packet != null) @@ -147,7 +147,7 @@ public uint ReceiveAsync(ref SNIPacket packet) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -157,7 +157,7 @@ public uint ReceiveAsync(ref SNIPacket packet) /// SNI error status public uint CheckConnection() { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { lock (this) @@ -167,7 +167,7 @@ public uint CheckConnection() } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -179,7 +179,7 @@ public void HandleReceiveError(SNIPacket packet) Debug.Assert(Monitor.IsEntered(this), "HandleReceiveError was called without being locked."); if (!Monitor.IsEntered(this)) { - SqlClientEventSource.Log.SNITrace(" HandleReceiveError was called without being locked."); + SqlClientEventSource.Log.SNITraceEvent(" HandleReceiveError was called without being locked."); } foreach (SNIMarsHandle handle in _sessions.Values) { @@ -208,7 +208,7 @@ public void HandleSendComplete(SNIPacket packet, uint sniErrorCode) /// SNI error code public void HandleReceiveComplete(SNIPacket packet, uint sniErrorCode) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { SNISMUXHeader currentHeader = null; @@ -220,7 +220,7 @@ public void HandleReceiveComplete(SNIPacket packet, uint sniErrorCode) lock (this) { HandleReceiveError(packet); - SqlClientEventSource.Log.SNITrace(" not successfull."); + SqlClientEventSource.Log.SNITraceEvent(" not successfull."); return; } } @@ -246,7 +246,7 @@ public void HandleReceiveComplete(SNIPacket packet, uint sniErrorCode) if (sniErrorCode == TdsEnums.SNI_SUCCESS_IO_PENDING) { - SqlClientEventSource.Log.SNITrace(" not successfull."); + SqlClientEventSource.Log.SNITraceEvent(" not successfull."); return; } @@ -343,7 +343,7 @@ public void HandleReceiveComplete(SNIPacket packet, uint sniErrorCode) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -352,14 +352,14 @@ public void HandleReceiveComplete(SNIPacket packet, uint sniErrorCode) /// public uint EnableSsl(uint options) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { return _lowerHandle.EnableSsl(options); } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -368,14 +368,14 @@ public uint EnableSsl(uint options) /// public void DisableSsl() { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { _lowerHandle.DisableSsl(); } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -385,14 +385,14 @@ public void DisableSsl() /// public void KillConnection() { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { _lowerHandle.KillConnection(); } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } #endif diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIMarsHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIMarsHandle.cs index d455100fa8..7c740be85c 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIMarsHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNIMarsHandle.cs @@ -51,19 +51,19 @@ internal sealed class SNIMarsHandle : SNIHandle /// public override void Dispose() { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { SendControlPacket(SNISMUXFlags.SMUX_FIN); } catch (Exception e) { - SqlClientEventSource.Log.SNITrace(" internal exception error = {0}, Member Name={1}", e.Message, e.GetType().Name); + SqlClientEventSource.Log.SNITraceEvent(" internal exception error = {0}, Member Name={1}", e.Message, e.GetType().Name); SNICommon.ReportSNIError(SNIProviders.SMUX_PROV, SNICommon.InternalExceptionError, e); } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -89,7 +89,7 @@ public SNIMarsHandle(SNIMarsConnection connection, ushort sessionId, object call /// SMUX header flags private void SendControlPacket(SNISMUXFlags flags) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { SNIPacket packet = new SNIPacket(headerSize: SNISMUXHeader.HEADER_LENGTH, dataSize: 0); @@ -105,7 +105,7 @@ private void SendControlPacket(SNISMUXFlags flags) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -146,7 +146,7 @@ private SNIPacket SetPacketSMUXHeader(SNIPacket packet) public override uint Send(SNIPacket packet) { Debug.Assert(packet.ReservedHeaderSize == SNISMUXHeader.HEADER_LENGTH, "mars handle attempting to send muxed packet without mux reservation in Send"); - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { while (true) @@ -176,7 +176,7 @@ public override uint Send(SNIPacket packet) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -189,14 +189,14 @@ public override uint Send(SNIPacket packet) private uint InternalSendAsync(SNIPacket packet, SNIAsyncCallback callback) { Debug.Assert(packet.ReservedHeaderSize == SNISMUXHeader.HEADER_LENGTH, "mars handle attempting to send muxed packet without mux reservation in InternalSendAsync"); - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { lock (this) { if (_sequenceNumber >= _sendHighwater) { - SqlClientEventSource.Log.SNITrace(" SNI Queue is full"); + SqlClientEventSource.Log.SNITraceEvent(" SNI Queue is full"); return TdsEnums.SNI_QUEUE_FULL; } @@ -207,7 +207,7 @@ private uint InternalSendAsync(SNIPacket packet, SNIAsyncCallback callback) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -217,7 +217,7 @@ private uint InternalSendAsync(SNIPacket packet, SNIAsyncCallback callback) /// SNI error code private uint SendPendingPackets() { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); SNIMarsQueuedPacket packet = null; try { @@ -234,7 +234,7 @@ private uint SendPendingPackets() if (result != TdsEnums.SNI_SUCCESS && result != TdsEnums.SNI_SUCCESS_IO_PENDING) { - SqlClientEventSource.Log.SNITrace(" InternalSendAsync result is not SNI_SUCCESS and is not SNI_SUCCESS_IO_PENDING"); + SqlClientEventSource.Log.SNITraceEvent(" InternalSendAsync result is not SNI_SUCCESS and is not SNI_SUCCESS_IO_PENDING"); return result; } @@ -255,7 +255,7 @@ private uint SendPendingPackets() } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -268,7 +268,7 @@ private uint SendPendingPackets() /// SNI error code public override uint SendAsync(SNIPacket packet, bool disposePacketAfterSendAsync, SNIAsyncCallback callback = null) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { lock (this) @@ -281,7 +281,7 @@ public override uint SendAsync(SNIPacket packet, bool disposePacketAfterSendAsyn } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -292,7 +292,7 @@ public override uint SendAsync(SNIPacket packet, bool disposePacketAfterSendAsyn /// SNI error code public override uint ReceiveAsync(ref SNIPacket packet) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { lock (_receivedPacketQueue) @@ -328,7 +328,7 @@ public override uint ReceiveAsync(ref SNIPacket packet) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -337,7 +337,7 @@ public override uint ReceiveAsync(ref SNIPacket packet) /// public void HandleReceiveError(SNIPacket packet) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { lock (_receivedPacketQueue) @@ -350,7 +350,7 @@ public void HandleReceiveError(SNIPacket packet) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -361,7 +361,7 @@ public void HandleReceiveError(SNIPacket packet) /// SNI error code public void HandleSendComplete(SNIPacket packet, uint sniErrorCode) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { lock (this) @@ -373,7 +373,7 @@ public void HandleSendComplete(SNIPacket packet, uint sniErrorCode) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -383,7 +383,7 @@ public void HandleSendComplete(SNIPacket packet, uint sniErrorCode) /// Send highwater mark public void HandleAck(uint highwater) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { lock (this) @@ -397,7 +397,7 @@ public void HandleAck(uint highwater) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -408,7 +408,7 @@ public void HandleAck(uint highwater) /// SMUX header public void HandleReceiveComplete(SNIPacket packet, SNISMUXHeader header) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { lock (this) @@ -443,7 +443,7 @@ public void HandleReceiveComplete(SNIPacket packet, SNISMUXHeader header) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -475,7 +475,7 @@ private void SendAckIfNecessary() /// SNI error code public override uint Receive(out SNIPacket packet, int timeoutInMilliseconds) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { packet = null; @@ -526,7 +526,7 @@ public override uint Receive(out SNIPacket packet, int timeoutInMilliseconds) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs index eefcaaaebc..8b1d921a1f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNINpHandle.cs @@ -40,8 +40,8 @@ internal sealed class SNINpHandle : SNIHandle public SNINpHandle(string serverName, string pipeName, long timerExpire, object callbackObject) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(" Constructor"); - SqlClientEventSource.Log.SNITrace(" Constructor. server name = {0}, pipe name = {1}", serverName, pipeName); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(" Constructor"); + SqlClientEventSource.Log.SNITraceEvent(" Constructor. server name = {0}, pipe name = {1}", serverName, pipeName); try { _sendSync = new object(); @@ -73,14 +73,14 @@ public SNINpHandle(string serverName, string pipeName, long timerExpire, object { SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.ConnOpenFailedError, te); _status = TdsEnums.SNI_ERROR; - SqlClientEventSource.Log.SNITrace(" Timed out. Exception = {0}", te.Message); + SqlClientEventSource.Log.SNITraceEvent(" Timed out. Exception = {0}", te.Message); return; } catch (IOException ioe) { SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.ConnOpenFailedError, ioe); _status = TdsEnums.SNI_ERROR; - SqlClientEventSource.Log.SNITrace(" IOException = {0}", ioe.Message); + SqlClientEventSource.Log.SNITraceEvent(" IOException = {0}", ioe.Message); return; } @@ -88,7 +88,7 @@ public SNINpHandle(string serverName, string pipeName, long timerExpire, object { SNICommon.ReportSNIError(SNIProviders.NP_PROV, 0, SNICommon.ConnOpenFailedError, string.Empty); _status = TdsEnums.SNI_ERROR; - SqlClientEventSource.Log.SNITrace(" Pipe stream is not connected or cannot write or read to/from it."); + SqlClientEventSource.Log.SNITraceEvent(" Pipe stream is not connected or cannot write or read to/from it."); return; } @@ -100,7 +100,7 @@ public SNINpHandle(string serverName, string pipeName, long timerExpire, object } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -122,12 +122,12 @@ public override uint Status public override uint CheckConnection() { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { if (!_stream.CanWrite || !_stream.CanRead) { - SqlClientEventSource.Log.SNITrace(" cannot wite or read to/from the stream"); + SqlClientEventSource.Log.SNITraceEvent(" cannot wite or read to/from the stream"); return TdsEnums.SNI_ERROR; } else @@ -137,7 +137,7 @@ public override uint CheckConnection() } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -170,7 +170,7 @@ public override void Dispose() public override uint Receive(out SNIPacket packet, int timeout) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { SNIPacket errorPacket; @@ -187,7 +187,7 @@ public override uint Receive(out SNIPacket packet, int timeout) errorPacket = packet; packet = null; var e = new Win32Exception(); - SqlClientEventSource.Log.SNITrace(" packet length is 0."); + SqlClientEventSource.Log.SNITraceEvent(" packet length is 0."); return ReportErrorAndReleasePacket(errorPacket, (uint)e.NativeErrorCode, 0, e.Message); } } @@ -195,14 +195,14 @@ public override uint Receive(out SNIPacket packet, int timeout) { errorPacket = packet; packet = null; - SqlClientEventSource.Log.SNITrace(" ObjectDisposedException message = {0}.", ode.Message); + SqlClientEventSource.Log.SNITraceEvent(" ObjectDisposedException message = {0}.", ode.Message); return ReportErrorAndReleasePacket(errorPacket, ode); } catch (IOException ioe) { errorPacket = packet; packet = null; - SqlClientEventSource.Log.SNITrace(" IOException message = {0}.", ioe.Message); + SqlClientEventSource.Log.SNITraceEvent(" IOException message = {0}.", ioe.Message); return ReportErrorAndReleasePacket(errorPacket, ioe); } return TdsEnums.SNI_SUCCESS; @@ -210,13 +210,13 @@ public override uint Receive(out SNIPacket packet, int timeout) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } public override uint ReceiveAsync(ref SNIPacket packet) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { SNIPacket errorPacket; @@ -231,26 +231,26 @@ public override uint ReceiveAsync(ref SNIPacket packet) { errorPacket = packet; packet = null; - SqlClientEventSource.Log.SNITrace(" ObjectDisposedException message = {0}.", ode.Message); + SqlClientEventSource.Log.SNITraceEvent(" ObjectDisposedException message = {0}.", ode.Message); return ReportErrorAndReleasePacket(errorPacket, ode); } catch (IOException ioe) { errorPacket = packet; packet = null; - SqlClientEventSource.Log.SNITrace(" IOException message = {0}.", ioe.Message); + SqlClientEventSource.Log.SNITraceEvent(" IOException message = {0}.", ioe.Message); return ReportErrorAndReleasePacket(errorPacket, ioe); } } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } public override uint Send(SNIPacket packet) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { bool releaseLock = false; @@ -282,12 +282,12 @@ public override uint Send(SNIPacket packet) } catch (ObjectDisposedException ode) { - SqlClientEventSource.Log.SNITrace(" ObjectDisposedException message = {0}.", ode.Message); + SqlClientEventSource.Log.SNITraceEvent(" ObjectDisposedException message = {0}.", ode.Message); return ReportErrorAndReleasePacket(packet, ode); } catch (IOException ioe) { - SqlClientEventSource.Log.SNITrace(" IOException message = {0}.", ioe.Message); + SqlClientEventSource.Log.SNITraceEvent(" IOException message = {0}.", ioe.Message); return ReportErrorAndReleasePacket(packet, ioe); } @@ -303,13 +303,13 @@ public override uint Send(SNIPacket packet) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } public override uint SendAsync(SNIPacket packet, bool disposePacketAfterSendAsync, SNIAsyncCallback callback = null) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { SNIAsyncCallback cb = callback ?? _sendCallback; @@ -318,7 +318,7 @@ public override uint SendAsync(SNIPacket packet, bool disposePacketAfterSendAsyn } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -330,7 +330,7 @@ public override void SetAsyncCallbacks(SNIAsyncCallback receiveCallback, SNIAsyn public override uint EnableSsl(uint options) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { _validateCert = (options & TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE) != 0; @@ -341,12 +341,12 @@ public override uint EnableSsl(uint options) } catch (AuthenticationException aue) { - SqlClientEventSource.Log.SNITrace(" AuthenticationException message = {0}.", aue.Message); + SqlClientEventSource.Log.SNITraceEvent(" AuthenticationException message = {0}.", aue.Message); return SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, aue); } catch (InvalidOperationException ioe) { - SqlClientEventSource.Log.SNITrace("InvalidOperationExceptionn message = {0}.", ioe.Message); + SqlClientEventSource.Log.SNITraceEvent("InvalidOperationExceptionn message = {0}.", ioe.Message); return SNICommon.ReportSNIError(SNIProviders.NP_PROV, SNICommon.InternalExceptionError, ioe); } _stream = _sslStream; @@ -354,7 +354,7 @@ public override uint EnableSsl(uint options) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -378,7 +378,7 @@ public override void DisableSsl() /// true if valid private bool ValidateServerCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors) { - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { if (!_validateCert) @@ -390,7 +390,7 @@ private bool ValidateServerCertificate(object sender, X509Certificate cert, X509 } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SSRP.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SSRP.cs index 8c9a27a115..f444236b70 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SSRP.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SSRP.cs @@ -26,7 +26,7 @@ internal static int GetPortByInstanceName(string browserHostName, string instanc { Debug.Assert(!string.IsNullOrWhiteSpace(browserHostName), "browserHostName should not be null, empty, or whitespace"); Debug.Assert(!string.IsNullOrWhiteSpace(instanceName), "instanceName should not be null, empty, or whitespace"); - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { byte[] instanceInfoRequest = CreateInstanceInfoRequest(instanceName); @@ -37,7 +37,7 @@ internal static int GetPortByInstanceName(string browserHostName, string instanc } catch (SocketException se) { - SqlClientEventSource.Log.SNITrace(" SocketException Message = {0}", se.Message); + SqlClientEventSource.Log.SNITraceEvent(" SocketException Message = {0}", se.Message); throw new Exception(SQLMessage.SqlServerBrowserNotAccessible(), se); } @@ -61,7 +61,7 @@ internal static int GetPortByInstanceName(string browserHostName, string instanc } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } @@ -73,7 +73,7 @@ internal static int GetPortByInstanceName(string browserHostName, string instanc private static byte[] CreateInstanceInfoRequest(string instanceName) { Debug.Assert(!string.IsNullOrWhiteSpace(instanceName), "instanceName should not be null, empty, or whitespace"); - long scopeID = SqlClientEventSource.Log.SNIScopeEnter(""); + long scopeID = SqlClientEventSource.Log.SNIScopeEnterEvent(""); try { const byte ClntUcastInst = 0x04; @@ -88,7 +88,7 @@ private static byte[] CreateInstanceInfoRequest(string instanceName) } finally { - SqlClientEventSource.Log.ScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.SNIScopeLeaveEvent(scopeID); } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs index f1fa9af23f..577afa6c6f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs @@ -546,7 +546,7 @@ private Task CreateAndExecuteInitialQueryAsync(out Bulk { string TDSCommand = CreateInitialQuery(); SqlClientEventSource.Log.TraceEvent(" Initial Query: '{0}'", TDSCommand); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); Task executeTask = _parser.TdsExecuteSQLBatch(TDSCommand, this.BulkCopyTimeout, null, _stateObj, sync: !_isAsyncBulkCopy, callerHasConnectionLock: true); if (executeTask == null) @@ -811,7 +811,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i private Task SubmitUpdateBulkCommand(string TDSCommand) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); Task executeTask = _parser.TdsExecuteSQLBatch(TDSCommand, this.BulkCopyTimeout, null, _stateObj, sync: !_isAsyncBulkCopy, callerHasConnectionLock: true); if (executeTask == null) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs index bef2b2eb39..880cd3a670 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs @@ -2,7 +2,6 @@ // 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.Text; using System.Diagnostics.Tracing; using System.Threading; @@ -14,9 +13,12 @@ internal class SqlClientEventSource : EventSource // Defines the singleton instance for the Resources ETW provider internal static readonly SqlClientEventSource Log = new SqlClientEventSource(); + #region Event IDs + // Initialized static Scope IDs private static long s_nextScopeId = 0; private static long s_nextNotificationScopeId = 0; private static long s_nextPoolerScopeId = 0; + private static long s_nextSNIScopeId = 0; /// /// Defines EventId for BeginExecute (Reader, Scalar, NonQuery, XmlReader). @@ -27,440 +29,621 @@ internal class SqlClientEventSource : EventSource /// Defines EventId for EndExecute (Reader, Scalar, NonQuery, XmlReader). /// private const int EndExecuteEventId = 2; + + /// + /// Defines EventId for Trace() events + /// private const int TraceEventId = 3; - private const int EnterScopeId = 4; - private const int ExitScopeId = 5; - private const int TraceBinId = 6; - private const int CorrelationTraceId = 7; - private const int NotificationsScopeEnterId = 8; - private const int NotificationsTraceId = 9; - private const int PoolerScopeEnterId = 10; + + /// + /// Defines EventId for ScopeEnter() events + /// + private const int ScopeEnterId = 4; + + /// + /// Defines EventId for ScopeLeave() events + /// + private const int ScopeExitId = 5; + + /// + /// Defines EventId for notificationScopeEnter() events + /// + private const int NotificationScopeEnterId = 6; + + /// + /// Defines EventId for notificationScopeLeave() events + /// + private const int NotificationScopeExitId = 7; + + /// + /// Defines EventId for notificationScopeTrace() events + /// + private const int NotificationTraceId = 8; + + /// + /// Defines EventId for PoolerScopeEnter() events + /// + private const int PoolerScopeEnterId = 9; + + /// + /// Defines EventId for PoolerScopeLeave() events + /// + private const int PoolerScopeExitId = 10; + + /// + /// Defines EventId for PoolerTrace() events + /// private const int PoolerTraceId = 11; /// - /// Keyword definitions. These represent logical groups of events that can be turned on and off independently - /// Often each task has a keyword, but where tasks are determined by subsystem, keywords are determined by - /// usefulness to end users to filter. Generally users don't mind extra events if they are not high volume - /// so grouping low volume events together in a single keywords is OK (users can post-filter by task if desired) + /// Defines EventId for AdvancedTrace() events + /// + private const int AdvancedTraceId = 12; + + /// + /// Defines EventId for AdvancedScopeEnter() events + /// + private const int AdvancedScopeEnterId = 13; + + /// + /// Defines EventId for AdvancedScopeLeave() events + /// + private const int AdvancedScopeExitId = 14; + + /// + /// Defines EventId for AdvancedTraceBin() events + /// + private const int AdvancedTraceBinId = 15; + + /// + /// Defines EventId for AdvancedTraceError() events + /// + private const int AdvancedTraceErrorId = 16; + + /// + /// Defines EventId for CorrelationTrace() events + /// + private const int CorrelationTraceId = 17; + + /// + /// Defines EventId for StateDump() events + /// + private const int StateDumpEventId = 18; + + /// + /// Defines EventId for SNITrace() events + /// + private const int SNITraceEventId = 19; + + /// + /// Defines EventId for SNIEnterScope() events + /// + private const int SNIScopeEnterId = 20; + + /// + /// Defines EventId for SNIExitScope() events + /// + private const int SNIScopeExitId = 21; + #endregion + + /// + /// These represent logical groups of events that can be turned on and off independently + /// Often each task has a keyword, but where tasks are determined by subsystem, keywords + /// are determined by usefulness to end users to filter. + /// + /// Generally users don't mind extra events if they are not high volume, so grouping low + /// volume events together in a single keywords is OK (users can post-filter by task if desired) + /// /// - /// The visibility of the enum has to be public, otherwise there will be an ArgumentException on calling related WriteEvent method. the Keywords class has to be a nested class. + /// The visibility of the enum has to be public, otherwise there will be an ArgumentException + /// on calling related WriteEvent() method. + /// + /// The Keywords class has to be a nested class. /// Each keyword must be a power of 2. /// + /// /// #region Keywords public class Keywords { - internal const EventKeywords SqlClient = 0; + /// + /// Captures Start/Stop events before and after command execution. + /// + internal const EventKeywords ExecutionTrace = (EventKeywords)1; - internal const EventKeywords Trace = (EventKeywords)1; - - internal const EventKeywords TraceBin = (EventKeywords)2; + /// + /// Captures basic application flow trace events. + /// + internal const EventKeywords Trace = (EventKeywords)2; + /// + /// Captures basic application scope entering and exiting events. + /// internal const EventKeywords Scope = (EventKeywords)4; + /// + /// Captures `SqlNotification` flow trace events. + /// internal const EventKeywords NotificationTrace = (EventKeywords)8; - internal const EventKeywords Pooling = (EventKeywords)16; - - internal const EventKeywords Correlation = (EventKeywords)32; - - internal const EventKeywords NotificationScope = (EventKeywords)64; - - internal const EventKeywords PoolerScope = (EventKeywords)128; - - internal const EventKeywords PoolerTrace = (EventKeywords)256; - - internal const EventKeywords Advanced = (EventKeywords)512; - + /// + /// Captures `SqlNotification` scope entering and exiting events. + /// + internal const EventKeywords NotificationScope = (EventKeywords)16; + + /// + /// Captures connection pooling flow trace events. + /// + internal const EventKeywords PoolerTrace = (EventKeywords)32; + + /// + /// Captures connection pooling scope trace events. + /// + internal const EventKeywords PoolerScope = (EventKeywords)64; + + /// + /// Captures advanced flow trace events. + /// + internal const EventKeywords AdvancedTrace = (EventKeywords)128; + + /// + /// Captures advanced flow trace events with additional information. + /// + internal const EventKeywords AdvancedTraceBin = (EventKeywords)256; + + /// + /// Captures correlation flow trace events. + /// + internal const EventKeywords CorrelationTrace = (EventKeywords)512; + + /// + /// Captures full state dump of `SqlConnection` + /// internal const EventKeywords StateDump = (EventKeywords)1024; + /// + /// Captures application flow traces from Managed networking implementation + /// internal const EventKeywords SNITrace = (EventKeywords)2048; + + /// + /// Captures scope trace events from Managed networking implementation + /// + internal const EventKeywords SNIScope = (EventKeywords)4096; } #endregion - public static class Tasks // this name is important for EventSource + #region Tasks + /// + /// Tasks supported by SqlClient's EventSource implementation + /// + public static class Tasks { - /// Task that tracks sql command execute. + /// + /// Task that tracks SqlCommand execution. + /// public const EventTask ExecuteCommand = (EventTask)1; } + #endregion #region Enable/Disable Events [NonEvent] - internal bool IsTraceEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Trace); + internal bool IsExecutionTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.ExecutionTrace); [NonEvent] - internal bool IsTraceBinEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.TraceBin); + internal bool IsTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.Trace); [NonEvent] - internal bool IsScopeEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Scope); + internal bool IsScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.Scope); [NonEvent] - internal bool IsPoolerScopeEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.PoolerScope); + internal bool IsNotificationTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.NotificationTrace); [NonEvent] - internal bool IsCorrelationEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Correlation); + internal bool IsNotificationScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.NotificationScope); [NonEvent] - internal bool IsNotificationScopeEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.NotificationScope); + internal bool IsPoolerTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.PoolerTrace); [NonEvent] - internal bool IsPoolingEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Pooling); + internal bool IsPoolerScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.PoolerScope); [NonEvent] - internal bool IsNotificationTraceEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.NotificationTrace); + internal bool IsAdvancedTraceOn() => Log.IsEnabled(EventLevel.Verbose, Keywords.AdvancedTrace); [NonEvent] - internal bool IsPoolerTraceEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.PoolerTrace); + internal bool IsCorrelationEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.CorrelationTrace); [NonEvent] - internal bool IsAdvanceTraceOn() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Advanced); + internal bool IsStateDumpEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.StateDump); [NonEvent] - internal bool IsStateDumpEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.StateDump); - - [NonEvent] - internal bool IsSqlClientEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.SqlClient); + internal bool IsSNITraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.SNITrace); [NonEvent] - internal bool IsSNITraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.SNITrace); + internal bool IsSNIScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.SNIScope); #endregion #region overloads //Never use event writer directly as they are not checking for enabled/disabled situations. Always use overloads. + + #region Trace [NonEvent] - internal void SNITrace(string message) + internal void TraceEvent(string message) { - if (Log.IsSNITraceEnabled()) + if (Log.IsTraceEnabled()) { - Trace(string.Format(message)); + Trace(message); } } [NonEvent] - internal void SNITrace(string message, T0 args0) + internal void TraceEvent(string message, T0 args0) { - if (Log.IsSNITraceEnabled()) + if (Log.IsTraceEnabled()) { - Trace(string.Format(message, args0)); + Trace(string.Format(message, args0?.ToString() ?? "Null")); } } [NonEvent] - internal void SNITrace(string message, T0 args0, T1 args1) + internal void TraceEvent(string message, T0 args0, T1 args1) { - if (Log.IsSNITraceEnabled()) + if (Log.IsTraceEnabled()) { - Trace(string.Format(message, args0, args1)); + Trace(string.Format(message, args0?.ToString() ?? "Null", args1?.ToString() ?? "Null")); } } [NonEvent] - internal void SNITrace(string message, T0 args0, T1 args1, T2 args2) + internal void TraceEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsSNITraceEnabled()) + if (Log.IsTraceEnabled()) { Trace(string.Format(message, args0, args1, args2)); } } [NonEvent] - internal void SNITrace(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal void TraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsSNITraceEnabled()) + if (Log.IsTraceEnabled()) { Trace(string.Format(message, args0, args1, args2, args3)); } } [NonEvent] - internal void SNITrace(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4) + internal void TraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5) { - if (Log.IsSNITraceEnabled()) + if (Log.IsTraceEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3, args4)); + Trace(string.Format(message, args0, args1, args2, args3, args4, args5)); } } + #endregion + #region Scope [NonEvent] - internal void TraceEvent(string message, T0 args0) + internal long ScopeEnterEvent(string message) { - if (Log.IsTraceEnabled()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0?.ToString())); + return ScopeEnter(message); } + return 0; } [NonEvent] - internal void TraceEvent(string message) + internal long ScopeEnterEvent(string message, T0 args0) { - if (Log.IsTraceEnabled()) + if (Log.IsScopeEnabled()) { - Trace(message); + return ScopeEnter(string.Format(message, args0)); } + return 0; } [NonEvent] - internal void TraceEvent(string message, T0 args0, T1 args1) + internal long ScopeEnterEvent(string message, T0 args0, T1 args1) { - if (Log.IsTraceEnabled()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0?.ToString() ?? "Null", args1?.ToString() ?? "Null")); + return ScopeEnter(string.Format(message, args0, args1)); } + return 0; } [NonEvent] - internal void TraceEvent(string message, T0 args0, T1 args1, T2 args2) + internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsTraceEnabled()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0?.ToString() ?? "Null", args1?.ToString() ?? "Null", args2?.ToString() ?? "Null")); + return ScopeEnter(string.Format(message, args0, args1, args2)); } + return 0; } [NonEvent] - internal void TraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsTraceEnabled()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3)); + return ScopeEnter(string.Format(message, args0, args1, args2, args3)); } + return 0; } [NonEvent] - internal void TraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5) + internal void ScopeLeaveEvent(long scopeId) { - if (Log.IsTraceEnabled()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3, args4, args5)); + ScopeLeave(scopeId); } } + #endregion + #region Notification Trace [NonEvent] - internal void AdvanceTrace(string message) + internal void NotificationTraceEvent(string message) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationTraceEnabled()) { - Trace(message); + NotificationTrace(message); } } [NonEvent] - internal void AdvanceTrace(string message, T0 args0) + internal void NotificationTraceEvent(string message, T0 args0) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationTraceEnabled()) { - Trace(string.Format(message, args0)); + NotificationTrace(string.Format(message, args0)); } } [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1) + internal void NotificationTraceEvent(string message, T0 args0, T1 args1) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationTraceEnabled()) { - Trace(string.Format(message, args0, args1)); + NotificationTrace(string.Format(message, args0, args1)); } } [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2) + internal void NotificationTraceEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationTraceEnabled()) { - Trace(string.Format(message, args0, args1, args2)); + NotificationTrace(string.Format(message, args0, args1, args2)); } } [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal void NotificationTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationTraceEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3)); + NotificationTrace(string.Format(message, args0, args1, args2, args3)); } } + #endregion + #region Notification Scope [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4) + internal long NotificationScopeEnterEvent(string message, T0 args0) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationScopeEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3, args4)); + return NotificationScopeEnter(string.Format(message, args0)); } + return 0; } + [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5) + internal long NotificationScopeEnterEvent(string message, T0 args0, T1 args1) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationScopeEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3, args4, args5)); + return NotificationScopeEnter(string.Format(message, args0, args1)); } + return 0; } [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5, T6 args6, T7 args7) + internal long NotificationScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationScopeEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3, args4, args5, args6, args7)); + return NotificationScopeEnter(string.Format(message, args0, args1, args2)); } + return 0; } [NonEvent] - internal void AdvanceTraceBin(string message, T0 args0, T1 args1) + internal long NotificationScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationScopeEnabled()) { - TraceBin(string.Format(message, args0, args1)); + return NotificationScopeEnter(string.Format(message, args0, args1, args2, args3)); } + return 0; } [NonEvent] - internal long ScopeEnterEvent(string message, T0 args0) + internal void NotificationScopeLeaveEvent(long scopeId) { - if (Log.IsScopeEnabled()) + if (Log.IsNotificationScopeEnabled()) { - return SNIScopeEnter(string.Format(message, args0)); + NotificationScopeLeave(scopeId); } - return 0; } + #endregion + #region Pooler Trace [NonEvent] - internal long AdvanceScopeEnter(string message, T0 args0) + internal void PoolerTraceEvent(string message, T0 args0) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsPoolerTraceEnabled()) { - return SNIScopeEnter(string.Format(message, args0)); + PoolerTrace(string.Format(message, args0)); } - return 0; } [NonEvent] - internal long ScopeEnterEvent(string message) + internal void PoolerTraceEvent(string message, T0 args0, T1 args1) { - if (Log.IsScopeEnabled()) + if (Log.IsPoolerTraceEnabled()) { - return SNIScopeEnter(message); + PoolerTrace(string.Format(message, args0, args1)); } - return 0; } [NonEvent] - internal long ScopeEnterEvent(string message, T0 args0, T1 args1) + internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsScopeEnabled()) + if (Log.IsPoolerTraceEnabled()) { - return SNIScopeEnter(string.Format(message, args0, args1)); + PoolerTrace(string.Format(message, args0, args1, args2)); } - return 0; } [NonEvent] - internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2) + internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsScopeEnabled()) + if (Log.IsPoolerTraceEnabled()) { - return SNIScopeEnter(string.Format(message, args0, args1, args2)); + PoolerTrace(string.Format(message, args0, args1, args2, args3)); } - return 0; } + #endregion + #region Pooler Scope [NonEvent] - internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal long PoolerScopeEnterEvent(string message, T0 args0) { - if (Log.IsScopeEnabled()) + if (Log.IsPoolerScopeEnabled()) { - return SNIScopeEnter(string.Format(message, args0, args1, args2, args3)); + return PoolerScopeEnter(string.Format(message, args0)); } return 0; } [NonEvent] - internal long PoolerScopeEnterEvent(string message, T0 args0) + internal void PoolerScopeLeaveEvent(long scopeId) { if (Log.IsPoolerScopeEnabled()) { - return PoolerScopeEnter(string.Format(message, args0)); + PoolerScopeLeave(scopeId); } - return 0; } + #endregion + #region AdvancedTrace [NonEvent] - internal long NotificationsScopeEnterEvent(string message, T0 args0) + internal void AdvancedTraceEvent(string message) { - if (Log.IsNotificationScopeEnabled()) + if (Log.IsAdvancedTraceOn()) { - return NotificationsScopeEnter(string.Format(message, args0)); + AdvancedTrace(message); } - return 0; } [NonEvent] - internal long NotificationsScopeEnterEvent(string message, T0 args0, T1 args1) + internal void AdvancedTraceEvent(string message, T0 args0) { - if (Log.IsNotificationScopeEnabled()) + if (Log.IsAdvancedTraceOn()) { - return NotificationsScopeEnter(string.Format(message, args0, args1)); + AdvancedTrace(string.Format(message, args0)); } - return 0; } [NonEvent] - internal long NotificationsScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1) { - if (Log.IsNotificationScopeEnabled()) + if (Log.IsAdvancedTraceOn()) { - return NotificationsScopeEnter(string.Format(message, args0, args1, args2)); + AdvancedTrace(string.Format(message, args0, args1)); } - return 0; } [NonEvent] - internal long NotificationsScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsNotificationScopeEnabled()) + if (Log.IsAdvancedTraceOn()) { - return NotificationsScopeEnter(string.Format(message, args0, args1, args2, args3)); + AdvancedTrace(string.Format(message, args0, args1, args2)); } - return 0; } [NonEvent] - internal void PoolerTraceEvent(string message, T0 args0) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsPoolerTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - PoolerTrace(string.Format(message, args0)); + AdvancedTrace(string.Format(message, args0, args1, args2, args3)); } } [NonEvent] - internal void PoolerTraceEvent(string message, T0 args0, T1 args1) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5) { - if (Log.IsPoolerTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - PoolerTrace(string.Format(message, args0, args1)); + AdvancedTrace(string.Format(message, args0, args1, args2, args3, args4, args5)); } } [NonEvent] - internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5, T6 args6, T7 args7) { - if (Log.IsPoolerTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - PoolerTrace(string.Format(message, args0, args1, args2)); + AdvancedTrace(string.Format(message, args0, args1, args2, args3, args4, args5, args6, args7)); } } [NonEvent] - internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal long AdvancedScopeEnterEvent(string message, T0 args0) { - if (Log.IsPoolerTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - PoolerTrace(string.Format(message, args0, args1, args2, args3)); + return AdvancedScopeEnter(string.Format(message, args0)); + } + return 0; + } + + [NonEvent] + internal void AdvanceScopeLeave(long scopeId) + { + if (Log.IsAdvancedTraceOn()) + { + AdvancedScopeLeave(scopeId); + } + } + + [NonEvent] + internal void AdvancedTraceBinEvent(string message, T0 args0, T1 args1) + { + if (Log.IsAdvancedTraceOn()) + { + AdvancedTraceBin(string.Format(message, args0, args1)); + } + } + + [NonEvent] + internal void AdvancedTraceErrorEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4) + { + if (Log.IsAdvancedTraceOn()) + { + AdvancedTraceError(string.Format(message, args0, args1, args2, args3, args4)); } } + #endregion + #region Correlation Trace [NonEvent] internal void CorrelationTraceEvent(string message, T0 args0) { @@ -475,7 +658,7 @@ internal void CorrelationTraceEvent(string message, T0 args0) { if (Log.IsCorrelationEnabled()) { - CorrelationTrace(string.Format(message, args0, args1?.ToString() ?? "Null")); + CorrelationTrace(string.Format(message, args0?.ToString() ?? "Null", args1?.ToString() ?? "Null")); } } @@ -487,146 +670,201 @@ internal void CorrelationTraceEvent(string message, T0 args0) CorrelationTrace(string.Format(message, args0?.ToString() ?? "Null", args1?.ToString() ?? "Null", args2?.ToString() ?? "Null")); } } + #endregion + #region State Dump [NonEvent] - internal void NotificationsTraceEvent(string message) + internal void StateDumpEvent(string message, T0 args0, T1 args1) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsStateDumpEnabled()) { - NotificationsTrace(message); + StateDump(string.Format(message, args0, args1)); } } + #endregion + #region SNI Trace [NonEvent] - internal void NotificationsTraceEvent(string message, T0 args0) + internal void SNITraceEvent(string message) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsSNITraceEnabled()) { - NotificationsTrace(string.Format(message, args0)); + SNITrace(string.Format(message)); } } [NonEvent] - internal void NotificationsTraceEvent(string message, T0 args0, T1 args1) + internal void SNITraceEvent(string message, T0 args0) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsSNITraceEnabled()) { - NotificationsTrace(string.Format(message, args0, args1)); + SNITrace(string.Format(message, args0)); } } [NonEvent] - internal void NotificationsTraceEvent(string message, T0 args0, T1 args1, T2 args2) + internal void SNITraceEvent(string message, T0 args0, T1 args1) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsSNITraceEnabled()) { - NotificationsTrace(string.Format(message, args0, args1, args2)); + SNITrace(string.Format(message, args0, args1)); } } [NonEvent] - internal void NotificationsTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal void SNITraceEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsSNITraceEnabled()) { - NotificationsTrace(string.Format(message, args0, args1, args2, args3)); + SNITrace(string.Format(message, args0, args1, args2)); } } [NonEvent] - internal void TraceBinEvent(string message, T0 args0, T1 args1) + internal void SNITraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsTraceBinEnabled()) + if (Log.IsSNITraceEnabled()) { - TraceBin(string.Format(message, args0, args1)); + SNITrace(string.Format(message, args0, args1, args2, args3)); } } [NonEvent] - internal void StateDumpEvent(string message, T0 args0, T1 args1) + internal void SNITraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4) { - if (Log.IsStateDumpEnabled()) + if (Log.IsSNITraceEnabled()) { - Trace(string.Format(message, args0, args1)); + SNITrace(string.Format(message, args0, args1, args2, args3, args4)); } } + #endregion + #region SNI Scope [NonEvent] - internal void ScopeLeaveEvent(long scopeId) + internal long SNIScopeEnterEvent(string message) { - if (Log.IsScopeEnabled()) + if (Log.IsSNIScopeEnabled()) { - ScopeLeave(scopeId); + return SNIScopeEnter(message); } + return 0; } [NonEvent] - internal void NotificationsScopeLeaveEvent(long scopeId) + internal long SNIScopeEnterEvent(string message, T0 args0) { - if (Log.IsNotificationScopeEnabled()) + if (Log.IsSNIScopeEnabled()) { - ScopeLeave(scopeId); + return SNIScopeEnter(string.Format(message, args0)); } + return 0; } [NonEvent] - internal void PoolerScopeLeaveEvent(long scopeId) + internal long SNIScopeEnterEvent(string message, T0 args0, T1 args1) { - if (Log.IsPoolerScopeEnabled()) + if (Log.IsSNIScopeEnabled()) { - ScopeLeave(scopeId); + return SNIScopeEnter(string.Format(message, args0, args1)); } + return 0; } [NonEvent] - internal void AdvanceScopeLeave(long scopeId) + internal long SNIScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsSNIScopeEnabled()) { - ScopeLeave(scopeId); + return SNIScopeEnter(string.Format(message, args0, args1, args2)); + } + return 0; + } + + [NonEvent] + internal long SNIScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + { + if (Log.IsSNIScopeEnabled()) + { + return SNIScopeEnter(string.Format(message, args0, args1, args2, args3)); + } + return 0; + } + + [NonEvent] + internal void SNIScopeLeaveEvent(long scopeId) + { + if (Log.IsSNIScopeEnabled()) + { + SNIScopeLeave(scopeId); } } #endregion - #region Events + #endregion + + #region Write Events + [Event(BeginExecuteEventId, Keywords = Keywords.ExecutionTrace, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Start)] + internal void BeginExecute(int objectId, string dataSource, string database, string commandText) + { + if (Log.IsExecutionTraceEnabled()) + { + WriteEvent(BeginExecuteEventId, objectId, dataSource, database, commandText); + } + } + + [Event(EndExecuteEventId, Keywords = Keywords.ExecutionTrace, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Stop)] + internal void EndExecute(int objectId, int compositeState, int sqlExceptionNumber) + { + if (Log.IsExecutionTraceEnabled()) + { + WriteEvent(EndExecuteEventId, objectId, compositeState, sqlExceptionNumber); + } + } + [Event(TraceEventId, Level = EventLevel.Informational, Keywords = Keywords.Trace)] internal void Trace(string message) { WriteEvent(TraceEventId, message); } - [Event(EnterScopeId, Level = EventLevel.Verbose, Keywords = Keywords.Scope)] - internal long SNIScopeEnter(string message) + [Event(ScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.Scope)] + internal long ScopeEnter(string message) { long scopeId = Interlocked.Increment(ref s_nextScopeId); - WriteEvent(EnterScopeId, message); + WriteEvent(ScopeEnterId, message); return scopeId; } - [Event(ExitScopeId, Level = EventLevel.Verbose, Keywords = Keywords.Scope)] + [Event(ScopeExitId, Level = EventLevel.Informational, Opcode = EventOpcode.Stop, Keywords = Keywords.Scope)] internal void ScopeLeave(long scopeId) { - WriteEvent(ExitScopeId, scopeId); + WriteEvent(ScopeExitId, scopeId); } - [Event(TraceBinId, Level = EventLevel.Informational, Keywords = Keywords.Trace)] - internal void TraceBin(string message) + [Event(NotificationTraceId, Level = EventLevel.Informational, Keywords = Keywords.NotificationTrace)] + internal void NotificationTrace(string message) { - WriteEvent(TraceBinId, message); + WriteEvent(NotificationTraceId, message); } - [Event(CorrelationTraceId, Level = EventLevel.Informational, Keywords = Keywords.Correlation, Opcode = EventOpcode.Start)] - internal void CorrelationTrace(string message) + [Event(NotificationScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.NotificationScope)] + internal long NotificationScopeEnter(string message) { - WriteEvent(CorrelationTraceId, message); + long scopeId = Interlocked.Increment(ref s_nextNotificationScopeId); + WriteEvent(NotificationScopeEnterId, message); + return scopeId; } - [Event(NotificationsScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.NotificationScope)] - internal long NotificationsScopeEnter(string message) + [Event(NotificationScopeExitId, Level = EventLevel.Informational, Opcode = EventOpcode.Stop, Keywords = Keywords.NotificationScope)] + internal void NotificationScopeLeave(long scopeId) { - long scopeId = Interlocked.Increment(ref s_nextNotificationScopeId); - WriteEvent(NotificationsScopeEnterId, message); - return scopeId; + WriteEvent(NotificationScopeExitId, scopeId); + } + + [Event(PoolerTraceId, Level = EventLevel.Informational, Keywords = Keywords.PoolerTrace)] + internal void PoolerTrace(string message) + { + WriteEvent(PoolerTraceId, message); } [Event(PoolerScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.PoolerScope)] @@ -637,44 +875,74 @@ internal long PoolerScopeEnter(string message) return scopeId; } - [Event(NotificationsTraceId, Level = EventLevel.Informational, Keywords = Keywords.Trace)] - internal void NotificationsTrace(string message) + [Event(PoolerScopeExitId, Level = EventLevel.Informational, Opcode = EventOpcode.Stop, Keywords = Keywords.PoolerScope)] + internal void PoolerScopeLeave(long scopeId) { - WriteEvent(NotificationsTraceId, message); + WriteEvent(PoolerScopeExitId, scopeId); } - [Event(PoolerTraceId, Level = EventLevel.Informational, Keywords = Keywords.PoolerTrace)] - internal void PoolerTrace(string message) + [Event(AdvancedTraceId, Level = EventLevel.Verbose, Keywords = Keywords.AdvancedTrace)] + internal void AdvancedTrace(string message) { - WriteEvent(PoolerTraceId, message); + WriteEvent(AdvancedTraceId, message); } - // unfortunately these are not marked as Start/Stop opcodes. The reason is that we dont want them to participate in - // the EventSource activity IDs (because they currently don't use tasks and this simply confuses the logic) and - // because of versioning requirements we don't have ActivityOptions capability (because mscorlib and System.Data version - // at different rates) Sigh... - [Event(BeginExecuteEventId, Keywords = Keywords.SqlClient, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Start)] - public void BeginExecute(int objectId, string dataSource, string database, string commandText) + [Event(AdvancedScopeEnterId, Level = EventLevel.Verbose, Opcode = EventOpcode.Start, Keywords = Keywords.AdvancedTrace)] + internal long AdvancedScopeEnter(string message) { - // we do not use unsafe code for better performance optization here because optimized helpers make the code unsafe where that would not be the case otherwise. - // This introduces the question of partial trust, which is complex in the SQL case (there are a lot of scenarios and SQL has special security support). - if (Log.IsSqlClientEnabled()) - { - WriteEvent(BeginExecuteEventId, objectId, dataSource, database, commandText); - } + long scopeId = Interlocked.Increment(ref s_nextScopeId); + WriteEvent(AdvancedScopeEnterId, message); + return scopeId; } - // unfortunately these are not marked as Start/Stop opcodes. The reason is that we dont want them to participate in - // the EventSource activity IDs (because they currently don't use tasks and this simply confuses the logic) and - // because of versioning requirements we don't have ActivityOptions capability (because mscorlib and System.Data version - // at different rates) Sigh... - [Event(EndExecuteEventId, Keywords = Keywords.SqlClient, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Stop)] - public void EndExecute(int objectId, int compositeState, int sqlExceptionNumber) + [Event(AdvancedScopeExitId, Level = EventLevel.Verbose, Opcode = EventOpcode.Stop, Keywords = Keywords.AdvancedTrace)] + internal void AdvancedScopeLeave(long scopeId) { - if (Log.IsSqlClientEnabled()) - { - WriteEvent(EndExecuteEventId, objectId, compositeState, sqlExceptionNumber); - } + WriteEvent(AdvancedScopeExitId, scopeId); + } + + [Event(AdvancedTraceBinId, Level = EventLevel.Verbose, Keywords = Keywords.AdvancedTraceBin)] + internal void AdvancedTraceBin(string message) + { + WriteEvent(AdvancedTraceBinId, message); + } + + [Event(AdvancedTraceErrorId, Level = EventLevel.Error, Keywords = Keywords.AdvancedTrace)] + internal void AdvancedTraceError(string message) + { + WriteEvent(AdvancedTraceErrorId, message); + } + + [Event(CorrelationTraceId, Level = EventLevel.Informational, Keywords = Keywords.CorrelationTrace, Opcode = EventOpcode.Start)] + internal void CorrelationTrace(string message) + { + WriteEvent(CorrelationTraceId, message); + } + + [Event(StateDumpEventId, Level = EventLevel.Verbose, Keywords = Keywords.StateDump)] + internal void StateDump(string message) + { + WriteEvent(StateDumpEventId, message); + } + + [Event(SNITraceEventId, Level = EventLevel.Informational, Keywords = Keywords.SNITrace)] + internal void SNITrace(string message) + { + WriteEvent(SNITraceEventId, message); + } + + [Event(SNIScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.SNIScope)] + internal long SNIScopeEnter(string message) + { + long scopeId = Interlocked.Increment(ref s_nextSNIScopeId); + WriteEvent(SNIScopeEnterId, message); + return scopeId; + } + + [Event(SNIScopeExitId, Level = EventLevel.Informational, Opcode = EventOpcode.Stop, Keywords = Keywords.SNIScope)] + internal void SNIScopeLeave(long scopeId) + { + WriteEvent(SNIScopeExitId, scopeId); } #endregion } 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 3c19bbeeac..a6c9b53dc6 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 @@ -414,7 +414,7 @@ private SqlCommand(SqlCommand from) : this() } _activeConnection = value; - SqlClientEventSource.Log.TraceEvent(" {0}#, {1}#", ObjectID, (null != value) ? value.ObjectID : -1); + SqlClientEventSource.Log.TraceEvent(" {0}, {1}", ObjectID, (null != value) ? value.ObjectID : -1); } } @@ -448,7 +448,7 @@ public SqlNotificationRequest Notification } set { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); _sqlDep = null; _notification = value; } @@ -492,7 +492,7 @@ internal SqlStatistics Statistics throw SQL.CannotModifyPropertyAsyncOperationInProgress(); } } - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); _transaction = value; } } @@ -520,7 +520,7 @@ override public string CommandText } set { - SqlClientEventSource.Log.TraceEvent(" {0}#, String Value = '{1}'", ObjectID, value); + SqlClientEventSource.Log.TraceEvent(" {0}, String Value = '{1}'", ObjectID, value); if (_commandText != value) { PropertyChanging(); @@ -541,7 +541,7 @@ override public int CommandTimeout } set { - SqlClientEventSource.Log.TraceEvent(" {0}#, {1}", ObjectID, value); + SqlClientEventSource.Log.TraceEvent(" {0}, {1}", ObjectID, value); if (value < 0) { throw ADP.InvalidCommandTimeout(value); @@ -574,7 +574,7 @@ override public CommandType CommandType } set { - SqlClientEventSource.Log.TraceEvent(" {0}#, {1}{2}", ObjectID, (int)value, _commandType); + SqlClientEventSource.Log.TraceEvent(" {0}, {1}{2}", ObjectID, (int)value, _commandType); if (_commandType != value) { switch (value) @@ -679,7 +679,7 @@ internal void OnStatementCompleted(int recordCount) { try { - SqlClientEventSource.Log.TraceEvent(" {0}#, recordCount={1}", ObjectID, recordCount); + SqlClientEventSource.Log.TraceEvent(" {0}, recordCount={1}", ObjectID, recordCount); handler(this, new StatementCompletedEventArgs(recordCount)); } catch (Exception e) @@ -706,8 +706,8 @@ override public void Prepare() _pendingCancel = false; SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -821,7 +821,7 @@ internal void Unprepare() } _cachedMetaData = null; - SqlClientEventSource.Log.TraceEvent(" {0}#, Command unprepared.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command unprepared.", ObjectID); } // Cancel is supposed to be multi-thread safe. @@ -831,8 +831,8 @@ internal void Unprepare() /// override public void Cancel() { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); SqlStatistics statistics = null; try { @@ -947,8 +947,8 @@ override public object ExecuteScalar() SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Exception e = null; bool success = false; @@ -1031,8 +1031,8 @@ override public int ExecuteNonQuery() SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Exception e = null; try { @@ -1070,7 +1070,7 @@ public IAsyncResult BeginExecuteNonQuery() /// public IAsyncResult BeginExecuteNonQuery(AsyncCallback callback, object stateObject) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); return BeginExecuteNonQueryInternal(0, callback, stateObject, 0, inRetry: false); } @@ -1267,7 +1267,7 @@ public int EndExecuteNonQuery(IAsyncResult asyncResult) } finally { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); } } @@ -1286,7 +1286,7 @@ private void ThrowIfReconnectionHasBeenCanceled() /// public int EndExecuteNonQueryAsync(IAsyncResult asyncResult) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Debug.Assert(!_internalEndExecuteInitiated || _stateObj == null); Exception asyncException = ((Task)asyncResult).Exception; @@ -1486,7 +1486,7 @@ private Task InternalExecuteNonQuery(TaskCompletionSource completion, bo { // otherwise, use a full-fledged execute that can handle params and stored procs Debug.Assert(!sendToPipe, "trying to send non-context command to pipe"); - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as RPC.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as RPC.", ObjectID); SqlDataReader reader = RunExecuteReader(0, RunBehavior.UntilDone, false, completion, timeout, out task, out usedCache, asyncWrite, inRetry, methodName); if (null != reader) @@ -1520,8 +1520,8 @@ public XmlReader ExecuteXmlReader() Guid operationId = _diagnosticListener.WriteCommandBefore(this); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); int? sqlExceptionNumber = null; Exception e = null; @@ -1572,7 +1572,7 @@ public IAsyncResult BeginExecuteXmlReader() /// public IAsyncResult BeginExecuteXmlReader(AsyncCallback callback, object stateObject) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); return BeginExecuteXmlReaderInternal(CommandBehavior.SequentialAccess, callback, stateObject, 0, inRetry: false); } @@ -1695,13 +1695,13 @@ public XmlReader EndExecuteXmlReader(IAsyncResult asyncResult) } finally { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); } } private XmlReader EndExecuteXmlReaderAsync(IAsyncResult asyncResult) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Debug.Assert(!_internalEndExecuteInitiated || _stateObj == null); Exception asyncException = ((Task)asyncResult).Exception; @@ -1808,14 +1808,14 @@ private XmlReader CompleteXmlReader(SqlDataReader ds, bool isAsync = false) /// public IAsyncResult BeginExecuteReader(AsyncCallback callback, object stateObject, CommandBehavior behavior) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); return BeginExecuteReaderInternal(behavior, callback, stateObject, 0, inRetry: false); } /// override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); return ExecuteReader(behavior); } @@ -1823,8 +1823,8 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) new public SqlDataReader ExecuteReader() { SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -1891,14 +1891,14 @@ public SqlDataReader EndExecuteReader(IAsyncResult asyncResult) } finally { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); } } internal SqlDataReader EndExecuteReaderAsync(IAsyncResult asyncResult) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Debug.Assert(!_internalEndExecuteInitiated || _stateObj == null); Exception asyncException = ((Task)asyncResult).Exception; @@ -2247,7 +2247,7 @@ private SqlDataReader InternalEndExecuteReader(IAsyncResult asyncResult, bool is /// public override Task ExecuteNonQueryAsync(CancellationToken cancellationToken) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Guid operationId = _diagnosticListener.WriteCommandBefore(this); TaskCompletionSource source = new TaskCompletionSource(); @@ -2334,7 +2334,7 @@ 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); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); Guid operationId = default(Guid); if (!_parentOperationStarted) operationId = _diagnosticListener.WriteCommandBefore(this); @@ -2485,7 +2485,7 @@ public Task ExecuteXmlReaderAsync() /// public Task ExecuteXmlReaderAsync(CancellationToken cancellationToken) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Guid operationId = _diagnosticListener.WriteCommandBefore(this); TaskCompletionSource source = new TaskCompletionSource(); @@ -3027,7 +3027,7 @@ private Task RunExecuteNonQueryTds(string methodName, bool isAsync, int timeout, // no parameters are sent over // no data reader is returned // use this overload for "batch SQL" tds token type - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as SQLBATCH.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as SQLBATCH.", ObjectID); Task executeTask = _stateObj.Parser.TdsExecuteSQLBatch(this.CommandText, timeout, this.Notification, _stateObj, sync: true); Debug.Assert(executeTask == null, "Shouldn't get a task when doing sync writes"); @@ -4377,7 +4377,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi if (returnStream) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as SQLBATCH.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as SQLBATCH.", ObjectID); } string text = GetCommandText(cmdBehavior) + GetResetOptionsString(cmdBehavior); //If the query requires enclave computations, pass the enclavepackage in the SQLBatch TDS stream @@ -4438,7 +4438,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi rpc.options = TdsEnums.RPC_NOMETADATA; if (returnStream) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as RPC.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as RPC.", ObjectID); } Debug.Assert(_rpcArrayOf1[0] == rpc); @@ -4456,7 +4456,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi optionSettings = GetSetOptionsString(cmdBehavior); if (returnStream) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as RPC.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as RPC.", ObjectID); } // turn set options ON @@ -6121,13 +6121,13 @@ private void NotifyDependency() public SqlCommand Clone() { SqlCommand clone = new SqlCommand(this); - SqlClientEventSource.Log.TraceEvent(" {0}#, clone={1}#", ObjectID, clone.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, clone={1}", ObjectID, clone.ObjectID); return clone; } private void WriteEndExecuteEvent(bool success, int? sqlExceptionNumber, bool synchronous) { - if (SqlClientEventSource.Log.IsSqlClientEnabled()) + if (SqlClientEventSource.Log.IsExecutionTraceEnabled()) { // SqlEventSource.WriteEvent(int, int, int, int) is faster than provided overload SqlEventSource.WriteEvent(int, object[]). // that's why trying to fit several booleans in one integer value diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommandSet.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommandSet.cs index df1d0b706e..18c1938401 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommandSet.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommandSet.cs @@ -116,7 +116,7 @@ internal int ObjectID internal void Append(SqlCommand command) { ADP.CheckArgumentNull(command, nameof(command)); - SqlClientEventSource.Log.TraceEvent(" {0}#, command={1}, parameterCount={2}", ObjectID, command.ObjectID, command.Parameters.Count); + SqlClientEventSource.Log.TraceEvent(" {0}, command={1}, parameterCount={2}", ObjectID, command.ObjectID, command.Parameters.Count); string cmdText = command.CommandText; if (string.IsNullOrEmpty(cmdText)) { @@ -248,7 +248,7 @@ internal static void BuildStoredProcedureName(StringBuilder builder, string part internal void Clear() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); DbCommand batchCommand = BatchCommand; if (null != batchCommand) { @@ -264,7 +264,7 @@ internal void Clear() internal void Dispose() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); SqlCommand command = _batchCommand; _commandList = null; _batchCommand = null; @@ -278,7 +278,7 @@ internal void Dispose() internal int ExecuteNonQuery() { ValidateCommandBehavior(nameof(ExecuteNonQuery), CommandBehavior.Default); - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { 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 7638f2a7aa..bad9865bbd 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 @@ -782,7 +782,7 @@ public SqlTransaction BeginTransaction(string transactionName) [SuppressMessage("Microsoft.Reliability", "CA2004:RemoveCallsToGCKeepAlive")] override protected DbTransaction BeginDbTransaction(System.Data.IsolationLevel isolationLevel) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#, isolationLevel={1}", ObjectID, (int)isolationLevel); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}, isolationLevel={1}", ObjectID, (int)isolationLevel); try { DbTransaction transaction = BeginTransaction(isolationLevel); @@ -806,7 +806,7 @@ public SqlTransaction BeginTransaction(System.Data.IsolationLevel iso, string tr { WaitForPendingReconnection(); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#, iso={1}, transactionName='{2}'", ObjectID, (int)iso, (string.IsNullOrEmpty(transactionName) ? "None" : transactionName)); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}, iso={1}, transactionName='{2}'", ObjectID, (int)iso, (string.IsNullOrEmpty(transactionName) ? "None" : transactionName)); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -840,7 +840,7 @@ public override void ChangeDatabase(string database) { SqlStatistics statistics = null; RepairInnerConnection(); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -885,8 +885,8 @@ private void CloseInnerConnection() /// public override void Close() { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); try { ConnectionState previousState = State; @@ -1000,7 +1000,7 @@ private void DisposeMe(bool disposing) public override void Open() { long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); try { Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this); @@ -1267,8 +1267,8 @@ private void CancelOpenAndWait() /// public override Task OpenAsync(CancellationToken cancellationToken) { - long scopeID = SqlClientEventSource.Log.PoolerScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + long scopeID = SqlClientEventSource.Log.PoolerScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); try { Guid operationId = s_diagnosticListener.WriteConnectionOpenBefore(this); @@ -1395,7 +1395,7 @@ public OpenAsyncRetry(SqlConnection parent, TaskCompletionSource retryTask) { - SqlClientEventSource.Log.TraceEvent(" {0}#", _parent.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", _parent.ObjectID); _registration.Dispose(); try { @@ -1653,7 +1653,7 @@ internal void OnError(SqlException exception, bool breakConnection, Action {0}#, Connection broken.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection broken.", ObjectID); Close(); } }; @@ -1662,7 +1662,7 @@ internal void OnError(SqlException exception, bool breakConnection, Action {0}#, Connection broken.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection broken.", ObjectID); Close(); } } @@ -1713,7 +1713,7 @@ internal void OnInfoMessage(SqlInfoMessageEventArgs imevent) internal void OnInfoMessage(SqlInfoMessageEventArgs imevent, out bool notified) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Message='{1}'", ObjectID, (null != imevent) ? imevent.Message : ""); + SqlClientEventSource.Log.TraceEvent(" {0}, Message='{1}'", ObjectID, (null != imevent) ? imevent.Message : ""); SqlInfoMessageEventHandler handler = InfoMessage; if (null != handler) { diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs index 2fa1a8481a..1a6f944a6c 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionHelper.cs @@ -60,7 +60,7 @@ internal DbConnectionOptions ConnectionOptions private string ConnectionString_Get() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); bool hidePassword = InnerConnection.ShouldHidePassword; DbConnectionOptions connectionOptions = UserConnectionOptions; return ((null != connectionOptions) ? connectionOptions.UsersConnectionString(hidePassword) : ""); @@ -87,7 +87,7 @@ private void ConnectionString_Set(DbConnectionPoolKey key) throw ADP.OpenConnectionPropertySet(nameof(ConnectionString), connectionInternal.State); } string cstr = ((null != connectionOptions) ? connectionOptions.UsersConnectionStringForTrace() : ""); - SqlClientEventSource.Log.TraceEvent(" {0}#, '{1}'", ObjectID, cstr); + SqlClientEventSource.Log.TraceEvent(" {0}, '{1}'", ObjectID, cstr); } internal DbConnectionInternal InnerConnection @@ -135,11 +135,11 @@ internal void Abort(Exception e) // will end the reliable try... if (e is OutOfMemoryException) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Aborting operation due to asynchronous exception: {'OutOfMemory'}", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Aborting operation due to asynchronous exception: {'OutOfMemory'}", ObjectID); } else { - SqlClientEventSource.Log.TraceEvent(" {0}#, Aborting operation due to asynchronous exception: {1}", ObjectID, e); + SqlClientEventSource.Log.TraceEvent(" {0}, Aborting operation due to asynchronous exception: {1}", ObjectID, e); } } @@ -151,7 +151,7 @@ internal void AddWeakReference(object value, int tag) /// override protected DbCommand CreateDbCommand() { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { DbCommand command = null; @@ -184,7 +184,7 @@ override protected void Dispose(bool disposing) /// public override void EnlistTransaction(Transaction transaction) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection enlisting in a transaction.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection enlisting in a transaction.", ObjectID); // If we're currently enlisted in a transaction and we were called // on the EnlistTransaction method (Whidbey) we're not allowed to diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs index 42bd34b435..273cfcd9f8 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs @@ -127,7 +127,7 @@ public override int UpdateBatchSize throw ADP.ArgumentOutOfRange(nameof(UpdateBatchSize)); } _updateBatchSize = value; - SqlClientEventSource.Log.TraceEvent(" {0}#, {1}", ObjectID, value); + SqlClientEventSource.Log.TraceEvent(" {0}, {1}", ObjectID, value); } } @@ -149,7 +149,7 @@ protected override void ClearBatch() protected override int ExecuteBatch() { Debug.Assert(null != _commandSet && (0 < _commandSet.CommandCount), "no commands"); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); return _commandSet.ExecuteNonQuery(); } @@ -172,7 +172,7 @@ protected override bool GetBatchedRecordsAffected(int commandIdentifier, out int /// protected override void InitializeBatching() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); _commandSet = new SqlCommandSet(); SqlCommand command = SelectCommand; if (null == command) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs index c9102e87cb..61efb7609f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDataReader.cs @@ -844,7 +844,7 @@ protected override void Dispose(bool disposing) /// public override void Close() { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); SqlStatistics statistics = null; try { @@ -1467,7 +1467,7 @@ override public int GetProviderSpecificValues(object[] values) public override DataTable GetSchemaTable() { SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -3261,7 +3261,7 @@ override public bool NextResult() private bool TryNextResult(out bool more) { SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -3422,7 +3422,7 @@ override public bool Read() private bool TryReadInternal(bool setTimeout, out bool more) { SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -3953,7 +3953,7 @@ private void RestoreServerSettings(TdsParser parser, TdsParserStateObject stateO // broken connection, so check state first. if (parser.State == TdsParserState.OpenLoggedIn) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID '{1}'", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID '{1}'", ObjectID, ActivityCorrelator.Current.ToString()); Task executeTask = parser.TdsExecuteSQLBatch(_resetOptionsString, (_command != null) ? _command.CommandTimeout : 0, null, stateObj, sync: true); Debug.Assert(executeTask == null, "Shouldn't get a task when doing sync writes"); @@ -4258,7 +4258,7 @@ private void AssertReaderState(bool requireData, bool permitAsync, int? columnIn /// public override Task NextResultAsync(CancellationToken cancellationToken) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { TaskCompletionSource source = new TaskCompletionSource(); @@ -4308,7 +4308,7 @@ private static Task NextResultAsyncExecute(Task task, object state) HasNextResultAsyncCallContext context = (HasNextResultAsyncCallContext)state; if (task != null) { - SqlClientEventSource.Log.TraceEvent(" attempt retry {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" attempt retry {0}", ObjectID); context._reader.PrepareForAsyncContinuation(); } @@ -4584,7 +4584,7 @@ private Task GetBytesAsyncReadDataStage(GetBytesAsyncCallContext context, b /// public override Task ReadAsync(CancellationToken cancellationToken) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { if (IsClosed) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs index fb4d16c502..acfe827b48 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs @@ -80,13 +80,13 @@ public void Initialize() // transaction. SqlInternalConnection connection = _connection; SqlConnection usersConnection = connection.Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, delegating transaction.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, delegating transaction.", ObjectID, connection.ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try { if (connection.IsEnlistedInTransaction) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, was enlisted, now defecting.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, was enlisted, now defecting.", ObjectID, connection.ObjectID); // defect first connection.EnlistNull(); @@ -141,7 +141,7 @@ public byte[] Promote() Exception promoteException; byte[] returnValue = null; SqlConnection usersConnection = connection.Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, promoting transaction.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, promoting transaction.", ObjectID, connection.ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try { @@ -220,7 +220,7 @@ public void Rollback(SinglePhaseEnlistment enlistment) SqlInternalConnection connection = GetValidConnection(); SqlConnection usersConnection = connection.Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, aborting transaction.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, aborting transaction.", ObjectID, connection.ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try { @@ -293,7 +293,7 @@ public void SinglePhaseCommit(SinglePhaseEnlistment enlistment) SqlInternalConnection connection = GetValidConnection(); SqlConnection usersConnection = connection.Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, committing transaction.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, committing transaction.", ObjectID, connection.ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try { @@ -404,7 +404,7 @@ internal void TransactionEnded(Transaction transaction) if (connection != null) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, transaction completed externally.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, transaction completed externally.", ObjectID, connection.ObjectID); lock (connection) { if (_atomicTransaction.Equals(transaction)) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependency.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependency.cs index fe24cdd944..c521b0906d 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependency.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependency.cs @@ -245,7 +245,7 @@ public SqlDependency(SqlCommand command) : this(command, null, SQL.SqlDependency /// public SqlDependency(SqlCommand command, string options, int timeout) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, options: '{1}', timeout: '{2}'", ObjectID, options, timeout); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, options: '{1}', timeout: '{2}'", ObjectID, options, timeout); try { if (timeout < 0) @@ -264,7 +264,7 @@ public SqlDependency(SqlCommand command, string options, int timeout) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -294,7 +294,7 @@ public SqlDependency(SqlCommand command, string options, int timeout) // EventHandlers to be fired when dependency is notified. add { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { if (null != value) @@ -329,12 +329,12 @@ public SqlDependency(SqlCommand command, string options, int timeout) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } remove { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { if (null != value) @@ -352,7 +352,7 @@ public SqlDependency(SqlCommand command, string options, int timeout) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } @@ -362,7 +362,7 @@ public SqlDependency(SqlCommand command, string options, int timeout) public void AddCommandDependency(SqlCommand command) { // Adds command to dependency collection so we automatically create the SqlNotificationsRequest object - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { // and listen for a notification for the added commands. @@ -375,7 +375,7 @@ public void AddCommandDependency(SqlCommand command) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -396,7 +396,7 @@ public static bool Start(string connectionString, string queue) internal static bool Start(string connectionString, string queue, bool useDefaults) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" AppDomainKey: '{0}', queue: '{1}'", AppDomainKey, queue); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" AppDomainKey: '{0}', queue: '{1}'", AppDomainKey, queue); try { if (string.IsNullOrEmpty(connectionString)) @@ -455,7 +455,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul SqlDependencyPerAppDomainDispatcher.SingletonInstance, out errorOccurred, out appDomainStart); - SqlClientEventSource.Log.NotificationsTraceEvent(" Start (defaults) returned: '{0}', with service: '{1}', server: '{2}', database: '{3}'", result, service, server, database); + SqlClientEventSource.Log.NotificationTraceEvent(" Start (defaults) returned: '{0}', with service: '{1}', server: '{2}', database: '{3}'", result, service, server, database); } finally { @@ -477,7 +477,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul } ADP.TraceExceptionWithoutRethrow(e); // Discard failure, but trace for now. - SqlClientEventSource.Log.NotificationsTrace(" Exception occurred from Stop() after duplicate was found on Start()."); + SqlClientEventSource.Log.NotificationTraceEvent(" Exception occurred from Stop() after duplicate was found on Start()."); } throw SQL.SqlDependencyDuplicateStart(); } @@ -491,7 +491,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul queue, s_appDomainKey, SqlDependencyPerAppDomainDispatcher.SingletonInstance); - SqlClientEventSource.Log.NotificationsTraceEvent(" Start (user provided queue) returned: '{0}'", result); + SqlClientEventSource.Log.NotificationTraceEvent(" Start (user provided queue) returned: '{0}'", result); // No need to call AddToServerDatabaseHash since if not using default queue user is required // to provide options themselves. @@ -505,7 +505,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul } ADP.TraceExceptionWithoutRethrow(e); // Discard failure, but trace for now. - SqlClientEventSource.Log.NotificationsTraceEvent(" Exception occurred from _processDispatcher.Start(...), calling Invalidate(...)."); + SqlClientEventSource.Log.NotificationTraceEvent(" Exception occurred from _processDispatcher.Start(...), calling Invalidate(...)."); throw; } } @@ -514,7 +514,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -532,7 +532,7 @@ public static bool Stop(string connectionString, string queue) internal static bool Stop(string connectionString, string queue, bool useDefaults, bool startFailed) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" AppDomainKey: '{0}', queue: '{1}'", AppDomainKey, queue); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" AppDomainKey: '{0}', queue: '{1}'", AppDomainKey, queue); try { if (string.IsNullOrEmpty(connectionString)) @@ -628,7 +628,7 @@ internal static bool Stop(string connectionString, string queue, bool useDefault } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -636,7 +636,7 @@ internal static bool Stop(string connectionString, string queue, bool useDefault private static bool AddToServerUserHash(string server, IdentityUserNamePair identityUser, DatabaseServicePair databaseService) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" server: '{0}', database: '{1}', service: '{2}'", server, databaseService.Database, databaseService.Service); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" server: '{0}', database: '{1}', service: '{2}'", server, databaseService.Database, databaseService.Service); try { bool result = false; @@ -647,7 +647,7 @@ private static bool AddToServerUserHash(string server, IdentityUserNamePair iden if (!s_serverUserHash.ContainsKey(server)) { - SqlClientEventSource.Log.NotificationsTrace(" Hash did not contain server, adding."); + SqlClientEventSource.Log.NotificationTraceEvent(" Hash did not contain server, adding."); identityDatabaseHash = new Dictionary>(); s_serverUserHash.Add(server, identityDatabaseHash); } @@ -660,7 +660,7 @@ private static bool AddToServerUserHash(string server, IdentityUserNamePair iden if (!identityDatabaseHash.ContainsKey(identityUser)) { - SqlClientEventSource.Log.NotificationsTrace(" Hash contained server but not user, adding user."); + SqlClientEventSource.Log.NotificationTraceEvent(" Hash contained server but not user, adding user."); databaseServiceList = new List(); identityDatabaseHash.Add(identityUser, databaseServiceList); } @@ -671,13 +671,13 @@ private static bool AddToServerUserHash(string server, IdentityUserNamePair iden if (!databaseServiceList.Contains(databaseService)) { - SqlClientEventSource.Log.NotificationsTrace(" Adding database."); + SqlClientEventSource.Log.NotificationTraceEvent(" Adding database."); databaseServiceList.Add(databaseService); result = true; } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - hash already contained server, user, and database - we will throw!."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - hash already contained server, user, and database - we will throw!."); } } @@ -685,13 +685,13 @@ private static bool AddToServerUserHash(string server, IdentityUserNamePair iden } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private static void RemoveFromServerUserHash(string server, IdentityUserNamePair identityUser, DatabaseServicePair databaseService) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" server: '{0}', database: '{1}', service: '{2}'", server, databaseService.Database, databaseService.Service); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" server: '{0}', database: '{1}', service: '{2}'", server, databaseService.Database, databaseService.Service); try { lock (s_serverUserHash) @@ -711,43 +711,43 @@ private static void RemoveFromServerUserHash(string server, IdentityUserNamePair int index = databaseServiceList.IndexOf(databaseService); if (index >= 0) { - SqlClientEventSource.Log.NotificationsTrace(" Hash contained server, user, and database - removing database."); + SqlClientEventSource.Log.NotificationTraceEvent(" Hash contained server, user, and database - removing database."); databaseServiceList.RemoveAt(index); if (databaseServiceList.Count == 0) { - SqlClientEventSource.Log.NotificationsTrace(" databaseServiceList count 0, removing the list for this server and user."); + SqlClientEventSource.Log.NotificationTraceEvent(" databaseServiceList count 0, removing the list for this server and user."); identityDatabaseHash.Remove(identityUser); if (identityDatabaseHash.Count == 0) { - SqlClientEventSource.Log.NotificationsTrace(" identityDatabaseHash count 0, removing the hash for this server."); + SqlClientEventSource.Log.NotificationTraceEvent(" identityDatabaseHash count 0, removing the hash for this server."); s_serverUserHash.Remove(server); } } } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - hash contained server and user but not database!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - hash contained server and user but not database!"); Debug.Fail("Unexpected state - hash did not contain database!"); } } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - hash contained server but not user!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - hash contained server but not user!"); Debug.Fail("Unexpected state - hash did not contain user!"); } } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - hash did not contain server!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - hash did not contain server!"); Debug.Fail("Unexpected state - hash did not contain server!"); } } } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -755,7 +755,7 @@ internal static string GetDefaultComposedOptions(string server, string failoverS { // Server must be an exact match, but user and database only needs to match exactly if there is more than one // for the given user or database passed. That is ambiguious and we must fail. - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" server: '{0}', failoverServer: '{1}', database: '{2}'", server, failoverServer, database); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" server: '{0}', failoverServer: '{1}', database: '{2}'", server, failoverServer, database); try { string result; @@ -767,17 +767,17 @@ internal static string GetDefaultComposedOptions(string server, string failoverS if (0 == s_serverUserHash.Count) { // Special error for no calls to start. - SqlClientEventSource.Log.NotificationsTrace(" ERROR - no start calls have been made, about to throw."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - no start calls have been made, about to throw."); throw SQL.SqlDepDefaultOptionsButNoStart(); } else if (!string.IsNullOrEmpty(failoverServer) && s_serverUserHash.ContainsKey(failoverServer)) { - SqlClientEventSource.Log.NotificationsTrace(" using failover server instead\n"); + SqlClientEventSource.Log.NotificationTraceEvent(" using failover server instead\n"); server = failoverServer; } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - not listening to this server, about to throw."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - not listening to this server, about to throw."); throw SQL.SqlDependencyNoMatchingServerStart(); } } @@ -790,7 +790,7 @@ internal static string GetDefaultComposedOptions(string server, string failoverS { if (identityDatabaseHash.Count > 1) { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - not listening for this user, " + + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - not listening for this user, " + "but listening to more than one other user, about to throw."); throw SQL.SqlDependencyNoMatchingServerStart(); } @@ -839,19 +839,19 @@ internal static string GetDefaultComposedOptions(string server, string failoverS else { // More than one database for given server, ambiguous - fail the default case! - SqlClientEventSource.Log.NotificationsTrace(" ERROR - SqlDependency.Start called multiple times for this server/user, but no matching database."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - SqlDependency.Start called multiple times for this server/user, but no matching database."); throw SQL.SqlDependencyNoMatchingServerDatabaseStart(); } } } Debug.Assert(!string.IsNullOrEmpty(result), "GetDefaultComposedOptions should never return null or empty string!"); - SqlClientEventSource.Log.NotificationsTraceEvent(" resulting options: '{0}'.", result); + SqlClientEventSource.Log.NotificationTraceEvent(" resulting options: '{0}'.", result); return result; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -861,7 +861,7 @@ internal static string GetDefaultComposedOptions(string server, string failoverS // use this list for a reverse lookup based on server. internal void AddToServerList(string server) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, server: '{1}'", ObjectID, server); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, server: '{1}'", ObjectID, server); try { lock (_serverList) @@ -877,7 +877,7 @@ internal void AddToServerList(string server) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -891,7 +891,7 @@ internal bool ContainsServer(string server) internal string ComputeHashAndAddToDispatcher(SqlCommand command) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlCommand: {1}#", ObjectID, command.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlCommand: {1}", ObjectID, command.ObjectID); try { // Create a string representing the concatenation of the connection string, command text and .ToString on all parameter values. @@ -903,18 +903,18 @@ internal string ComputeHashAndAddToDispatcher(SqlCommand command) string commandHash = ComputeCommandHash(command.Connection.ConnectionString, command); // calculate the string representation of command string idString = SqlDependencyPerAppDomainDispatcher.SingletonInstance.AddCommandEntry(commandHash, this); // Add to map. - SqlClientEventSource.Log.NotificationsTraceEvent(" computed id string: '{0}'.", idString); + SqlClientEventSource.Log.NotificationTraceEvent(" computed id string: '{0}'.", idString); return idString; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } internal void Invalidate(SqlNotificationType type, SqlNotificationInfo info, SqlNotificationSource source) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { List eventList = null; @@ -928,7 +928,7 @@ internal void Invalidate(SqlNotificationType type, SqlNotificationInfo info, Sql if (ExpirationTime >= DateTime.UtcNow) { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - notification received twice - we should never enter this state!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - notification received twice - we should never enter this state!"); Debug.Fail("Received notification twice - we should never enter this state!"); } else @@ -937,7 +937,7 @@ internal void Invalidate(SqlNotificationType type, SqlNotificationInfo info, Sql // raises Timeout event but before removing this event from the list. If notification is received from // server in this case, we will hit this code path. // It is safe to ignore this race condition because no event is sent to user and no leak happens. - SqlClientEventSource.Log.NotificationsTrace(" ignore notification received after timeout!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ignore notification received after timeout!"); } } else @@ -951,7 +951,7 @@ internal void Invalidate(SqlNotificationType type, SqlNotificationInfo info, Sql if (eventList != null) { - SqlClientEventSource.Log.NotificationsTrace(" Firing events."); + SqlClientEventSource.Log.NotificationTraceEvent(" Firing events."); foreach (EventContextPair pair in eventList) { pair.Invoke(new SqlNotificationEventArgs(type, info, source)); @@ -960,14 +960,14 @@ internal void Invalidate(SqlNotificationType type, SqlNotificationInfo info, Sql } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // This method is used by SqlCommand. internal void StartTimer(SqlNotificationRequest notificationRequest) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { if (_expirationTime == DateTime.MaxValue) @@ -989,7 +989,7 @@ internal void StartTimer(SqlNotificationRequest notificationRequest) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1000,7 +1000,7 @@ private void AddCommandInternal(SqlCommand cmd) if (cmd != null) { // Don't bother with EventSource if command null. - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlCommand: {1}#", ObjectID, cmd.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlCommand: {1}", ObjectID, cmd.ObjectID); try { SqlConnection connection = cmd.Connection; @@ -1010,7 +1010,7 @@ private void AddCommandInternal(SqlCommand cmd) // Fail if cmd has notification that is not already associated with this dependency. if (cmd._sqlDep == null || cmd._sqlDep != this) { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - throwing command has existing SqlNotificationRequest exception."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - throwing command has existing SqlNotificationRequest exception."); throw SQL.SqlCommandHasExistingSqlNotificationRequest(); } } @@ -1044,7 +1044,7 @@ private void AddCommandInternal(SqlCommand cmd) if (0 == _eventList.Count) { // Keep logic just in case. - SqlClientEventSource.Log.NotificationsTrace(" ERROR - firing events, though it is unexpected we have events at this point."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - firing events, though it is unexpected we have events at this point."); needToInvalidate = true; // Delay invalidation until outside of lock. } } @@ -1058,14 +1058,14 @@ private void AddCommandInternal(SqlCommand cmd) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } private string ComputeCommandHash(string connectionString, SqlCommand command) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlCommand: {1}#", ObjectID, command.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlCommand: {1}", ObjectID, command.ObjectID); try { // Create a string representing the concatenation of the connection string, the command text and .ToString on all its parameter values. @@ -1121,12 +1121,12 @@ private string ComputeCommandHash(string connectionString, SqlCommand command) } string result = builder.ToString(); - SqlClientEventSource.Log.NotificationsTraceEvent(" ComputeCommandHash result: '{0}'.", result); + SqlClientEventSource.Log.NotificationTraceEvent(" ComputeCommandHash result: '{0}'.", result); return result; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs index b342713762..3cea4ef4a0 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs @@ -55,7 +55,7 @@ private class SqlConnectionContainer internal SqlConnectionContainer(SqlConnectionContainerHashHelper hashHelper, string appDomainKey, bool useDefaults) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, queue: '{1}'", ObjectID, HashHelper?.Queue); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, queue: '{1}'", ObjectID, HashHelper?.Queue); bool setupCompleted = false; try { @@ -76,7 +76,7 @@ internal SqlConnectionContainer(SqlConnectionContainerHashHelper hashHelper, str } #if DEBUG SqlConnectionString connectionStringOptions = new SqlConnectionString(_hashHelper.ConnectionStringBuilder.ConnectionString); - SqlClientEventSource.Log.NotificationsTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); + SqlClientEventSource.Log.NotificationTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); #endif // Always use ConnectionStringBuilder since in default case it is different from the @@ -175,7 +175,7 @@ internal SqlConnectionContainer(SqlConnectionContainerHashHelper hashHelper, str } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -207,7 +207,7 @@ internal string Database // SqlDependencyProcessDispatcher.QueueAppDomainUnload on AppDomain.Unload. internal bool AppDomainUnload(string appDomainKey) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, AppDomainKey: '{1}'", ObjectID, appDomainKey); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, AppDomainKey: '{1}'", ObjectID, appDomainKey); try { Debug.Assert(!string.IsNullOrEmpty(appDomainKey), "Unexpected empty appDomainKey!"); @@ -219,9 +219,9 @@ internal bool AppDomainUnload(string appDomainKey) if (_appDomainKeyHash.ContainsKey(appDomainKey)) { // Do nothing if AppDomain did not call Start! - SqlClientEventSource.Log.NotificationsTraceEvent(" _appDomainKeyHash contained AppDomainKey: '{0}'.", appDomainKey); + SqlClientEventSource.Log.NotificationTraceEvent(" _appDomainKeyHash contained AppDomainKey: '{0}'.", appDomainKey); int value = _appDomainKeyHash[appDomainKey]; - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> _appDomainKeyHash for AppDomainKey: '{0}' count: '{1}'.", appDomainKey, value); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> _appDomainKeyHash for AppDomainKey: '{0}' count: '{1}'.", appDomainKey, value); Debug.Assert(value > 0, "Why is value 0 or less?"); bool ignored = false; @@ -238,26 +238,26 @@ internal bool AppDomainUnload(string appDomainKey) if (_appDomainKeyHash.ContainsKey(appDomainKey)) { - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP|ERR> ERROR - after the Stop() loop, _appDomainKeyHash for AppDomainKey: '{0}' entry not removed from hash. Count: {1}'", appDomainKey, _appDomainKeyHash[appDomainKey]); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP|ERR> ERROR - after the Stop() loop, _appDomainKeyHash for AppDomainKey: '{0}' entry not removed from hash. Count: {1}'", appDomainKey, _appDomainKeyHash[appDomainKey]); } } else { - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> _appDomainKeyHash did not contain AppDomainKey: '{0}'.", appDomainKey); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> _appDomainKeyHash did not contain AppDomainKey: '{0}'.", appDomainKey); } } - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> Exiting, _stopped: '{0}'.", _stopped); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> Exiting, _stopped: '{0}'.", _stopped); return _stopped; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void AsynchronouslyQueryServiceBrokerQueue() { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { AsyncCallback callback = new AsyncCallback(AsyncResultCallback); @@ -265,13 +265,13 @@ private void AsynchronouslyQueryServiceBrokerQueue() } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void AsyncResultCallback(IAsyncResult asyncResult) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { using (SqlDataReader reader = _com.EndExecuteReader(asyncResult)) @@ -297,7 +297,7 @@ private void AsyncResultCallback(IAsyncResult asyncResult) _errorState = true; throw; } - SqlClientEventSource.Log.NotificationsTrace(" Exception occurred."); + SqlClientEventSource.Log.NotificationTraceEvent(" Exception occurred."); if (!_stop) { // Only assert if not in cancel path. @@ -317,13 +317,13 @@ private void AsyncResultCallback(IAsyncResult asyncResult) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void CreateQueueAndService(bool restart) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { SqlCommand com = new SqlCommand() @@ -457,18 +457,18 @@ private void CreateQueueAndService(bool restart) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } internal void IncrementStartCount(string appDomainKey, out bool appDomainStart) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { appDomainStart = false; // Reset out param. int result = Interlocked.Increment(ref _startCount); // Add to refCount. - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.IncrementStartCount|DEP> {0}#, incremented _startCount: {1}", s_staticInstance.ObjectID, result); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.IncrementStartCount|DEP> {0}, incremented _startCount: {1}", s_staticInstance.ObjectID, result); // Dictionary used to track how many times start has been called per app domain. // For each increment, add to count, and create entry if not present. @@ -477,25 +477,25 @@ internal void IncrementStartCount(string appDomainKey, out bool appDomainStart) if (_appDomainKeyHash.ContainsKey(appDomainKey)) { _appDomainKeyHash[appDomainKey] = _appDomainKeyHash[appDomainKey] + 1; - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.IncrementStartCount|DEP> _appDomainKeyHash contained AppDomainKey: '{0}', incremented count: '{1}'.", appDomainKey, _appDomainKeyHash[appDomainKey]); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.IncrementStartCount|DEP> _appDomainKeyHash contained AppDomainKey: '{0}', incremented count: '{1}'.", appDomainKey, _appDomainKeyHash[appDomainKey]); } else { _appDomainKeyHash[appDomainKey] = 1; appDomainStart = true; - SqlClientEventSource.Log.NotificationsTraceEvent(" _appDomainKeyHash did not contain AppDomainKey: '{0}', added to hashtable and value set to 1.", appDomainKey); + SqlClientEventSource.Log.NotificationTraceEvent(" _appDomainKeyHash did not contain AppDomainKey: '{0}', added to hashtable and value set to 1.", appDomainKey); } } } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void ProcessNotificationResults(SqlDataReader reader) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); Guid handle = Guid.Empty; // Conversation_handle. Always close this! try { @@ -503,18 +503,18 @@ private void ProcessNotificationResults(SqlDataReader reader) { while (reader.Read()) { - SqlClientEventSource.Log.NotificationsTrace(" Row read."); + SqlClientEventSource.Log.NotificationTraceEvent(" Row read."); #if DEBUG if (SqlClientEventSource.Log.IsNotificationTraceEnabled()) { for (int i = 0; i < reader.FieldCount; i++) { - SqlClientEventSource.Log.NotificationsTraceEvent(" column: {0}, value: {1}", reader.GetName(i), reader.GetValue(i).ToString()); + SqlClientEventSource.Log.NotificationTraceEvent(" column: {0}, value: {1}", reader.GetName(i), reader.GetValue(i).ToString()); } } #endif string msgType = reader.GetString(0); - SqlClientEventSource.Log.NotificationsTraceEvent(" msgType: '{0}'", msgType); + SqlClientEventSource.Log.NotificationTraceEvent(" msgType: '{0}'", msgType); handle = reader.GetGuid(1); // Only process QueryNotification messages. @@ -527,7 +527,7 @@ private void ProcessNotificationResults(SqlDataReader reader) if (null != notification) { string key = notification.Key; - SqlClientEventSource.Log.NotificationsTraceEvent(" Key: '{0}'", key); + SqlClientEventSource.Log.NotificationTraceEvent(" Key: '{0}'", key); int index = key.IndexOf(';'); // Our format is simple: "AppDomainKey;commandHash" if (index >= 0) @@ -556,31 +556,31 @@ private void ProcessNotificationResults(SqlDataReader reader) else { Debug.Fail("Received notification but do not have an associated PerAppDomainDispatcher!"); - SqlClientEventSource.Log.NotificationsTrace(" Received notification but do not have an associated PerAppDomainDispatcher!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Received notification but do not have an associated PerAppDomainDispatcher!"); } } else { Debug.Fail("Unexpected ID format received!"); - SqlClientEventSource.Log.NotificationsTrace(" Unexpected ID format received!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Unexpected ID format received!"); } } else { Debug.Fail("Null notification returned from ProcessMessage!"); - SqlClientEventSource.Log.NotificationsTrace(" Null notification returned from ProcessMessage!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Null notification returned from ProcessMessage!"); } } else { Debug.Fail("Null payload for QN notification type!"); - SqlClientEventSource.Log.NotificationsTrace(" Null payload for QN notification type!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Null payload for QN notification type!"); } } else { handle = Guid.Empty; - SqlClientEventSource.Log.NotificationsTrace(" Unexpected message format received!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Unexpected message format received!"); } } } @@ -608,13 +608,13 @@ private void ProcessNotificationResults(SqlDataReader reader) } Debug.Assert(_com.Parameters.Count == 2, "Unexpected number of parameters!"); } - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void Restart(object unused) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { // Unused arg required by TimerCallback. @@ -762,13 +762,13 @@ private void Restart(object unused) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } internal bool Stop(string appDomainKey, out bool appDomainStop) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { appDomainStop = false; @@ -786,7 +786,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) int value = _appDomainKeyHash[appDomainKey]; Debug.Assert(value > 0, "Unexpected count for appDomainKey"); - SqlClientEventSource.Log.NotificationsTraceEvent(" _appDomainKeyHash contained AppDomainKey: '{0}', pre-decrement Count: '{1}'.", appDomainKey, value); + SqlClientEventSource.Log.NotificationTraceEvent(" _appDomainKeyHash contained AppDomainKey: '{0}', pre-decrement Count: '{1}'.", appDomainKey, value); if (value > 0) { @@ -794,7 +794,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR pre-decremented count <= 0!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR pre-decremented count <= 0!"); Debug.Fail("Unexpected AppDomainKey count in Stop()"); } @@ -806,7 +806,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR appDomainKey not null and not found in hash!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR appDomainKey not null and not found in hash!"); Debug.Fail("Unexpected state on Stop() - no AppDomainKey entry in hashtable!"); } } @@ -819,7 +819,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) { // If we've reached refCount 0, destroy. // Lock to ensure Cancel() complete prior to other thread calling TearDown. - SqlClientEventSource.Log.NotificationsTrace(" Reached 0 count, cancelling and waiting."); + SqlClientEventSource.Log.NotificationTraceEvent(" Reached 0 count, cancelling and waiting."); lock (this) { @@ -862,7 +862,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) // TearDownAndDispose in the maximum retry period case as well as in the _errorState case. if (_errorState || retryStopwatch.Elapsed.Seconds >= 30) { - SqlClientEventSource.Log.NotificationsTraceEvent(" forcing cleanup. elapsedSeconds: '{0}', _errorState: '{1}'.", retryStopwatch.Elapsed.Seconds, _errorState); + SqlClientEventSource.Log.NotificationTraceEvent(" forcing cleanup. elapsedSeconds: '{0}', _errorState: '{1}'.", retryStopwatch.Elapsed.Seconds, _errorState); Timer retryTimer = _retryTimer; _retryTimer = null; if (retryTimer != null) @@ -881,7 +881,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) } else { - SqlClientEventSource.Log.NotificationsTraceEvent(" _startCount not 0 after decrement. _startCount: '{0}'.", _startCount); + SqlClientEventSource.Log.NotificationTraceEvent(" _startCount not 0 after decrement. _startCount: '{0}'.", _startCount); } Debug.Assert(0 <= _startCount, "Invalid start count state"); @@ -890,13 +890,13 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void SynchronouslyQueryServiceBrokerQueue() { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { using (SqlDataReader reader = _com.ExecuteReader()) @@ -906,14 +906,14 @@ private void SynchronouslyQueryServiceBrokerQueue() } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } [SuppressMessage("Microsoft.Security", "CA2100:ReviewSqlQueriesForSecurityVulnerabilities")] private void TearDownAndDispose() { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { lock (this) @@ -981,7 +981,7 @@ private void TearDownAndDispose() } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } @@ -1310,19 +1310,19 @@ public override int GetHashCode() private SqlDependencyProcessDispatcher(object dummyVariable) { Debug.Assert(null == s_staticInstance, "Real constructor called with static instance already created!"); - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { #if DEBUG // Possibly expensive, limit to debug. - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, AppDomain.CurrentDomain.FriendlyName: {1}", ObjectID, AppDomain.CurrentDomain.FriendlyName); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, AppDomain.CurrentDomain.FriendlyName: {1}", ObjectID, AppDomain.CurrentDomain.FriendlyName); #endif _connectionContainers = new Dictionary(); _sqlDependencyPerAppDomainDispatchers = new Dictionary(); } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1331,17 +1331,17 @@ private SqlDependencyProcessDispatcher(object dummyVariable) public SqlDependencyProcessDispatcher() { // Empty constructor and object - dummy to obtain singleton. - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { #if DEBUG // Possibly expensive, limit to debug. - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, AppDomain.CurrentDomain.FriendlyName: {1}", ObjectID, AppDomain.CurrentDomain.FriendlyName); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, AppDomain.CurrentDomain.FriendlyName: {1}", ObjectID, AppDomain.CurrentDomain.FriendlyName); #endif } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1358,7 +1358,7 @@ public SqlDependencyProcessDispatcher() out string user, string queue) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, queue: {1}", s_staticInstance.ObjectID, queue); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, queue: {1}", s_staticInstance.ObjectID, queue); try { // Force certain connection string properties to be used by SqlDependencyProcessDispatcher. @@ -1392,7 +1392,7 @@ public SqlDependencyProcessDispatcher() } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1404,7 +1404,7 @@ public override object InitializeLifetimeService() private void Invalidate(string server, SqlNotification sqlNotification) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, server: {1}", ObjectID, server); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, server: {1}", ObjectID, server); try { Debug.Assert(this == s_staticInstance, "Instance method called on non _staticInstance instance!"); @@ -1436,7 +1436,7 @@ private void Invalidate(string server, SqlNotification sqlNotification) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1451,7 +1451,7 @@ internal void QueueAppDomainUnloading(string appDomainKey) // This method is only called by queued work-items from the method above. private void AppDomainUnloading(object state) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { string appDomainKey = (string)state; @@ -1483,7 +1483,7 @@ private void AppDomainUnloading(object state) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1553,7 +1553,7 @@ private void AppDomainUnloading(object state) bool useDefaults) { Debug.Assert(this == s_staticInstance, "Instance method called on non _staticInstance instance!"); - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, queue: '{1}', appDomainKey: '{2}', perAppDomainDispatcher ID: '{3}'", ObjectID, queueService, appDomainKey, dispatcher.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, queue: '{1}', appDomainKey: '{2}', perAppDomainDispatcher ID: '{3}'", ObjectID, queueService, appDomainKey, dispatcher.ObjectID); try { server = null; // Reset out params. @@ -1578,7 +1578,7 @@ private void AppDomainUnloading(object state) queueService); #if DEBUG SqlConnectionString connectionStringOptions = new SqlConnectionString(connectionStringBuilder.ConnectionString); - SqlClientEventSource.Log.NotificationsTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); + SqlClientEventSource.Log.NotificationTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); #endif bool started = false; @@ -1588,7 +1588,7 @@ private void AppDomainUnloading(object state) { if (!_connectionContainers.ContainsKey(hashHelper)) { - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, hashtable miss, creating new container.", ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, hashtable miss, creating new container.", ObjectID); container = new SqlConnectionContainer(hashHelper, appDomainKey, useDefaults); _connectionContainers.Add(hashHelper, container); started = true; @@ -1597,10 +1597,10 @@ private void AppDomainUnloading(object state) else { container = _connectionContainers[hashHelper]; - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, hashtable hit, container: {1}", ObjectID, container.ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, hashtable hit, container: {1}", ObjectID, container.ObjectID); if (container.InErrorState) { - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, container: {1} is in error state!", ObjectID, container.ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, container: {1} is in error state!", ObjectID, container.ObjectID); errorOccurred = true; // Set outparam errorOccurred true so we invalidate on Start(). } else @@ -1615,14 +1615,14 @@ private void AppDomainUnloading(object state) server = container.Server; database = container.Database; queueService = container.Queue; - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, default service: '{1}', server: '{2}', database: '{3}'", ObjectID, queueService, server, database); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, default service: '{1}', server: '{2}', database: '{3}'", ObjectID, queueService, server, database); } - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, started: {1}", ObjectID, started); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, started: {1}", ObjectID, started); return started; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1638,7 +1638,7 @@ private void AppDomainUnloading(object state) string appDomainKey, out bool appDomainStop) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, queue: '{1}'", ObjectID, queueService); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, queue: '{1}'", ObjectID, queueService); Debug.Assert(this == s_staticInstance, "Instance method called on non _staticInstance instance!"); try { @@ -1655,7 +1655,7 @@ private void AppDomainUnloading(object state) queueService); #if DEBUG SqlConnectionString connectionStringOptions = new SqlConnectionString(connectionStringBuilder.ConnectionString); - SqlClientEventSource.Log.NotificationsTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); + SqlClientEventSource.Log.NotificationTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); #endif bool stopped = false; @@ -1665,7 +1665,7 @@ private void AppDomainUnloading(object state) if (_connectionContainers.ContainsKey(hashHelper)) { SqlConnectionContainer container = _connectionContainers[hashHelper]; - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, hashtable hit, container: {1}", ObjectID, container.ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, hashtable hit, container: {1}", ObjectID, container.ObjectID); server = container.Server; // Return server, database, and queue info for use by calling SqlDependency. database = container.Database; queueService = container.Queue; @@ -1678,15 +1678,15 @@ private void AppDomainUnloading(object state) } else { - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, hashtable miss.", ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, hashtable miss.", ObjectID); } } - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, stopped: {1}", ObjectID, stopped); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, stopped: {1}", ObjectID, stopped); return stopped; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs index c75553cf49..65bc264f21 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyUtils.AppDomain.cs @@ -19,7 +19,7 @@ private void SubscribeToAppDomainUnload() private void UnloadEventHandler(object sender, EventArgs e) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { // Make non-blocking call to ProcessDispatcher to ThreadPool.QueueUserWorkItem to complete @@ -31,7 +31,7 @@ private void UnloadEventHandler(object sender, EventArgs e) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs index abb7d8425c..98f474ea2b 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs @@ -80,7 +80,7 @@ internal DependencyList(string commandHash) private SqlDependencyPerAppDomainDispatcher() { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { _dependencyIdToDependencyHash = new Dictionary(); @@ -97,7 +97,7 @@ private SqlDependencyPerAppDomainDispatcher() } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -113,7 +113,7 @@ public override object InitializeLifetimeService() // This method is called upon SqlDependency constructor. internal void AddDependencyEntry(SqlDependency dep) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlDependency: {1}#", ObjectID, dep.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlDependency: {1}", ObjectID, dep.ObjectID); try { lock (_instanceLock) @@ -123,14 +123,14 @@ internal void AddDependencyEntry(SqlDependency dep) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // This method is called upon Execute of a command associated with a SqlDependency object. internal string AddCommandEntry(string commandHash, SqlDependency dep) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, commandHash: '{1}', SqlDependency: {2}#", ObjectID, commandHash, dep.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, commandHash: '{1}', SqlDependency: {2}", ObjectID, commandHash, dep.ObjectID); string notificationId = string.Empty; try { @@ -139,7 +139,7 @@ internal string AddCommandEntry(string commandHash, SqlDependency dep) if (!_dependencyIdToDependencyHash.ContainsKey(dep.Id)) { // Determine if depId->dep hashtable contains dependency. If not, it's been invalidated. - SqlClientEventSource.Log.NotificationsTraceEvent(" Dependency not present in depId->dep hash, must have been invalidated."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency not present in depId->dep hash, must have been invalidated."); } else { @@ -160,12 +160,12 @@ internal string AddCommandEntry(string commandHash, SqlDependency dep) // join the new dependency to the list if (!dependencyList.Contains(dep)) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Dependency not present for commandHash, adding."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency not present for commandHash, adding."); dependencyList.Add(dep); } else { - SqlClientEventSource.Log.NotificationsTraceEvent(" Dependency already present for commandHash."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency already present for commandHash."); } } else @@ -179,7 +179,7 @@ internal string AddCommandEntry(string commandHash, SqlDependency dep) SqlDependency.AppDomainKey, // must be first Guid.NewGuid().ToString("D", System.Globalization.CultureInfo.InvariantCulture) ); - SqlClientEventSource.Log.NotificationsTraceEvent(" Creating new Dependencies list for commandHash."); + SqlClientEventSource.Log.NotificationTraceEvent(" Creating new Dependencies list for commandHash."); DependencyList dependencyList = new DependencyList(commandHash); dependencyList.Add(dep); @@ -196,14 +196,14 @@ internal string AddCommandEntry(string commandHash, SqlDependency dep) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // This method is called by the ProcessDispatcher upon a notification for this AppDomain. internal void InvalidateCommandID(SqlNotification sqlNotification) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, commandHash: '{1}'", ObjectID, sqlNotification.Key); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, commandHash: '{1}'", ObjectID, sqlNotification.Key); try { List dependencyList = null; @@ -214,7 +214,7 @@ internal void InvalidateCommandID(SqlNotification sqlNotification) if (null != dependencyList) { - SqlClientEventSource.Log.NotificationsTraceEvent(" commandHash found in hashtable."); + SqlClientEventSource.Log.NotificationTraceEvent(" commandHash found in hashtable."); foreach (SqlDependency dependency in dependencyList) { // Ensure we remove from process static app domain hash for dependency initiated invalidates. @@ -226,7 +226,7 @@ internal void InvalidateCommandID(SqlNotification sqlNotification) } else { - SqlClientEventSource.Log.NotificationsTraceEvent(" commandHash NOT found in hashtable."); + SqlClientEventSource.Log.NotificationTraceEvent(" commandHash NOT found in hashtable."); } } @@ -235,7 +235,7 @@ internal void InvalidateCommandID(SqlNotification sqlNotification) // After removal from hashtables, invalidate. foreach (SqlDependency dependency in dependencyList) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Dependency found in commandHash dependency ArrayList - calling invalidate."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency found in commandHash dependency ArrayList - calling invalidate."); try { dependency.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source); @@ -256,14 +256,14 @@ internal void InvalidateCommandID(SqlNotification sqlNotification) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(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.NotificationsScopeEnterEvent(" {0}#, server: '{1}'", ObjectID, server); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, server: '{1}'", ObjectID, server); try { List dependencies = new List(); @@ -310,14 +310,14 @@ internal void InvalidateServer(string server, SqlNotification sqlNotification) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(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.NotificationsScopeEnterEvent(" {0}#, Key: '{1}'", ObjectID, id); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, Key: '{1}'", ObjectID, id); try { if (null == id) @@ -339,7 +339,7 @@ internal SqlDependency LookupDependencyEntry(string id) } else { - SqlClientEventSource.Log.NotificationsTraceEvent(" ERROR - dependency ID mismatch - not throwing."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - dependency ID mismatch - not throwing."); } } @@ -347,21 +347,21 @@ internal SqlDependency LookupDependencyEntry(string id) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // Remove the dependency from the hashtable with the passed id. private void LookupDependencyEntryWithRemove(string id) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, id: '{1}'", ObjectID, id); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, id: '{1}'", ObjectID, id); try { lock (_instanceLock) { if (_dependencyIdToDependencyHash.ContainsKey(id)) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Entry found in hashtable - removing."); + SqlClientEventSource.Log.NotificationTraceEvent(" Entry found in hashtable - removing."); _dependencyIdToDependencyHash.Remove(id); // if there are no more dependencies then we can dispose the timer. @@ -373,20 +373,20 @@ private void LookupDependencyEntryWithRemove(string id) } else { - SqlClientEventSource.Log.NotificationsTraceEvent(" Entry NOT found in hashtable."); + SqlClientEventSource.Log.NotificationTraceEvent(" Entry NOT found in hashtable."); } } } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // Find and return arraylist, and remove passed hash value. private List LookupCommandEntryWithRemove(string notificationId) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, commandHash: '{1}'", ObjectID, notificationId); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, commandHash: '{1}'", ObjectID, notificationId); try { DependencyList entry = null; @@ -395,7 +395,7 @@ private List LookupCommandEntryWithRemove(string notificationId) { if (_notificationIdToDependenciesHash.TryGetValue(notificationId, out entry)) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Entries found in hashtable - removing."); + SqlClientEventSource.Log.NotificationTraceEvent(" Entries found in hashtable - removing."); // update the tables _notificationIdToDependenciesHash.Remove(notificationId); @@ -404,7 +404,7 @@ private List LookupCommandEntryWithRemove(string notificationId) } else { - SqlClientEventSource.Log.NotificationsTraceEvent(" Entries NOT found in hashtable."); + SqlClientEventSource.Log.NotificationTraceEvent(" Entries NOT found in hashtable."); } Debug.Assert(_notificationIdToDependenciesHash.Count == _commandHashToNotificationId.Count, "always keep these maps in sync!"); @@ -414,14 +414,14 @@ private List LookupCommandEntryWithRemove(string notificationId) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // Remove from commandToDependenciesHash all references to the passed dependency. private void RemoveDependencyFromCommandToDependenciesHash(SqlDependency dependency) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlDependency: {1}#", ObjectID, dependency.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlDependency: {1}", ObjectID, dependency.ObjectID); try { lock (_instanceLock) @@ -434,7 +434,7 @@ private void RemoveDependencyFromCommandToDependenciesHash(SqlDependency depende DependencyList dependencies = entry.Value; if (dependencies.Remove(dependency)) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Removed SqlDependency: {0}#, with ID: '{1}'.", dependency.ObjectID, dependency.Id); + SqlClientEventSource.Log.NotificationTraceEvent(" 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 @@ -461,7 +461,7 @@ private void RemoveDependencyFromCommandToDependenciesHash(SqlDependency depende } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -469,7 +469,7 @@ private void RemoveDependencyFromCommandToDependenciesHash(SqlDependency depende internal void StartTimer(SqlDependency dep) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlDependency: {1}#", ObjectID, dep.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlDependency: {1}", ObjectID, dep.ObjectID); try { // If this dependency expires sooner than the current next timeout, change @@ -480,7 +480,7 @@ internal void StartTimer(SqlDependency dep) // Enable the timer if needed (disable when empty, enable on the first addition). if (!_sqlDependencyTimeOutTimerStarted) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Timer not yet started, starting."); + SqlClientEventSource.Log.NotificationTraceEvent(" Timer not yet started, starting."); _timeoutTimer.Change(15000 /* 15 secs */, 15000 /* 15 secs */); // Save this as the earlier timeout to come. @@ -489,7 +489,7 @@ internal void StartTimer(SqlDependency dep) } else if (_nextTimeout > dep.ExpirationTime) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Timer already started, resetting time."); + SqlClientEventSource.Log.NotificationTraceEvent(" Timer already started, resetting time."); // Save this as the earlier timeout to come. _nextTimeout = dep.ExpirationTime; @@ -498,13 +498,13 @@ internal void StartTimer(SqlDependency dep) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private static void TimeoutTimerCallback(object state) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" AppDomainKey: '{0}'", SqlDependency.AppDomainKey); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" AppDomainKey: '{0}'", SqlDependency.AppDomainKey); try { SqlDependency[] dependencies; @@ -516,14 +516,14 @@ private static void TimeoutTimerCallback(object state) { if (0 == SingletonInstance._dependencyIdToDependencyHash.Count) { - SqlClientEventSource.Log.NotificationsTrace(" No dependencies, exiting."); + SqlClientEventSource.Log.NotificationTraceEvent(" No dependencies, exiting."); // Nothing to check. return; } if (SingletonInstance._nextTimeout > DateTime.UtcNow) { - SqlClientEventSource.Log.NotificationsTrace(" No timeouts expired, exiting."); + SqlClientEventSource.Log.NotificationTraceEvent(" No timeouts expired, exiting."); // No dependency timed-out yet. return; @@ -594,7 +594,7 @@ private static void TimeoutTimerCallback(object state) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs index 6eebfcf36c..e11677b0a1 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs @@ -249,7 +249,7 @@ override protected void Deactivate() { try { - SqlClientEventSource.Log.AdvanceTrace(" {0}# deactivating", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} deactivating", ObjectID); SqlReferenceCollection referenceCollection = (SqlReferenceCollection)ReferenceCollection; if (null != referenceCollection) { @@ -329,12 +329,12 @@ protected void Enlist(Transaction tx) private void EnlistNonNull(Transaction tx) { Debug.Assert(null != tx, "null transaction?"); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, transaction {1}#.", ObjectID, tx.GetHashCode()); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, transaction {1}.", ObjectID, tx.GetHashCode()); bool hasDelegatedTransaction = false; // Promotable transactions are only supported on Yukon // servers or newer. - SqlClientEventSource.Log.AdvanceTrace(" {0}#, attempting to delegate", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, attempting to delegate", ObjectID); SqlDelegatedTransaction delegatedTransaction = new SqlDelegatedTransaction(this, tx); try @@ -398,7 +398,7 @@ private void EnlistNonNull(Transaction tx) if (hasDelegatedTransaction) { this.DelegatedTransaction = delegatedTransaction; - SqlClientEventSource.Log.AdvanceTrace(" {0}#, delegated to transaction {1}# with transactionId=0x{2}", ObjectID, null != CurrentTransaction ? CurrentTransaction.ObjectID : 0, null != CurrentTransaction ? CurrentTransaction.TransactionId : SqlInternalTransaction.NullTransactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, delegated to transaction {1} with transactionId=0x{2}", ObjectID, null != CurrentTransaction ? CurrentTransaction.ObjectID : 0, null != CurrentTransaction ? CurrentTransaction.TransactionId : SqlInternalTransaction.NullTransactionId); } } catch (SqlException e) @@ -428,7 +428,7 @@ private void EnlistNonNull(Transaction tx) if (!hasDelegatedTransaction) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, delegation not possible, enlisting.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, delegation not possible, enlisting.", ObjectID); byte[] cookie = null; if (_isGlobalTransaction) @@ -459,7 +459,7 @@ private void EnlistNonNull(Transaction tx) PropagateTransactionCookie(cookie); _isEnlistedInTransaction = true; - SqlClientEventSource.Log.AdvanceTrace(" {0}#, enlisted with transaction {1}# with transactionId=0x{2}", ObjectID, null != CurrentTransaction ? CurrentTransaction.ObjectID : 0, null != CurrentTransaction ? CurrentTransaction.TransactionId : SqlInternalTransaction.NullTransactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, enlisted with transaction {1} with transactionId=0x{2}", ObjectID, null != CurrentTransaction ? CurrentTransaction.ObjectID : 0, null != CurrentTransaction ? CurrentTransaction.TransactionId : SqlInternalTransaction.NullTransactionId); } EnlistedTransaction = tx; // Tell the base class about our enlistment @@ -483,7 +483,7 @@ private void EnlistNonNull(Transaction tx) internal void EnlistNull() { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, unenlisting.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, unenlisting.", ObjectID); // We were in a transaction, but now we are not - so send // message to server with empty transaction - confirmed proper // behavior from Sameet Agarwal @@ -501,7 +501,7 @@ internal void EnlistNull() _isEnlistedInTransaction = false; EnlistedTransaction = null; // Tell the base class about our enlistment - SqlClientEventSource.Log.AdvanceTrace(" {0}#, unenlisted.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, unenlisted.", ObjectID); // The EnlistTransaction above will return an TransactionEnded event, // which causes the TdsParser or SmiEventSink should to clear the 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 b8f47a8198..30d335d3cd 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 @@ -462,7 +462,7 @@ internal SqlConnectionTimeoutErrorInternal TimeoutErrorInternal ThreadHasParserLockForClose = false; _parserLock.Release(); } - SqlClientEventSource.Log.AdvanceTrace(" {0}#, constructed new TDS internal connection", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, constructed new TDS internal connection", ObjectID); } // Returns true if the Sql error is a transient. @@ -646,7 +646,7 @@ protected override void ChangeDatabaseInternal(string database) public override void Dispose() { - SqlClientEventSource.Log.AdvanceTrace(" {0}# disposing", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} disposing", ObjectID); try { TdsParser parser = Interlocked.Exchange(ref _parser, null); // guard against multiple concurrent dispose calls -- Delegated Transactions might cause this. @@ -1094,12 +1094,12 @@ private void CompleteLogin(bool enlistOK) // ROR should not affect state of connection recovery if (_federatedAuthenticationRequested && !_federatedAuthenticationAcknowledged) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Server did not acknowledge the federated authentication request", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Server did not acknowledge the federated authentication request", ObjectID); throw SQL.ParsingError(ParsingErrorState.FedAuthNotAcknowledged); } if (_federatedAuthenticationInfoRequested && !_federatedAuthenticationInfoReceived) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Server never sent the requested federated authentication info", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Server never sent the requested federated authentication info", ObjectID); throw SQL.ParsingError(ParsingErrorState.FedAuthInfoNotReceived); } if (!_sessionRecoveryAcknowledged) @@ -1136,7 +1136,7 @@ private void CompleteLogin(bool enlistOK) _parser.EnableMars(); _fConnectionOpen = true; // mark connection as open - SqlClientEventSource.Log.AdvanceTrace(" Post-Login Phase: Server connection obtained."); + SqlClientEventSource.Log.AdvancedTraceEvent(" Post-Login Phase: Server connection obtained."); // for non-pooled connections, enlist in a distributed transaction // if present - and user specified to enlist @@ -1251,7 +1251,7 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword, private void LoginFailure() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); // If the parser was allocated and we failed, then we must have failed on // either the Connect or Login, either way we should call Disconnect. @@ -1367,7 +1367,7 @@ private bool IsDoNotRetryConnectError(SqlException exc) Debug.Assert(object.ReferenceEquals(connectionOptions, this.ConnectionOptions), "ConnectionOptions argument and property must be the same"); // consider removing the argument int routingAttempts = 0; ServerInfo originalServerInfo = serverInfo; // serverInfo may end up pointing to new object due to routing, original object is used to set CurrentDatasource - SqlClientEventSource.Log.AdvanceTrace(" {0}#, host={1}", ObjectID, serverInfo.UserServerName); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, host={1}", ObjectID, serverInfo.UserServerName); int sleepInterval = 100; //milliseconds to sleep (back off) between attempts. ResolveExtendedServerName(serverInfo, !redirectedUserInstance, connectionOptions); @@ -1517,7 +1517,7 @@ private bool IsDoNotRetryConnectError(SqlException exc) // Sleep for a bit to prevent clogging the network with requests, // then update sleep interval for next iteration (max 1 second interval) - SqlClientEventSource.Log.AdvanceTrace(" {0}#, sleeping {1}[milisec]", ObjectID, sleepInterval); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, sleeping {1}[milisec]", ObjectID, sleepInterval); Thread.Sleep(sleepInterval); sleepInterval = (sleepInterval < 500) ? sleepInterval * 2 : 1000; } @@ -1561,7 +1561,7 @@ TimeoutTimer timeout ) { Debug.Assert(!connectionOptions.MultiSubnetFailover, "MultiSubnetFailover should not be set if failover partner is used"); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, useFailover={1}[bool], primary={2}, failover={3}", ObjectID, useFailoverHost, primaryServerInfo.UserServerName, failoverHost ?? "null"); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, useFailover={1}[bool], primary={2}, failover={3}", ObjectID, useFailoverHost, primaryServerInfo.UserServerName, failoverHost ?? "null"); int sleepInterval = 100; //milliseconds to sleep (back off) between attempts. long timeoutUnitInterval; @@ -1620,7 +1620,7 @@ TimeoutTimer timeout // Primary server may give us a different failover partner than the connection string indicates. Update it if (null != ServerProvidedFailOverPartner && failoverServerInfo.ResolvedServerName != ServerProvidedFailOverPartner) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, new failover partner={1}", ObjectID, ServerProvidedFailOverPartner); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, new failover partner={1}", ObjectID, ServerProvidedFailOverPartner); failoverServerInfo.SetDerivedNames(string.Empty, ServerProvidedFailOverPartner); } currentServerInfo = failoverServerInfo; @@ -1685,7 +1685,7 @@ TimeoutTimer timeout // the network with requests, then update sleep interval for next iteration (max 1 second interval) if (1 == attemptNumber % 2) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, sleeping {1}[milisec]", ObjectID, sleepInterval); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, sleeping {1}[milisec]", ObjectID, sleepInterval); Thread.Sleep(sleepInterval); sleepInterval = (sleepInterval < 500) ? sleepInterval * 2 : 1000; } @@ -1740,7 +1740,7 @@ private void ResolveExtendedServerName(ServerInfo serverInfo, bool aliasLookup, TimeoutTimer timeout, bool withFailover = false) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, timout={1}[msec], server={2}", ObjectID, timeout.MillisecondsRemaining, serverInfo.ExtendedServerName); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, timout={1}[msec], server={2}", ObjectID, timeout.MillisecondsRemaining, serverInfo.ExtendedServerName); RoutingInfo = null; // forget routing information _parser._physicalStateObj.SniContext = SniContext.Snix_Connect; @@ -1843,7 +1843,7 @@ internal bool GetSessionAndReconnectIfNeeded(SqlConnection parent, int timeout = internal void BreakConnection() { var connection = Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Breaking connection.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Breaking connection.", ObjectID); DoomThisConnection(); // Mark connection as unusable, so it will be destroyed if (null != connection) { @@ -1949,7 +1949,7 @@ internal void OnEnvChange(SqlEnvChange rec) break; case TdsEnums.ENV_ROUTING: - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received routing info", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received routing info", ObjectID); if (string.IsNullOrEmpty(rec.newRoutingInfo.ServerName) || rec.newRoutingInfo.Protocol != 0 || rec.newRoutingInfo.Port == 0) { throw SQL.ROR_InvalidRoutingInfo(this); @@ -1992,7 +1992,7 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo) "Credentials aren't provided for calling MSAL"); Debug.Assert(fedAuthInfo != null, "info should not be null."); Debug.Assert(_dbConnectionPoolAuthenticationContextKey == null, "_dbConnectionPoolAuthenticationContextKey should be null."); - SqlClientEventSource.Log.TraceEvent(" {0}#, Generating federated authentication token", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Generating federated authentication token", ObjectID); DbConnectionPoolAuthenticationContext dbConnectionPoolAuthenticationContext = null; // We want to refresh the token without taking a lock on the context, allowed when the access token is expiring within the next 10 mins. @@ -2023,7 +2023,7 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo) // And on successful login, try to update the cache with the new token. if (contextValidity <= _dbAuthenticationContextUnLockedRefreshTimeSpan) { - SqlClientEventSource.Log.TraceEvent(" {0}#, " + + SqlClientEventSource.Log.TraceEvent(" {0}, " + "The expiration time is less than 10 mins, so trying to get new access token regardless of if an other thread is also trying to update it." + "The expiration time is {1}. Current Time is {2}.", ObjectID, dbConnectionPoolAuthenticationContext.ExpirationTime.ToLongTimeString(), DateTime.UtcNow.ToLongTimeString()); attemptRefreshTokenUnLocked = true; @@ -2045,7 +2045,7 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo) // If a thread is already doing the refresh, just use the existing token in the cache and proceed. else if (contextValidity <= _dbAuthenticationContextLockedRefreshTimeSpan) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, " + + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, " + "The authentication context needs a refresh.The expiration time is {1}. " + "Current Time is {2}.", ObjectID, dbConnectionPoolAuthenticationContext.ExpirationTime.ToLongTimeString(), DateTime.UtcNow.ToLongTimeString()); @@ -2061,10 +2061,10 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo) // Indicate in EventSource Trace that we are successful with the update. if (attemptRefreshTokenLocked) { - SqlClientEventSource.Log.TraceEvent(" {0}#, The attempt to get a new access token succeeded under the locked mode.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, The attempt to get a new access token succeeded under the locked mode.", ObjectID); } } - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Found an authentication context in the cache that does not need a refresh at this time. Re-using the cached token.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Found an authentication context in the cache that does not need a refresh at this time. Re-using the cached token.", ObjectID); } } @@ -2124,14 +2124,14 @@ internal bool TryGetFedAuthTokenLocked(SqlFedAuthInfo fedAuthInfo, DbConnectionP // Else some other thread is already updating it, so just proceed forward with the existing token in the cache. if (dbConnectionPoolAuthenticationContext.LockToUpdate()) { - SqlClientEventSource.Log.TraceEvent(" {0}#, " + + SqlClientEventSource.Log.TraceEvent(" {0}, " + "Acquired the lock to update the authentication context.The expiration time is {1}. " + "Current Time is {2}.", ObjectID, dbConnectionPoolAuthenticationContext.ExpirationTime.ToLongTimeString(), DateTime.UtcNow.ToLongTimeString()); authenticationContextLocked = true; } else { - SqlClientEventSource.Log.TraceEvent(" {0}#, Refreshing the context is already in progress by another thread.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Refreshing the context is already in progress by another thread.", ObjectID); } if (authenticationContextLocked) @@ -2289,7 +2289,7 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo) || _timeout.IsExpired || _timeout.MillisecondsRemaining <= sleepInterval) { - SqlClientEventSource.Log.TraceEvent(" {0}#", msalException.ErrorCode); + SqlClientEventSource.Log.TraceEvent(" {0}", msalException.ErrorCode); // Error[0] SqlErrorCollection sqlErs = new SqlErrorCollection(); sqlErs.Add(new SqlError(0, (byte)0x00, (byte)TdsEnums.MIN_ERROR_CLASS, ConnectionOptions.DataSource, SRHelper.GetString(SR.SQL_MSALFailure, username, ConnectionOptions.Authentication.ToString("G")), ActiveDirectoryAuthentication.MSALGetAccessTokenFunctionName, 0)); @@ -2307,8 +2307,8 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo) throw exc; } - SqlClientEventSource.Log.AdvanceTrace(" {0}#, sleeping {1}[Milliseconds]", ObjectID, sleepInterval); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, remaining {1}[Milliseconds]", ObjectID, _timeout.MillisecondsRemaining); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, sleeping {1}[Milliseconds]", ObjectID, sleepInterval); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, remaining {1}[Milliseconds]", ObjectID, _timeout.MillisecondsRemaining); Thread.Sleep(sleepInterval); sleepInterval *= 2; @@ -2324,7 +2324,7 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo) DateTime expirationTime = DateTime.FromFileTimeUtc(fedAuthToken.expirationFileTime); _newDbConnectionPoolAuthenticationContext = new DbConnectionPoolAuthenticationContext(fedAuthToken.accessToken, expirationTime); } - SqlClientEventSource.Log.TraceEvent(" {0}#, Finished generating federated authentication token.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Finished generating federated authentication token.", ObjectID); return fedAuthToken; } @@ -2388,10 +2388,10 @@ internal void OnFeatureExtAck(int featureId, byte[] data) case TdsEnums.FEATUREEXT_GLOBALTRANSACTIONS: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for GlobalTransactions", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for GlobalTransactions", ObjectID); if (data.Length < 1) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown version number for GlobalTransactions", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown version number for GlobalTransactions", ObjectID); throw SQL.ParsingError(); } @@ -2404,10 +2404,10 @@ internal void OnFeatureExtAck(int featureId, byte[] data) } case TdsEnums.FEATUREEXT_FEDAUTH: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for federated authentication", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for federated authentication", ObjectID); if (!_federatedAuthenticationRequested) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Did not request federated authentication", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Did not request federated authentication", ObjectID); throw SQL.ParsingErrorFeatureId(ParsingErrorState.UnrequestedFeatureAckReceived, featureId); } @@ -2420,14 +2420,14 @@ internal void OnFeatureExtAck(int featureId, byte[] data) // The server shouldn't have sent any additional data with the ack (like a nonce) if (data.Length != 0) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Federated authentication feature extension ack for MSAL and Security Token includes extra data", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Federated authentication feature extension ack for MSAL and Security Token includes extra data", ObjectID); throw SQL.ParsingError(ParsingErrorState.FedAuthFeatureAckContainsExtraData); } break; default: Debug.Fail("Unknown _fedAuthLibrary type"); - SqlClientEventSource.Log.TraceEvent(" {0}#, Attempting to use unknown federated authentication library", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Attempting to use unknown federated authentication library", ObjectID); throw SQL.ParsingErrorLibraryType(ParsingErrorState.FedAuthFeatureAckUnknownLibraryType, (int)_fedAuthFeatureExtensionData.Value.libraryType); } _federatedAuthenticationAcknowledged = true; @@ -2446,11 +2446,11 @@ internal void OnFeatureExtAck(int featureId, byte[] data) // For debug purposes, assert and trace if we ended up updating the cache with the new one or some other thread's context won the expiration race. if (newAuthenticationContextInCacheAfterAddOrUpdate == _newDbConnectionPoolAuthenticationContext) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Updated the new dbAuthenticationContext in the _dbConnectionPool.AuthenticationContexts.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Updated the new dbAuthenticationContext in the _dbConnectionPool.AuthenticationContexts.", ObjectID); } else { - SqlClientEventSource.Log.TraceEvent(" {0}#, AddOrUpdate attempted on _dbConnectionPool.AuthenticationContexts, but it did not update the new value.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, AddOrUpdate attempted on _dbConnectionPool.AuthenticationContexts, but it did not update the new value.", ObjectID); } #endif } @@ -2459,17 +2459,17 @@ internal void OnFeatureExtAck(int featureId, byte[] data) } case TdsEnums.FEATUREEXT_TCE: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for TCE", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for TCE", ObjectID); if (data.Length < 1) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown version number for TCE", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown version number for TCE", ObjectID); throw SQL.ParsingError(ParsingErrorState.TceUnknownVersion); } byte supportedTceVersion = data[0]; if (0 == supportedTceVersion || supportedTceVersion > TdsEnums.MAX_SUPPORTED_TCE_VERSION) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Invalid version number for TCE", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Invalid version number for TCE", ObjectID); throw SQL.ParsingErrorValue(ParsingErrorState.TceInvalidVersion, supportedTceVersion); } @@ -2488,32 +2488,32 @@ internal void OnFeatureExtAck(int featureId, byte[] data) case TdsEnums.FEATUREEXT_UTF8SUPPORT: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for UTF8 support", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for UTF8 support", ObjectID); if (data.Length < 1) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown value for UTF8 support", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown value for UTF8 support", ObjectID); throw SQL.ParsingError(); } break; } case TdsEnums.FEATUREEXT_DATACLASSIFICATION: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for DATACLASSIFICATION", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for DATACLASSIFICATION", ObjectID); if (data.Length < 1) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown token for DATACLASSIFICATION", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown token for DATACLASSIFICATION", ObjectID); throw SQL.ParsingError(ParsingErrorState.CorruptedTdsStream); } byte supportedDataClassificationVersion = data[0]; if ((0 == supportedDataClassificationVersion) || (supportedDataClassificationVersion > TdsEnums.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION)) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Invalid version number for DATACLASSIFICATION", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Invalid version number for DATACLASSIFICATION", ObjectID); throw SQL.ParsingErrorValue(ParsingErrorState.DataClassificationInvalidVersion, supportedDataClassificationVersion); } if (data.Length != 2) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown token for DATACLASSIFICATION", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown token for DATACLASSIFICATION", ObjectID); throw SQL.ParsingError(ParsingErrorState.CorruptedTdsStream); } byte enabled = data[1]; diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalTransaction.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalTransaction.cs index b972b47444..872074006f 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalTransaction.cs @@ -52,7 +52,7 @@ internal SqlInternalTransaction(SqlInternalConnection innerConnection, Transacti internal SqlInternalTransaction(SqlInternalConnection innerConnection, TransactionType type, SqlTransaction outerTransaction, long transactionId) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Created for connection {1}#, outer transaction {2}#, Type {3}", ObjectID, innerConnection.ObjectID, (null != outerTransaction) ? outerTransaction.ObjectID : -1, (int)type); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Created for connection {1}, outer transaction {2}, Type {3}", ObjectID, innerConnection.ObjectID, (null != outerTransaction) ? outerTransaction.ObjectID : -1, (int)type); _innerConnection = innerConnection; _transactionType = type; @@ -254,7 +254,7 @@ internal void CloseFromConnection() SqlInternalConnection innerConnection = _innerConnection; Debug.Assert(innerConnection != null, "How can we be here if the connection is null?"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Closing", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Closing", ObjectID); bool processFinallyBlock = true; try { @@ -280,7 +280,7 @@ internal void CloseFromConnection() internal void Commit() { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); if (_innerConnection.IsLockedForBulkCopy) { @@ -339,7 +339,7 @@ internal void Dispose() private /*protected override*/ void Dispose(bool disposing) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Disposing", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Disposing", ObjectID); if (disposing) { if (null != _innerConnection) @@ -390,7 +390,7 @@ internal void InitParent(SqlTransaction transaction) internal void Rollback() { - var scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + var scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); if (_innerConnection.IsLockedForBulkCopy) { throw SQL.ConnectionLockedForBcpEvent(); @@ -432,7 +432,7 @@ internal void Rollback() internal void Rollback(string transactionName) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#, transactionName='{transactionName}'", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}, transactionName={1}", ObjectID, transactionName); if (_innerConnection.IsLockedForBulkCopy) { throw SQL.ConnectionLockedForBcpEvent(); @@ -468,7 +468,7 @@ internal void Rollback(string transactionName) internal void Save(string savePointName) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#, savePointName='{savePointName}'", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}, savePointName={1}", ObjectID, savePointName); _innerConnection.ValidateConnectionForExecute(null); // ROLLBACK takes either a save point name or a transaction name. It will rollback the 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 09ac390078..0ffb0db1f8 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 @@ -142,8 +142,8 @@ override public void Commit() ZombieCheck(); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -209,7 +209,7 @@ override public void Rollback() if (IsYukonPartialZombie) { // Put something in the trace in case a customer has an issue - SqlClientEventSource.Log.AdvanceTrace(" {0}# partial zombie no rollback required", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} partial zombie no rollback required", ObjectID); _internalTransaction = null; // yukon zombification } else @@ -217,8 +217,8 @@ override public void Rollback() ZombieCheck(); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -256,7 +256,7 @@ public void Rollback(string transactionName) Guid operationId = s_diagnosticListener.WriteTransactionRollbackBefore(_isolationLevel, _connection, transactionName); ZombieCheck(); - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}# transactionName='{1}'", ObjectID, transactionName); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} transactionName='{1}'", ObjectID, transactionName); SqlStatistics statistics = null; try { @@ -295,7 +295,7 @@ public void Save(string savePointName) ZombieCheck(); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}# savePointName='{1}'", ObjectID, savePointName); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} savePointName='{1}'", ObjectID, savePointName); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -323,7 +323,7 @@ internal void Zombie() SqlInternalConnection internalConnection = (_connection.InnerConnection as SqlInternalConnection); if (null != internalConnection && !_isFromAPI) { - SqlClientEventSource.Log.AdvanceTrace(" {0}# yukon deferred zombie", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} yukon deferred zombie", ObjectID); } else { 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 723559a4fa..0a53bd2998 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 @@ -543,7 +543,7 @@ internal void EnableMars() internal TdsParserStateObject CreateSession() { TdsParserStateObject session = TdsParserStateObjectFactory.Singleton.CreateSessionObject(this, _pMarsPhysicalConObj, true); - SqlClientEventSource.Log.AdvanceTrace(" {0}# created session {1}", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} created session {1}", ObjectID, session.ObjectID); return session; } @@ -555,12 +555,12 @@ internal TdsParserStateObject GetSession(object owner) session = _sessionPool.GetSession(owner); Debug.Assert(!session.HasPendingData, "pending data on a pooled MARS session"); - SqlClientEventSource.Log.AdvanceTrace(" {0}# getting session {1} from pool", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} getting session {1} from pool", ObjectID, session.ObjectID); } else { session = _physicalStateObj; - SqlClientEventSource.Log.AdvanceTrace(" {0}# getting physical session {1}", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} getting physical session {1}", ObjectID, session.ObjectID); } Debug.Assert(session._outputPacketNumber == 1, "The packet number is expected to be 1"); return session; @@ -952,7 +952,7 @@ private PreLoginHandshakeStatus ConsumePreLoginHandshake(bool encrypt, bool trus // Only 0x00 and 0x01 are accepted values from the server. if (payload[payloadOffset] != 0x00 && payload[payloadOffset] != 0x01) { - SqlClientEventSource.Log.TraceEvent(" {0}#, " + + SqlClientEventSource.Log.TraceEvent(" {0}, " + "Server sent an unexpected value for FedAuthRequired PreLogin Option. Value was {1}.", ObjectID, (int)payload[payloadOffset]); throw SQL.ParsingErrorValue(ParsingErrorState.FedAuthRequiredPreLoginResponseInvalidValue, (int)payload[payloadOffset]); } @@ -989,8 +989,11 @@ private PreLoginHandshakeStatus ConsumePreLoginHandshake(bool encrypt, bool trus internal void Deactivate(bool connectionIsDoomed) { // Called when the connection that owns us is deactivated. - SqlClientEventSource.Log.AdvanceTrace(" {0}# deactivating", ObjectID); - SqlClientEventSource.Log.StateDumpEvent(" {0}# {1}", ObjectID, TraceString()); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} deactivating", ObjectID); + if (SqlClientEventSource.Log.IsStateDumpEnabled()) + { + SqlClientEventSource.Log.StateDumpEvent(" {0} {1}", ObjectID, TraceString()); + } if (MARSOn) { @@ -1150,7 +1153,7 @@ internal void ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool calle if (temp.Count == 0) { - SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, unexpectedly empty warnings/errors under lock {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, unexpectedly empty warnings/errors under lock {0}", ObjectID); } Debug.Assert(temp != null, "TdsParser::ThrowExceptionAndWarning: null errors collection!"); Debug.Assert(temp.Count > 0, "TdsParser::ThrowExceptionAndWarning called with no exceptions or warnings!"); @@ -1263,7 +1266,7 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj) #if DEBUG // There is an exception here for MARS as its possible that another thread has closed the connection just as we see an error Debug.Assert(SniContext.Undefined != stateObj.DebugOnlyCopyOfSniContext || ((_fMARS) && ((_state == TdsParserState.Closed) || (_state == TdsParserState.Broken))), "SniContext must not be None"); - SqlClientEventSource.Log.SNITrace(" SNIContext must not be None = {0}, _fMARS = {1}, TDS Parser State = {2}", stateObj.DebugOnlyCopyOfSniContext, _fMARS, _state); + SqlClientEventSource.Log.SNITraceEvent(" SNIContext must not be None = {0}, _fMARS = {1}, TDS Parser State = {2}", stateObj.DebugOnlyCopyOfSniContext, _fMARS, _state); #endif SNIErrorDetails details = GetSniErrorDetails(); @@ -1275,17 +1278,17 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj) { case (int)SNINativeMethodWrapper.SniSpecialErrors.MultiSubnetFailoverWithMoreThan64IPs: // Connecting with the MultiSubnetFailover connection option to a SQL Server instance configured with more than 64 IP addresses is not supported. - SqlClientEventSource.Log.AdvanceTrace(" Connecting with the MultiSubnetFailover connection option to a SQL Server instance configured with more than 64 IP addresses is not supported."); + SqlClientEventSource.Log.AdvancedTraceEvent(" Connecting with the MultiSubnetFailover connection option to a SQL Server instance configured with more than 64 IP addresses is not supported."); throw SQL.MultiSubnetFailoverWithMoreThan64IPs(); case (int)SNINativeMethodWrapper.SniSpecialErrors.MultiSubnetFailoverWithInstanceSpecified: // Connecting to a named SQL Server instance using the MultiSubnetFailover connection option is not supported. - SqlClientEventSource.Log.AdvanceTrace(" Connecting to a named SQL Server instance using the MultiSubnetFailover connection option is not supported."); + SqlClientEventSource.Log.AdvancedTraceEvent(" Connecting to a named SQL Server instance using the MultiSubnetFailover connection option is not supported."); throw SQL.MultiSubnetFailoverWithInstanceSpecified(); case (int)SNINativeMethodWrapper.SniSpecialErrors.MultiSubnetFailoverWithNonTcpProtocol: // Connecting to a SQL Server instance using the MultiSubnetFailover connection option is only supported when using the TCP protocol. - SqlClientEventSource.Log.AdvanceTrace(" Connecting to a SQL Server instance using the MultiSubnetFailover connection option is only supported when using the TCP protocol."); + SqlClientEventSource.Log.AdvancedTraceEvent(" Connecting to a SQL Server instance using the MultiSubnetFailover connection option is only supported when using the TCP protocol."); throw SQL.MultiSubnetFailoverWithNonTcpProtocol(); // continue building SqlError instance } @@ -1293,30 +1296,30 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj) // PInvoke code automatically sets the length of the string for us // So no need to look for \0 string errorMessage = details.errorMessage; - SqlClientEventSource.Log.AdvanceTrace("< sc.TdsParser.ProcessSNIError |ERR|ADV > Error message Detail: {0}", details.errorMessage); - - // Format SNI errors and add Context Information - // - // General syntax is: - // - // (provider:, error: - ) - // - // errorMessage | sniError | - // ------------------------------------------- - // ==null | x | must never happen - // !=null | != 0 | retrieve corresponding errorMessage from resources - // !=null | == 0 | replace text left of errorMessage - // + SqlClientEventSource.Log.AdvancedTraceEvent("< sc.TdsParser.ProcessSNIError |ERR|ADV > Error message Detail: {0}", details.errorMessage); + + /* Format SNI errors and add Context Information + * + * General syntax is: + * + * (provider:, error: - ) + * + * errorMessage | sniError | + * ------------------------------------------- + * ==null | x | must never happen + * !=null | != 0 | retrieve corresponding errorMessage from resources + * !=null | == 0 | replace text left of errorMessage + */ if (TdsParserStateObjectFactory.UseManagedSNI) { Debug.Assert(!string.IsNullOrEmpty(details.errorMessage) || details.sniErrorNumber != 0, "Empty error message received from SNI"); - SqlClientEventSource.Log.AdvanceTrace(" Empty error message received from SNI. Error Message = {0}, SNI Error Number ={1}", details.errorMessage, details.sniErrorNumber); + SqlClientEventSource.Log.AdvancedTraceEvent(" Empty error message received from SNI. Error Message = {0}, SNI Error Number ={1}", details.errorMessage, details.sniErrorNumber); } else { Debug.Assert(!string.IsNullOrEmpty(details.errorMessage), "Empty error message received from SNI"); - SqlClientEventSource.Log.AdvanceTrace(" Empty error message received from SNI. Error Message = {0}", details.errorMessage); + SqlClientEventSource.Log.AdvancedTraceEvent(" Empty error message received from SNI. Error Message = {0}", details.errorMessage); } string sniContextEnumName = TdsEnums.GetSniContextEnumName(stateObj.SniContext); @@ -1326,7 +1329,7 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj) string providerName = SRHelper.GetResourceString(providerRid); Debug.Assert(!string.IsNullOrEmpty(providerName), $"invalid providerResourceId '{providerRid}'"); uint win32ErrorCode = details.nativeError; - SqlClientEventSource.Log.AdvanceTrace(" SNI Native Error Code = {0}", win32ErrorCode); + SqlClientEventSource.Log.AdvancedTraceEvent(" SNI Native Error Code = {0}", win32ErrorCode); if (details.sniErrorNumber == 0) { // Provider error. The message from provider is preceded with non-localizable info from SNI @@ -1334,9 +1337,9 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj) // int iColon = errorMessage.IndexOf(':'); Debug.Assert(0 <= iColon, "':' character missing in sni errorMessage"); - SqlClientEventSource.Log.AdvanceTrace(" ':' character missing in sni errorMessage. Error Mesage index of ':' = {0}", iColon); + SqlClientEventSource.Log.AdvancedTraceEvent(" ':' character missing in sni errorMessage. Error Mesage index of ':' = {0}", iColon); Debug.Assert(errorMessage.Length > iColon + 1 && errorMessage[iColon + 1] == ' ', "Expecting a space after the ':' character"); - SqlClientEventSource.Log.AdvanceTrace(" Expecting a space after the ':' character. Error Mesage Length = {0}", errorMessage.Length); + SqlClientEventSource.Log.AdvancedTraceEvent(" Expecting a space after the ':' character. Error Mesage Length = {0}", errorMessage.Length); // extract the message excluding the colon and trailing cr/lf chars if (0 <= iColon) { @@ -1384,7 +1387,10 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj) } errorMessage = string.Format("{0} (provider: {1}, error: {2} - {3})", sqlContextInfo, providerName, (int)details.sniErrorNumber, errorMessage); - SqlClientEventSource.Log.AdvanceTrace(" SNI Error Message. Native Error = {0}, Line Number ={1}, Function ={2}, Exception ={3}, Server = {4}", (int)details.nativeError, (int)details.lineNumber, details.function, details.exception, _server); + + SqlClientEventSource.Log.AdvancedTraceErrorEvent(" SNI Error Message. Native Error = {0}, Line Number ={1}, Function ={2}, Exception ={3}, Server = {4}", + (int)details.nativeError, (int)details.lineNumber, details.function, details.exception, _server); + return new SqlError((int)details.nativeError, 0x00, TdsEnums.FATAL_ERROR_CLASS, _server, errorMessage, details.function, (int)details.lineNumber, details.nativeError, details.exception); } @@ -1867,7 +1873,7 @@ internal bool TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataRead Debug.Fail($"unexpected token; token = {token,-2:X2}"); _state = TdsParserState.Broken; _connHandler.BreakConnection(); - SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, unexpected TDS token found {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, unexpected TDS token found {0}", ObjectID); throw SQL.ParsingError(); } @@ -3588,7 +3594,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, SqlFedAuthInfo tempFedAuthInfo = new SqlFedAuthInfo(); // Skip reading token length, since it has already been read in caller - SqlClientEventSource.Log.AdvanceTrace(" FEDAUTHINFO token stream length = {0}", tokenLen); + SqlClientEventSource.Log.AdvancedTraceEvent(" FEDAUTHINFO token stream length = {0}", tokenLen); if (tokenLen < sizeof(uint)) { // the token must at least contain a DWORD indicating the number of info IDs @@ -3604,14 +3610,14 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, throw SQL.ParsingError(ParsingErrorState.FedAuthInfoFailedToReadCountOfInfoIds); } tokenLen -= sizeof(uint); // remaining length is shortened since we read optCount - SqlClientEventSource.Log.AdvanceTrace(" CountOfInfoIDs = {0}", optionsCount.ToString(CultureInfo.InvariantCulture)); + SqlClientEventSource.Log.AdvancedTraceEvent(" CountOfInfoIDs = {0}", optionsCount.ToString(CultureInfo.InvariantCulture)); if (tokenLen > 0) { // read the rest of the token byte[] tokenData = new byte[tokenLen]; int totalRead = 0; bool successfulRead = stateObj.TryReadByteArray(tokenData, tokenLen, out totalRead); - SqlClientEventSource.Log.AdvanceTrace(" Read rest of FEDAUTHINFO token stream: {0}", BitConverter.ToString(tokenData, 0, totalRead)); + SqlClientEventSource.Log.AdvancedTraceEvent(" Read rest of FEDAUTHINFO token stream: {0}", BitConverter.ToString(tokenData, 0, totalRead)); if (!successfulRead || totalRead != tokenLen) { @@ -3636,7 +3642,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, byte id = tokenData[currentOptionOffset]; uint dataLen = BitConverter.ToUInt32(tokenData, checked((int)(currentOptionOffset + 1))); uint dataOffset = BitConverter.ToUInt32(tokenData, checked((int)(currentOptionOffset + 5))); - SqlClientEventSource.Log.AdvanceTrace(" FedAuthInfoOpt: ID={0}, DataLen={1}, Offset={2}", id, dataLen.ToString(CultureInfo.InvariantCulture), dataOffset.ToString(CultureInfo.InvariantCulture)); + SqlClientEventSource.Log.AdvancedTraceEvent(" FedAuthInfoOpt: ID={0}, DataLen={1}, Offset={2}", id, dataLen.ToString(CultureInfo.InvariantCulture), dataOffset.ToString(CultureInfo.InvariantCulture)); // offset is measured from optCount, so subtract to make offset measured // from the beginning of tokenData @@ -3668,7 +3674,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, SqlClientEventSource.Log.TraceEvent(" FedAuthInfoData is not in unicode format.", "ERR"); throw SQL.ParsingError(ParsingErrorState.FedAuthInfoDataNotUnicode, e); } - SqlClientEventSource.Log.AdvanceTrace(" FedAuthInfoData: {0}", data); + SqlClientEventSource.Log.AdvancedTraceEvent(" FedAuthInfoData: {0}", data); // store data in tempFedAuthInfo switch ((TdsEnums.FedAuthInfoId)id) @@ -3682,7 +3688,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, break; default: - SqlClientEventSource.Log.AdvanceTrace(" Ignoring unknown federated authentication info option: {0}", id); + SqlClientEventSource.Log.AdvancedTraceEvent(" Ignoring unknown federated authentication info option: {0}", id); break; } } @@ -8019,7 +8025,7 @@ internal void TdsLogin(SqlLogin rec, TdsEnums.FeatureExtension requestedFeatures } WriteInt(log7Flags, _physicalStateObj); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, TDS Login7 flags = {1}:", ObjectID, log7Flags); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, TDS Login7 flags = {1}:", ObjectID, log7Flags); WriteInt(0, _physicalStateObj); // ClientTimeZone is not used WriteInt(0, _physicalStateObj); // LCID is unused by server @@ -8691,7 +8697,7 @@ internal Task TdsExecuteSQLBatch(string text, int timeout, SqlNotificationReques if ((!_fMARS) && (_physicalStateObj.HasOpenResult)) { - SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, non-MARs connection with an open result {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, non-MARs connection with an open result {0}", ObjectID); } stateObj.SniContext = SniContext.Snix_Execute; @@ -8820,7 +8826,7 @@ internal Task TdsExecuteSQLBatch(string text, int timeout, SqlNotificationReques if ((!_fMARS) && (_physicalStateObj.HasOpenResult)) { - SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, non-MARs connection with an open result {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, non-MARs connection with an open result {0}", ObjectID); } stateObj.SniContext = SniContext.Snix_Execute; @@ -9641,7 +9647,7 @@ private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefa } var sendDefaultValue = sendDefault ? 1 : 0; - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Sending parameter '{1}', default flag={2}, metadata:{3}", ObjectID, param.ParameterName, sendDefaultValue, metaData.TraceString(3)); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Sending parameter '{1}', default flag={2}, metadata:{3}", ObjectID, param.ParameterName, sendDefaultValue, metaData.TraceString(3)); // // Write parameter metadata @@ -10680,7 +10686,7 @@ private void WriteQueryNotificationHeaderData(SqlNotificationRequest notificatio Debug.Assert(ushort.MaxValue >= service.Length, "Service length is out of range"); Debug.Assert(-1 <= timeout, "Timeout"); - SqlClientEventSource.Log.NotificationsTraceEvent(" NotificationRequest: userData: '{0}', options: '{1}', timeout: '{2}'", notificationRequest.UserData, notificationRequest.Options, notificationRequest.Timeout); + SqlClientEventSource.Log.NotificationTraceEvent(" NotificationRequest: userData: '{0}', options: '{1}', timeout: '{2}'", notificationRequest.UserData, notificationRequest.Options, notificationRequest.Timeout); WriteShort(TdsEnums.HEADERTYPE_QNOTIFICATION, stateObj); // Query notifications Type WriteShort(callbackId.Length * 2, stateObj); // Length in bytes @@ -12643,13 +12649,13 @@ private bool TryProcessUDTMetaData(SqlMetaDataPriv metaData, TdsParserStateObjec ; internal string TraceString() { - return String.Format(/*IFormatProvider*/ null, + return string.Format(/*IFormatProvider*/ null, StateTraceFormatString, - null == _physicalStateObj, - null == _pMarsPhysicalConObj, + null == _physicalStateObj ? bool.TrueString : bool.FalseString, + null == _pMarsPhysicalConObj ? bool.TrueString : bool.FalseString, _state, _server, - _fResetConnection, + _fResetConnection ? bool.TrueString : bool.FalseString, null == _defaultCollation ? "(null)" : _defaultCollation.TraceString(), _defaultCodePage, _defaultLCID, @@ -12661,17 +12667,17 @@ internal string TraceString() _retainedTransactionId, _nonTransactedOpenResultCount, null == _connHandler ? "(null)" : _connHandler.ObjectID.ToString((IFormatProvider)null), - _fMARS, + _fMARS ? bool.TrueString : bool.FalseString, null == _sessionPool ? "(null)" : _sessionPool.TraceString(), - _isYukon, + _isYukon ? bool.TrueString : bool.FalseString, null == _sniSpnBuffer ? "(null)" : _sniSpnBuffer.Length.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.ErrorCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.WarningCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionErrorCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionWarningCount.ToString((IFormatProvider)null), - null == _statistics, - _statisticsIsInTransaction, - _fPreserveTransaction, + null == _statistics ? bool.TrueString : bool.FalseString, + _statisticsIsInTransaction ? bool.TrueString : bool.FalseString, + _fPreserveTransaction ? bool.TrueString : bool.FalseString, null == _connHandler ? "(null)" : _connHandler.ConnectionOptions.MultiSubnetFailover.ToString((IFormatProvider)null)); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs index b25b9eaef1..29791e4c4c 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs @@ -36,7 +36,7 @@ internal TdsParserSessionPool(TdsParser parser) _cache = new List(); _freeStateObjects = new TdsParserStateObject[MaxInactiveCount]; _freeStateObjectCount = 0; - SqlClientEventSource.Log.AdvanceTrace(" {0}# created session pool for parser {1}", ObjectID, parser.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} created session pool for parser {1}", ObjectID, parser.ObjectID); } private bool IsDisposed @@ -60,7 +60,7 @@ internal void Deactivate() // When being deactivated, we check all the sessions in the // cache to make sure they're cleaned up and then we dispose of // sessions that are past what we want to keep around. - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}# deactivating cachedCount={1}", ObjectID, _cachedCount); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} deactivating cachedCount={1}", ObjectID, _cachedCount); try { lock (_cache) @@ -79,7 +79,7 @@ internal void Deactivate() if (session.IsOrphaned) { // TODO: consider adding a performance counter for the number of sessions we reclaim - SqlClientEventSource.Log.AdvanceTrace(" {0}# reclaiming session {1}", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} reclaiming session {1}", ObjectID, session.ObjectID); PutSession(session); } } @@ -96,7 +96,7 @@ internal void Deactivate() internal void Dispose() { - SqlClientEventSource.Log.AdvanceTrace(" {0}# disposing cachedCount={1}", ObjectID, _cachedCount); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} disposing cachedCount={1}", ObjectID, _cachedCount); lock (_cache) { // Dispose free sessions @@ -154,7 +154,7 @@ internal TdsParserStateObject GetSession(object owner) { // No free objects, create a new one session = _parser.CreateSession(); - SqlClientEventSource.Log.AdvanceTrace(" {0}# adding session {1} to pool", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} adding session {1} to pool", ObjectID, session.ObjectID); _cache.Add(session); _cachedCount = _cache.Count; @@ -163,7 +163,7 @@ internal TdsParserStateObject GetSession(object owner) session.Activate(owner); } - SqlClientEventSource.Log.AdvanceTrace(" {0}# using session {1}", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} using session {1}", ObjectID, session.ObjectID); return session; } @@ -185,7 +185,7 @@ internal void PutSession(TdsParserStateObject session) else if ((okToReuse) && (_freeStateObjectCount < MaxInactiveCount)) { // Session is good to re-use and our cache has space - SqlClientEventSource.Log.AdvanceTrace(" {0}# keeping session {1} cachedCount={2}", ObjectID, session.ObjectID, _cachedCount); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} keeping session {1} cachedCount={2}", ObjectID, session.ObjectID, _cachedCount); Debug.Assert(!session.HasPendingData, "pending data on a pooled session?"); _freeStateObjects[_freeStateObjectCount] = session; @@ -194,7 +194,7 @@ internal void PutSession(TdsParserStateObject session) else { // Either the session is bad, or we have no cache space - so dispose the session and remove it - SqlClientEventSource.Log.AdvanceTrace(" {0}# disposing session {1} cachedCount={2}", ObjectID, session.ObjectID, _cachedCount); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} disposing session {1} cachedCount={2}", ObjectID, session.ObjectID, _cachedCount); bool removed = _cache.Remove(session); Debug.Assert(removed, "session not in pool?"); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs index 690b28c65e..8e5d970bdb 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs @@ -540,8 +540,8 @@ internal bool TryInitialize(TdsParserStateObject stateObj, int columnsCount) return false; } - SqlClientEventSource.Log.TraceEvent(" {0}#, NBCROW bitmap received, column count = {1}", stateObj.ObjectID, columnsCount); - SqlClientEventSource.Log.TraceBinEvent(" NBCROW bitmap data: ", _nullBitmap, (ushort)_nullBitmap.Length); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, NBCROW bitmap received, column count = {1}", stateObj.ObjectID, columnsCount); + SqlClientEventSource.Log.AdvancedTraceBinEvent(" NBCROW bitmap data: ", _nullBitmap, (ushort)_nullBitmap.Length); return true; } @@ -869,7 +869,7 @@ internal void DecrementOpenResultCount() internal int DecrementPendingCallbacks(bool release) { int remaining = Interlocked.Decrement(ref _pendingCallbacks); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, after decrementing _pendingCallbacks: {1}", ObjectID, _pendingCallbacks); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, after decrementing _pendingCallbacks: {1}", ObjectID, _pendingCallbacks); FreeGcHandle(remaining, release); // NOTE: TdsParserSessionPool may call DecrementPendingCallbacks on a TdsParserStateObject which is already disposed // This is not dangerous (since the stateObj is no longer in use), but we need to add a workaround in the assert for it diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Windows.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Windows.cs index 2f609b5d91..c96c32a551 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Windows.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Windows.cs @@ -39,13 +39,13 @@ public TdsParserStateObject CreateTdsParserStateObject(TdsParser parser) { if (UseManagedSNI) { - SqlClientEventSource.Log.TraceEvent(" Found AppContext switch '{0}#' enabled, managed networking implementation will be used." + SqlClientEventSource.Log.TraceEvent(" Found AppContext switch '{0}' enabled, managed networking implementation will be used." , UseManagedNetworkingOnWindows); return new TdsParserStateObjectManaged(parser); } else { - SqlClientEventSource.Log.TraceEvent(" AppContext switch '{0}#' not enabled, native networking implementation will be used." + SqlClientEventSource.Log.TraceEvent(" AppContext switch '{0}' not enabled, native networking implementation will be used." , UseManagedNetworkingOnWindows); return new TdsParserStateObjectNative(parser); } diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs index 8723e77cda..5ac0634202 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs @@ -61,7 +61,7 @@ public sealed partial class SqlFileStream : System.IO.Stream /// public SqlFileStream(string path, byte[] transactionContext, FileAccess access, FileOptions options, long allocationSize) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}# access={1} options={2} path='{3}'", ObjectID, (int)access, (int)options, path); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} access={1} options={2} path='{3}'", ObjectID, (int)access, (int)options, path); try { //----------------------------------------------------------------- @@ -599,7 +599,7 @@ long allocationSize eaBuffer: b, eaLength: (uint)fullSize); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, desiredAccess=0x{1}, allocationSize={2}, " + + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, desiredAccess=0x{1}, allocationSize={2}, " + "fileAttributes=0x{3}, shareAccess=0x{4}, dwCreateDisposition=0x{5}, createOptions=0x{ dwCreateOptions}", ObjectID, (int)nDesiredAccess, allocationSize, 0, (int)nShareAccess, dwCreateDisposition); retval = status; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/ActivityCorrelator.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/ActivityCorrelator.cs index 550cbf24e0..27d4ffbdbb 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/ActivityCorrelator.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/ActivityCorrelator.cs @@ -15,30 +15,15 @@ namespace Microsoft.Data.Common internal static class ActivityCorrelator { - internal class ActivityId + internal sealed class ActivityId { - internal Guid Id { get; private set; } - internal UInt32 Sequence { get; private set; } + internal readonly Guid Id; + internal readonly uint Sequence; - internal ActivityId() + internal ActivityId(uint sequence) { this.Id = Guid.NewGuid(); - this.Sequence = 0; // the first event will start 1 - } - - // copy-constructor - internal ActivityId(ActivityId activity) - { - this.Id = activity.Id; - this.Sequence = activity.Sequence; - } - - internal void Increment() - { - unchecked - { - ++this.Sequence; - } + this.Sequence = sequence; } public override string ToString() @@ -51,7 +36,7 @@ public override string ToString() // The Sequence number will be incremented when each event happens. // Correlation along threads is consistent with the current XEvent mechanisam at server. [ThreadStaticAttribute] - static ActivityId tlsActivity; + static ActivityId t_tlsActivity; /// /// Get the current ActivityId @@ -60,12 +45,12 @@ internal static ActivityId Current { get { - if (tlsActivity == null) + if (t_tlsActivity == null) { - tlsActivity = new ActivityId(); + t_tlsActivity = new ActivityId(1); } - return new ActivityId(tlsActivity); + return t_tlsActivity; } } @@ -75,14 +60,9 @@ internal static ActivityId Current /// ActivityId internal static ActivityId Next() { - if (tlsActivity == null) - { - tlsActivity = new ActivityId(); - } - - tlsActivity.Increment(); - - return new ActivityId(tlsActivity); + t_tlsActivity = new ActivityId(t_tlsActivity?.Sequence ?? 0); + + return t_tlsActivity; } } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs index df45de05c9..02afb1f3e5 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DBConnectionString.cs @@ -470,7 +470,7 @@ static private string[] NoDuplicateUnion(string[] a, string[] b) private static string[] ParseRestrictions(string restrictions, Hashtable synonyms) { #if DEBUG - SqlClientEventSource.Log.AdvanceTrace(" Restrictions='{0}'", restrictions); + SqlClientEventSource.Log.AdvancedTraceEvent(" Restrictions='{0}'", restrictions); #endif List restrictionValues = new List(); StringBuilder buffer = new StringBuilder(restrictions.Length); @@ -486,7 +486,7 @@ private static string[] ParseRestrictions(string restrictions, Hashtable synonym if (!ADP.IsEmpty(keyname)) { #if DEBUG - SqlClientEventSource.Log.AdvanceTrace(" KeyName='{0}'", keyname); + SqlClientEventSource.Log.AdvancedTraceEvent(" KeyName='{0}'", keyname); #endif string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname); // MDAC 85144 if (ADP.IsEmpty(realkeyname)) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionOptions.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionOptions.cs index 62510f14ab..30c7d22443 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionOptions.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/DbConnectionOptions.cs @@ -627,7 +627,7 @@ internal string ExpandKeyword(string keyword, string replacementValue) [System.Diagnostics.Conditional("DEBUG")] private static void DebugTraceKeyValuePair(string keyname, string keyvalue, Hashtable synonyms) { - if (SqlClientEventSource.Log.IsAdvanceTraceOn()) + if (SqlClientEventSource.Log.IsAdvancedTraceOn()) { Debug.Assert(keyname == keyname.ToLower(CultureInfo.InvariantCulture), "missing ToLower"); string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname); @@ -637,11 +637,11 @@ private static void DebugTraceKeyValuePair(string keyname, string keyvalue, Hash // don't trace passwords ever! if (null != keyvalue) { - SqlClientEventSource.Log.AdvanceTrace(" KeyName='{0}', KeyValue='{1}'", keyname, keyvalue); + SqlClientEventSource.Log.AdvancedTraceEvent(" KeyName='{0}', KeyValue='{1}'", keyname, keyvalue); } else { - SqlClientEventSource.Log.AdvanceTrace(" KeyName='{0}'", keyname); + SqlClientEventSource.Log.AdvancedTraceEvent(" KeyName='{0}'", keyname); } } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/DataException.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/DataException.cs index 059d0acc6f..49f6551617 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/DataException.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/DataException.cs @@ -28,10 +28,10 @@ internal static class ExceptionBuilder Debug.Assert(null != e, "TraceException: null Exception"); if (null != e) { - SqlClientEventSource.Log.AdvanceTrace(trace, e.Message); + SqlClientEventSource.Log.AdvancedTraceEvent(trace, e.Message); try { - SqlClientEventSource.Log.AdvanceTrace(" Environment StackTrace = '{0}'", Environment.StackTrace); + SqlClientEventSource.Log.AdvancedTraceEvent(" Environment StackTrace = '{0}'", Environment.StackTrace); } catch (System.Security.SecurityException) { diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs index eaac2585c6..35cc1e92d2 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionFactory.cs @@ -87,7 +87,7 @@ public void ClearAllPools() public void ClearPool(DbConnection connection) { ADP.CheckArgumentNull(connection, "connection"); - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", GetObjectId(connection)); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", GetObjectId(connection)); try { DbConnectionPoolGroup poolGroup = GetConnectionPoolGroup(connection); @@ -151,7 +151,7 @@ internal DbConnectionInternal CreateNonPooledConnection(DbConnection owningConne PerformanceCounters.HardConnectsPerSecond.Increment(); newConnection.MakeNonPooledObject(owningConnection, PerformanceCounters); } - SqlClientEventSource.Log.TraceEvent(" {0}#, Non-pooled database connection created.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Non-pooled database connection created.", ObjectID); return newConnection; } @@ -167,7 +167,7 @@ internal DbConnectionInternal CreatePooledConnection(DbConnectionPool pool, DbCo PerformanceCounters.HardConnectsPerSecond.Increment(); newConnection.MakePooledConnection(pool); } - SqlClientEventSource.Log.TraceEvent(" {0}#, Pooled database connection created.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Pooled database connection created.", ObjectID); return newConnection; } @@ -362,7 +362,7 @@ internal bool TryGetConnection(DbConnection owningConnection, TaskCompletionSour // connection creation failed on semaphore waiting or if max pool reached if (connectionPool.IsRunning) { - SqlClientEventSource.Log.TraceEvent(" {0}#, GetConnection failed because a pool timeout occurred.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, GetConnection failed because a pool timeout occurred.", ObjectID); // If GetConnection failed while the pool is running, the pool timeout occurred. throw ADP.PooledOpenTimeout(); @@ -381,7 +381,7 @@ internal bool TryGetConnection(DbConnection owningConnection, TaskCompletionSour if (connection == null) { - SqlClientEventSource.Log.TraceEvent(" {0}#, GetConnection failed because a pool timeout occurred and all retries were exhausted.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, GetConnection failed because a pool timeout occurred and all retries were exhausted.", ObjectID); // exhausted all retries or timed out - give up throw ADP.PooledOpenTimeout(); @@ -408,7 +408,7 @@ private DbConnectionPool GetConnectionPool(DbConnection owningObject, DbConnecti // however, don't rebuild connectionOptions if no pooling is involved - let new connections do that work if (connectionPoolGroup.IsDisabled && (null != connectionPoolGroup.PoolGroupOptions)) { - SqlClientEventSource.Log.TraceEvent(" {0}#, DisabledPoolGroup={1}#", ObjectID, connectionPoolGroup.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, DisabledPoolGroup={1}", ObjectID, connectionPoolGroup.ObjectID); // reusing existing pool option in case user originally used SetConnectionPoolOptions DbConnectionPoolGroupOptions poolOptions = connectionPoolGroup.PoolGroupOptions; @@ -539,7 +539,7 @@ internal DbMetaDataFactory GetMetaDataFactory(DbConnectionPoolGroup connectionPo private void PruneConnectionPoolGroups(object state) { // when debugging this method, expect multiple threads at the same time - SqlClientEventSource.Log.AdvanceTrace(" {0}#", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}", ObjectID); // First, walk the pool release list and attempt to clear each // pool, when the pool is finally empty, we dispose of it. If the @@ -559,7 +559,7 @@ private void PruneConnectionPoolGroups(object state) if (0 == pool.Count) { _poolsToRelease.Remove(pool); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, ReleasePool={1}#", ObjectID, pool.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, ReleasePool={1}", ObjectID, pool.ObjectID); PerformanceCounters.NumberOfInactiveConnectionPools.Decrement(); } } @@ -584,7 +584,7 @@ private void PruneConnectionPoolGroups(object state) if (0 == poolsLeft) { _poolGroupsToRelease.Remove(poolGroup); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, ReleasePoolGroup={1}#", ObjectID, poolGroup.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, ReleasePoolGroup={1}", ObjectID, poolGroup.ObjectID); PerformanceCounters.NumberOfInactiveConnectionPoolGroups.Decrement(); } } @@ -650,7 +650,7 @@ internal void QueuePoolForRelease(DbConnectionPool pool, bool clearing) internal void QueuePoolGroupForRelease(DbConnectionPoolGroup poolGroup) { Debug.Assert(null != poolGroup, "null poolGroup?"); - SqlClientEventSource.Log.TraceEvent(" {0}#, poolGroup={1}#", ObjectID, poolGroup.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, poolGroup={1}", ObjectID, poolGroup.ObjectID); lock (_poolGroupsToRelease) { diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs index 095b105a0b..352182aa52 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionInternal.cs @@ -163,7 +163,7 @@ protected internal SysTx.Transaction EnlistedTransaction if (null != value) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Enlisting.", ObjectID, value.GetHashCode()); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Enlisting.", ObjectID, value.GetHashCode()); TransactionOutcomeEnlist(value); } } @@ -388,7 +388,7 @@ internal void ActivateConnection(SysTx.Transaction transaction) { // Internal method called from the connection pooler so we don't expose // the Activate method publicly. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Activating", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Activating", ObjectID); #if DEBUG int activateCount = Interlocked.Increment(ref _activateCount); Debug.Assert(1 == activateCount, "activated multiple times?"); @@ -459,7 +459,7 @@ internal virtual void CloseConnection(DbConnection owningObject, DbConnectionFac //////////////////////////////////////////////////////////////// Debug.Assert(null != owningObject, "null owningObject"); Debug.Assert(null != connectionFactory, "null connectionFactory"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}# Closing.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0} Closing.", ObjectID); // if an exception occurs after the state change but before the try block // the connection will be stuck in OpenBusy state. The commented out try-catch @@ -564,7 +564,7 @@ internal void DeactivateConnection() { // Internal method called from the connection pooler so we don't expose // the Deactivate method publicly. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Deactivating", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Deactivating", ObjectID); #if DEBUG int activateCount = Interlocked.Decrement(ref _activateCount); Debug.Assert(0 == activateCount, "activated multiple times?"); @@ -598,7 +598,7 @@ virtual internal void DelegatedTransactionEnded() // IMPORTANT NOTE: You must have taken a lock on the object before // you call this method to prevent race conditions with Clear and // ReclaimEmancipatedObjects. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Delegated Transaction Completed.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Delegated Transaction Completed.", ObjectID); if (1 == _pooledCount) { @@ -661,7 +661,7 @@ public virtual void Dispose() protected internal void DoNotPoolThisConnection() { _cannotBePooled = true; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Marking pooled object as non-poolable so it will be disposed", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Marking pooled object as non-poolable so it will be disposed", ObjectID); } /// Ensure that this connection cannot be put back into the pool. @@ -669,7 +669,7 @@ protected internal void DoNotPoolThisConnection() protected internal void DoomThisConnection() { _connectionIsDoomed = true; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Dooming", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Dooming", ObjectID); } // Reset connection doomed status so it can be re-connected and pooled. @@ -803,7 +803,7 @@ internal void PrePush(object expectedOwner) } //DbConnection x = (expectedOwner as DbConnection); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Preparing to push into pool, owning connection {1}#, pooledCount={2}", ObjectID, 0, _pooledCount); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Preparing to push into pool, owning connection {1}, pooledCount={2}", ObjectID, 0, _pooledCount); _pooledCount++; _owningObject.Target = null; // NOTE: doing this and checking for InternalError.PooledObjectHasOwner degrades the close by 2% @@ -835,7 +835,7 @@ internal void PostPop(object newOwner) _pooledCount--; //DbConnection x = (newOwner as DbConnection); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Preparing to pop from pool, owning connection {1}#, pooledCount={2}", ObjectID, 0, _pooledCount); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Preparing to pop from pool, owning connection {1}, pooledCount={2}", ObjectID, 0, _pooledCount); //3 // The following tests are retail assertions of things we can't allow to happen. if (null != Pool) @@ -892,7 +892,7 @@ internal void DetachCurrentTransactionIfEnded() // Detach transaction from connection. internal void DetachTransaction(SysTx.Transaction transaction, bool isExplicitlyReleasing) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction Completed. (pooledCount={1})", ObjectID, _pooledCount); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction Completed. (pooledCount={1})", ObjectID, _pooledCount); // potentially a multi-threaded event, so lock the connection to make sure we don't enlist in a new // transaction between compare and assignment. No need to short circuit outside of lock, since failed comparisons should @@ -933,7 +933,7 @@ internal void CleanupConnectionOnTransactionCompletion(SysTx.Transaction transac void TransactionCompletedEvent(object sender, SysTx.TransactionEventArgs e) { SysTx.Transaction transaction = e.Transaction; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction Completed. (pooledCount = {1})", ObjectID, _pooledCount); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction Completed. (pooledCount = {1})", ObjectID, _pooledCount); CleanupTransactionOnCompletion(transaction); CleanupConnectionOnTransactionCompletion(transaction); @@ -950,7 +950,7 @@ private void TransactionOutcomeEnlist(SysTx.Transaction transaction) internal void SetInStasis() { _isInStasis = true; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Non-Pooled Connection has Delegated Transaction, waiting to Dispose.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Non-Pooled Connection has Delegated Transaction, waiting to Dispose.", ObjectID); PerformanceCounters.NumberOfStasisConnections.Increment(); } @@ -958,11 +958,11 @@ private void TerminateStasis(bool returningToPool) { if (returningToPool) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Delegated Transaction has ended, connection is closed. Returning to general pool.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Delegated Transaction has ended, connection is closed. Returning to general pool.", ObjectID); } else { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Delegated Transaction has ended, connection is closed/leaked. Disposing.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Delegated Transaction has ended, connection is closed/leaked. Disposing.", ObjectID); } PerformanceCounters.NumberOfStasisConnections.Decrement(); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs index 19d00a3805..c753c9addd 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs @@ -81,7 +81,7 @@ internal TransactedConnectionPool(DbConnectionPool pool) Debug.Assert(null != pool, "null pool?"); _pool = pool; _transactedCxns = new Dictionary(); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Constructed for connection pool {1}#", ObjectID, _pool.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Constructed for connection pool {1}", ObjectID, _pool.ObjectID); } internal int ObjectID @@ -140,7 +140,7 @@ internal DbConnectionInternal GetTransactedObject(SysTx.Transaction transaction) if (null != transactedObject) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Popped.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Popped.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); } return transactedObject; } @@ -167,7 +167,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt lock (connections) { Debug.Assert(0 > connections.IndexOf(transactedObject), "adding to pool a second time?"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); connections.Add(transactedObject); } } @@ -202,13 +202,13 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt lock (connections) { Debug.Assert(0 > connections.IndexOf(transactedObject), "adding to pool a second time?"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); connections.Add(transactedObject); } } else { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Adding List to transacted pool.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Adding List to transacted pool.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); // add the connection/transacted object to the list newConnections.Add(transactedObject); @@ -236,7 +236,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt } } } - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Added.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Added.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); } Pool.PerformanceCounters.NumberOfFreeConnections.Increment(); @@ -245,7 +245,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionInternal transactedObject) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); TransactedConnectionList connections; int entry = -1; @@ -279,7 +279,7 @@ internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionIntern // safely remove the list from the transacted pool. if (0 >= connections.Count) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Removing List from transacted pool.", ObjectID, transaction.GetHashCode()); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Removing List from transacted pool.", ObjectID, transaction.GetHashCode()); _transactedCxns.Remove(transaction); // we really need to dispose our connection list; it may have @@ -296,7 +296,7 @@ internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionIntern else { //Debug.Assert ( false, "TransactionCompletedEvent fired before PutTransactedObject put the connection in the transacted pool." ); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Transacted pool not yet created prior to transaction completing. Connection may be leaked.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Transacted pool not yet created prior to transaction completing. Connection may be leaked.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); } } @@ -523,7 +523,7 @@ protected override bool ReleaseHandle() _poolCreateRequest = new WaitCallback(PoolCreateRequest); // used by CleanupCallback _state = State.Running; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Constructed.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Constructed.", ObjectID); //_cleanupTimer & QueuePoolCreateRequest is delayed until DbConnectionPoolGroup calls // StartBackgroundCallbacks after pool is actually in the collection @@ -671,7 +671,7 @@ private void CleanupCallback(Object state) // // With this logic, objects are pruned from the pool if unused for // at least one period but not more than two periods. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}", ObjectID); // Destroy free objects that put us above MinPoolSize from old stack. while (Count > MinPoolSize) @@ -745,7 +745,7 @@ private void CleanupCallback(Object state) break; Debug.Assert(obj != null, "null connection is not expected"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, ChangeStacks={1}#", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, ChangeStacks={1}", ObjectID, obj.ObjectID); Debug.Assert(!obj.IsEmancipated, "pooled object not in pool"); Debug.Assert(obj.CanBePooled, "pooled object is not poolable"); @@ -760,7 +760,7 @@ private void CleanupCallback(Object state) internal void Clear() { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Clearing.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Clearing.", ObjectID); DbConnectionInternal obj; // First, quickly doom everything. @@ -796,7 +796,7 @@ internal void Clear() // Finally, reclaim everything that's emancipated (which, because // it's been doomed, will cause it to be disposed of as well) ReclaimEmancipatedObjects(); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Cleared.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Cleared.", ObjectID); } private Timer CreateCleanupTimer() @@ -886,7 +886,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio } } } - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Added to pool.", ObjectID, newObj != null ? newObj?.ObjectID.ToString() ?? "null" : "null"); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Added to pool.", ObjectID, newObj != null ? newObj?.ObjectID.ToString() ?? "null" : "null"); // Reset the error wait: _errorWait = ERROR_WAIT_DEFAULT; @@ -947,7 +947,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio private void DeactivateObject(DbConnectionInternal obj) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Deactivating.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Deactivating.", ObjectID, obj.ObjectID); obj.DeactivateConnection(); // we presume this operation is safe outside of a lock... bool returnToGeneralPool = false; @@ -1087,11 +1087,11 @@ internal void DestroyObject(DbConnectionInternal obj) // again. if (obj.IsTxRootWaitingForTxEnd) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Has Delegated Transaction, waiting to Dispose.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Has Delegated Transaction, waiting to Dispose.", ObjectID, obj.ObjectID); } else { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Removing from pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Removing from pool.", ObjectID, obj.ObjectID); bool removed = false; lock (_objectList) { @@ -1102,18 +1102,18 @@ internal void DestroyObject(DbConnectionInternal obj) if (removed) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Removed from pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Removed from pool.", ObjectID, obj.ObjectID); PerformanceCounters.NumberOfPooledConnections.Decrement(); } obj.Dispose(); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Disposed.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Disposed.", ObjectID, obj.ObjectID); PerformanceCounters.HardDisconnectsPerSecond.Increment(); } } private void ErrorCallback(Object state) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Resetting Error handling.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Resetting Error handling.", ObjectID); _errorOccurred = false; _waitHandles.ErrorEvent.Reset(); @@ -1287,7 +1287,7 @@ internal bool TryGetConnection(DbConnection owningObject, TaskCompletionSource {0}#, DbConnectionInternal State != Running.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, DbConnectionInternal State != Running.", ObjectID); connection = null; return true; } @@ -1332,7 +1332,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj SysTx.Transaction transaction = null; PerformanceCounters.SoftConnectsPerSecond.Increment(); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Getting connection.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Getting connection.", ObjectID); // If automatic transaction enlistment is required, then we try to // get the connection from the transacted connection pool first. @@ -1385,7 +1385,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj switch (waitResult) { case WAIT_TIMEOUT: - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Wait timed out.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Wait timed out.", ObjectID); Interlocked.Decrement(ref _waitCount); connection = null; return false; @@ -1393,12 +1393,12 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj case ERROR_HANDLE: // Throw the error that PoolCreateRequest stashed. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Errors are set.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Errors are set.", ObjectID); Interlocked.Decrement(ref _waitCount); throw TryCloneCachedException(); case CREATION_HANDLE: - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Creating new connection.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Creating new connection.", ObjectID); try { obj = UserCreateRequest(owningObject, userOptions); @@ -1451,7 +1451,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj if ((obj != null) && (!obj.IsConnectionAlive())) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, found dead and removed.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectID, obj.ObjectID); DestroyObject(obj); obj = null; // Setting to null in case creating a new object fails @@ -1462,7 +1462,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj RuntimeHelpers.PrepareConstrainedRegions(); try { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Creating new connection.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Creating new connection.", ObjectID); obj = UserCreateRequest(owningObject, userOptions); } finally @@ -1473,7 +1473,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj else { // Timeout waiting for creation semaphore - return null - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Wait timed out.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Wait timed out.", ObjectID); connection = null; return false; } @@ -1483,28 +1483,28 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj case WAIT_FAILED: Debug.Assert(waitForMultipleObjectsExHR != 0, "WaitForMultipleObjectsEx failed but waitForMultipleObjectsExHR remained 0"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Wait failed.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Wait failed.", ObjectID); Interlocked.Decrement(ref _waitCount); Marshal.ThrowExceptionForHR(waitForMultipleObjectsExHR); goto default; // if ThrowExceptionForHR didn't throw for some reason case (WAIT_ABANDONED + SEMAPHORE_HANDLE): - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Semaphore handle abandonded.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Semaphore handle abandonded.", ObjectID); Interlocked.Decrement(ref _waitCount); throw new AbandonedMutexException(SEMAPHORE_HANDLE, _waitHandles.PoolSemaphore); case (WAIT_ABANDONED + ERROR_HANDLE): - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Error handle abandonded.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Error handle abandonded.", ObjectID); Interlocked.Decrement(ref _waitCount); throw new AbandonedMutexException(ERROR_HANDLE, _waitHandles.ErrorEvent); case (WAIT_ABANDONED + CREATION_HANDLE): - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Creation handle abandoned.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Creation handle abandoned.", ObjectID); Interlocked.Decrement(ref _waitCount); throw new AbandonedMutexException(CREATION_HANDLE, _waitHandles.CreationSemaphore); default: - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, WaitForMultipleObjects={1}", ObjectID, waitResult); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, WaitForMultipleObjects={1}", ObjectID, waitResult); Interlocked.Decrement(ref _waitCount); throw ADP.InternalError(ADP.InternalErrorCode.UnexpectedWaitAnyResult); } @@ -1569,7 +1569,7 @@ private void PrepareConnection(DbConnection owningObject, DbConnectionInternal o internal DbConnectionInternal ReplaceConnection(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) { PerformanceCounters.SoftConnectsPerSecond.Increment(); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, replacing connection.", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, replacing connection.", ObjectID); DbConnectionInternal newConnection = UserCreateRequest(owningObject, userOptions, oldConnection); if (newConnection != null) @@ -1611,7 +1611,7 @@ private DbConnectionInternal GetFromGeneralPool() if (null != obj) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Popped from general pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Popped from general pool.", ObjectID, obj.ObjectID); PerformanceCounters.NumberOfFreeConnections.Decrement(); } return (obj); @@ -1628,7 +1628,7 @@ private DbConnectionInternal GetFromTransactedPool(out SysTx.Transaction transac if (null != obj) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Popped from transacted pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Popped from transacted pool.", ObjectID, obj.ObjectID); PerformanceCounters.NumberOfFreeConnections.Decrement(); if (obj.IsTransactionRoot) @@ -1639,14 +1639,14 @@ private DbConnectionInternal GetFromTransactedPool(out SysTx.Transaction transac } catch { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, found dead and removed.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectID, obj.ObjectID); DestroyObject(obj); throw; } } else if (!obj.IsConnectionAlive()) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, found dead and removed.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, found dead and removed.", ObjectID, obj.ObjectID); DestroyObject(obj); obj = null; } @@ -1661,7 +1661,7 @@ private void PoolCreateRequest(object state) { // called by pooler to ensure pool requests are currently being satisfied - // creation mutex has not been obtained - long scopeID = SqlClientEventSource.Log.PoolerScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.PoolerScopeEnterEvent(" {0}", ObjectID); try { if (State.Running == _state) @@ -1746,7 +1746,7 @@ private void PoolCreateRequest(object state) else { // trace waitResult and ignore the failure - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, PoolCreateRequest called WaitForSingleObject failed {1}", ObjectID, waitResult); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, PoolCreateRequest called WaitForSingleObject failed {1}", ObjectID, waitResult); } } catch (Exception e) @@ -1760,7 +1760,7 @@ private void PoolCreateRequest(object state) // Now that CreateObject can throw, we need to catch the exception and discard it. // There is no further action we can take beyond tracing. The error will be // thrown to the user the next time they request a connection. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, PoolCreateRequest called CreateConnection which threw an exception: {1}", ObjectID, e); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, PoolCreateRequest called CreateConnection which threw an exception: {1}", ObjectID, e); } finally { @@ -1793,7 +1793,7 @@ internal void PutNewObject(DbConnectionInternal obj) // causes the following assert to fire, which really mucks up stress // against checked bits. // Debug.Assert(obj.CanBePooled, "non-poolable object in pool"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Pushing to general pool.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Pushing to general pool.", ObjectID, obj.ObjectID); _stackNew.Push(obj); _waitHandles.PoolSemaphore.Release(1); @@ -1842,7 +1842,7 @@ internal void PutObjectFromTransactedPool(DbConnectionInternal obj) // method, we can safely presume that the caller is the only person // that is using the connection, and that all pre-push logic has been // done and all transactions are ended. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Transaction has ended.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Transaction has ended.", ObjectID, obj.ObjectID); if (_state == State.Running && obj.CanBePooled) { @@ -1867,7 +1867,7 @@ private void QueuePoolCreateRequest() private bool ReclaimEmancipatedObjects() { bool emancipatedObjectFound = false; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}", ObjectID); List reclaimedObjects = new List(); int count; @@ -1919,7 +1919,7 @@ private bool ReclaimEmancipatedObjects() for (int i = 0; i < count; ++i) { DbConnectionInternal obj = reclaimedObjects[i]; - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Reclaiming.", ObjectID, obj.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Connection {1}, Reclaiming.", ObjectID, obj.ObjectID); PerformanceCounters.NumberOfReclaimedConnections.Increment(); emancipatedObjectFound = true; @@ -1932,7 +1932,7 @@ private bool ReclaimEmancipatedObjects() internal void Startup() { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, CleanupWait={1}", ObjectID, _cleanupWait); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, CleanupWait={1}", ObjectID, _cleanupWait); _cleanupTimer = CreateCleanupTimer(); if (NeedToReplenish) @@ -1943,7 +1943,7 @@ internal void Startup() internal void Shutdown() { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}", ObjectID); _state = State.ShuttingDown; // deactivate timer callbacks @@ -1965,7 +1965,7 @@ internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionIntern Debug.Assert(null != transactedObject, "null transactedObject?"); // Note: connection may still be associated with transaction due to Explicit Unbinding requirement. - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Transaction {1}, Connection {2}, Transaction Completed", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID); // called by the internal connection when it get's told that the // transaction is completed. We tell the transacted pool to remove diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs index f250f44a4f..04a279503c 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionPoolGroup.cs @@ -273,7 +273,7 @@ private bool MarkPoolGroupAsActive() if (PoolGroupStateIdle == _state) { _state = PoolGroupStateActive; - SqlClientEventSource.Log.TraceEvent(" {0}#, Active", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Active", ObjectID); } return (PoolGroupStateActive == _state); } @@ -335,12 +335,12 @@ internal bool Prune() if (PoolGroupStateActive == _state) { _state = PoolGroupStateIdle; - SqlClientEventSource.Log.TraceEvent(" {0}#, Idle", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Idle", ObjectID); } else if (PoolGroupStateIdle == _state) { _state = PoolGroupStateDisabled; - SqlClientEventSource.Log.TraceEvent(" {0}#, Disabled", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Disabled", ObjectID); } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlConnectionHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlConnectionHelper.cs index e1847db521..618a6ea183 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlConnectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlConnectionHelper.cs @@ -87,7 +87,7 @@ internal DbConnectionOptions ConnectionOptions private string ConnectionString_Get() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); bool hidePassword = InnerConnection.ShouldHidePassword; DbConnectionOptions connectionOptions = UserConnectionOptions; return ((null != connectionOptions) ? connectionOptions.UsersConnectionString(hidePassword) : ""); @@ -132,7 +132,7 @@ private void ConnectionString_Set(DbConnectionPoolKey key) } string cstr = ((null != connectionOptions) ? connectionOptions.UsersConnectionStringForTrace() : ""); - SqlClientEventSource.Log.TraceEvent(" {0}#, '{1}'", ObjectID, cstr); + SqlClientEventSource.Log.TraceEvent(" {0}, '{1}'", ObjectID, cstr); } internal DbConnectionInternal InnerConnection @@ -182,11 +182,11 @@ internal void Abort(Exception e) // will end the reliable try... if (e is OutOfMemoryException) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Aborting operation due to asynchronous exception: {'OutOfMemory'}", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Aborting operation due to asynchronous exception: {'OutOfMemory'}", ObjectID); } else { - SqlClientEventSource.Log.TraceEvent(" {0}#, Aborting operation due to asynchronous exception: {1}", ObjectID, e.ToString()); + SqlClientEventSource.Log.TraceEvent(" {0}, Aborting operation due to asynchronous exception: {1}", ObjectID, e.ToString()); } } @@ -199,7 +199,7 @@ internal void AddWeakReference(object value, int tag) override protected DbCommand CreateDbCommand() { DbCommand command = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { DbProviderFactory providerFactory = ConnectionFactory.ProviderFactory; @@ -245,7 +245,7 @@ private void EnlistDistributedTransactionHelper(System.EnterpriseServices.ITrans permissionSet.AddPermission(new System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)); permissionSet.Demand(); - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection enlisting in a transaction.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection enlisting in a transaction.", ObjectID); SysTx.Transaction indigoTransaction = null; if (null != transaction) @@ -270,7 +270,7 @@ private void EnlistDistributedTransactionHelper(System.EnterpriseServices.ITrans override public void EnlistTransaction(SysTx.Transaction transaction) { SqlConnection.ExecutePermission.Demand(); - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection enlisting in a transaction.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection enlisting in a transaction.", ObjectID); // If we're currently enlisted in a transaction and we were called // on the EnlistTransaction method (Whidbey) we're not allowed to diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterCollectionHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterCollectionHelper.cs index 78a61fbe0d..55695adbc0 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterCollectionHelper.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/SqlParameterCollectionHelper.cs @@ -235,7 +235,7 @@ override public void Insert(int index, object value) { OnChange(); // fire event before value is validated ValidateType(value); - Validate(-1, (SqlParameterCollection)value); + Validate(-1, (SqlParameter)value); InnerList.Insert(index, (SqlParameter)value); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/ActiveDirectoryNativeAuthenticationProvider.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/ActiveDirectoryNativeAuthenticationProvider.cs index 645d28e2c2..250a39c173 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/ActiveDirectoryNativeAuthenticationProvider.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/ActiveDirectoryNativeAuthenticationProvider.cs @@ -52,6 +52,7 @@ internal class ActiveDirectoryNativeAuthenticationProvider : SqlAuthenticationPr { result = await app.AcquireTokenInteractive(scopes) .WithUseEmbeddedWebView(true) + .WithLoginHint(parameters.UserId) .ExecuteAsync(); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs index dd3b6a807b..7e1a438532 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Server/SmiEventSink_Default.cs @@ -267,7 +267,7 @@ internal override void MessagePosted(int number, byte state, byte errorClass, st { if (null == _parent) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, number={1} state={2} errorClass={3} server='{4}' message='{5}' procedure='{6}' linenumber={7}.", 0, number, state, errorClass, server ?? "", message ?? "", procedure ?? "", lineNumber); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, number={1} state={2} errorClass={3} server='{4}' message='{5}' procedure='{6}' linenumber={7}.", 0, number, state, errorClass, server ?? "", message ?? "", procedure ?? "", lineNumber); SqlError error = new SqlError(number, state, errorClass, server, message, procedure, lineNumber); if (error.Class < TdsEnums.MIN_ERROR_CLASS) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs index c369f64f1b..d2e3c58e5e 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlBulkCopy.cs @@ -625,7 +625,7 @@ private Task CreateAndExecuteInitialQueryAsync(out Bulk { string TDSCommand = CreateInitialQuery(); SqlClientEventSource.Log.TraceEvent(" Initial Query: '{0}'", TDSCommand); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); Task executeTask = _parser.TdsExecuteSQLBatch(TDSCommand, this.BulkCopyTimeout, null, _stateObj, sync: !_isAsyncBulkCopy, callerHasConnectionLock: true); if (executeTask == null) @@ -915,7 +915,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i // private Task SubmitUpdateBulkCommand(string TDSCommand) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); Task executeTask = _parser.TdsExecuteSQLBatch(TDSCommand, this.BulkCopyTimeout, null, _stateObj, sync: !_isAsyncBulkCopy, callerHasConnectionLock: true); if (executeTask == null) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs index 9ed6d0b7bf..f639711104 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs @@ -2,7 +2,6 @@ // 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.Text; using System.Diagnostics.Tracing; using System.Threading; @@ -14,6 +13,8 @@ internal class SqlClientEventSource : EventSource // Defines the singleton instance for the Resources ETW provider internal static readonly SqlClientEventSource Log = new SqlClientEventSource(); + #region Event IDs + // Initialized static Scope IDs private static long s_nextScopeId = 0; private static long s_nextNotificationScopeId = 0; private static long s_nextPoolerScopeId = 0; @@ -27,116 +28,225 @@ internal class SqlClientEventSource : EventSource /// Defines EventId for EndExecute (Reader, Scalar, NonQuery, XmlReader). /// private const int EndExecuteEventId = 2; + + /// + /// Defines EventId for Trace() events + /// private const int TraceEventId = 3; - private const int EnterScopeId = 4; - private const int ExitScopeId = 5; - private const int TraceBinId = 6; - private const int CorrelationTraceId = 7; - private const int NotificationsScopeEnterId = 8; - private const int NotificationsTraceId = 9; - private const int PoolerScopeEnterId = 10; + + /// + /// Defines EventId for ScopeEnter() events + /// + private const int ScopeEnterId = 4; + + /// + /// Defines EventId for ScopeLeave() events + /// + private const int ScopeExitId = 5; + + /// + /// Defines EventId for NotificationScopeEnter() events + /// + private const int NotificationScopeEnterId = 6; + + /// + /// Defines EventId for NotificationScopeLeave() events + /// + private const int NotificationScopeExitId = 7; + + /// + /// Defines EventId for NotificationScopeTrace() events + /// + private const int NotificationTraceId = 8; + + /// + /// Defines EventId for PoolerScopeEnter() events + /// + private const int PoolerScopeEnterId = 9; + + /// + /// Defines EventId for PoolerScopeLeave() events + /// + private const int PoolerScopeExitId = 10; + + /// + /// Defines EventId for PoolerTrace() events + /// private const int PoolerTraceId = 11; /// - /// Keyword definitions. These represent logical groups of events that can be turned on and off independently - /// Often each task has a keyword, but where tasks are determined by subsystem, keywords are determined by - /// usefulness to end users to filter. Generally users don't mind extra events if they are not high volume - /// so grouping low volume events together in a single keywords is OK (users can post-filter by task if desired) + /// Defines EventId for AdvancedTrace() events + /// + private const int AdvancedTraceId = 12; + + /// + /// Defines EventId for AdvancedScopeEnter() events + /// + private const int AdvancedScopeEnterId = 13; + + /// + /// Defines EventId for AdvancedScopeLeave() events + /// + private const int AdvancedScopeExitId = 14; + + /// + /// Defines EventId for AdvancedTraceBin() events + /// + private const int AdvancedTraceBinId = 15; + + /// + /// Defines EventId for CorrelationTrace() events + /// + private const int CorrelationTraceId = 16; + + /// + /// Defines EventId for StateDump() events + /// + private const int StateDumpEventId = 17; + #endregion + + /// + /// These represent logical groups of events that can be turned on and off independently + /// Often each task has a keyword, but where tasks are determined by subsystem, keywords + /// are determined by usefulness to end users to filter. + /// + /// Generally users don't mind extra events if they are not high volume, so grouping low + /// volume events together in a single keywords is OK (users can post-filter by task if desired) + /// /// - /// The visibility of the enum has to be public, otherwise there will be an ArgumentException on calling related WriteEvent method. the Keywords class has to be a nested class. + /// The visibility of the enum has to be public, otherwise there will be an ArgumentException + /// on calling related WriteEvent() method. + /// + /// The Keywords class has to be a nested class. /// Each keyword must be a power of 2. /// + /// /// #region Keywords public class Keywords { - internal const EventKeywords SqlClient = 0; + /// + /// Captures Start/Stop events before and after command execution. + /// + internal const EventKeywords ExecutionTrace = (EventKeywords)1; - internal const EventKeywords Trace = (EventKeywords)1; - - internal const EventKeywords TraceBin = (EventKeywords)2; + /// + /// Captures basic application flow trace events. + /// + internal const EventKeywords Trace = (EventKeywords)2; + /// + /// Captures basic application scope entering and exiting events. + /// internal const EventKeywords Scope = (EventKeywords)4; + /// + /// Captures `SqlNotification` flow trace events. + /// internal const EventKeywords NotificationTrace = (EventKeywords)8; - internal const EventKeywords Pooling = (EventKeywords)16; - - internal const EventKeywords Correlation = (EventKeywords)32; - - internal const EventKeywords NotificationScope = (EventKeywords)64; - - internal const EventKeywords PoolerScope = (EventKeywords)128; - - internal const EventKeywords PoolerTrace = (EventKeywords)256; - - internal const EventKeywords Advanced = (EventKeywords)512; - + /// + /// Captures `SqlNotification` scope entering and exiting events. + /// + internal const EventKeywords NotificationScope = (EventKeywords)16; + + /// + /// Captures connection pooling flow trace events. + /// + internal const EventKeywords PoolerTrace = (EventKeywords)32; + + /// + /// Captures connection pooling scope trace events. + /// + internal const EventKeywords PoolerScope = (EventKeywords)64; + + /// + /// Captures advanced flow trace events. + /// + internal const EventKeywords AdvancedTrace = (EventKeywords)128; + + /// + /// Captures advanced flow trace events with additional information. + /// + internal const EventKeywords AdvancedTraceBin = (EventKeywords)256; + + /// + /// Captures correlation flow trace events. + /// + internal const EventKeywords CorrelationTrace = (EventKeywords)512; + + /// + /// Captures full state dump of `SqlConnection` + /// internal const EventKeywords StateDump = (EventKeywords)1024; } #endregion - public static class Tasks // this name is important for EventSource + #region Tasks + /// + /// Tasks supported by SqlClient's EventSource implementation + /// + public static class Tasks { - /// Task that tracks sql command execute. + /// + /// Task that tracks SqlCommand execution. + /// public const EventTask ExecuteCommand = (EventTask)1; } + #endregion #region Enable/Disable Events [NonEvent] - internal bool IsTraceEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Trace); + internal bool IsExecutionTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.ExecutionTrace); [NonEvent] - internal bool IsTraceBinEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.TraceBin); + internal bool IsTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.Trace); [NonEvent] - internal bool IsScopeEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Scope); + internal bool IsScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.Scope); [NonEvent] - internal bool IsPoolerScopeEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.PoolerScope); + internal bool IsNotificationTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.NotificationTrace); [NonEvent] - internal bool IsCorrelationEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Correlation); + internal bool IsNotificationScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.NotificationScope); [NonEvent] - internal bool IsNotificationScopeEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.NotificationScope); + internal bool IsPoolerTraceEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.PoolerTrace); [NonEvent] - internal bool IsPoolingEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Pooling); + internal bool IsPoolerScopeEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.PoolerScope); [NonEvent] - internal bool IsNotificationTraceEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.NotificationTrace); + internal bool IsAdvancedTraceOn() => Log.IsEnabled(EventLevel.Informational, Keywords.AdvancedTrace); [NonEvent] - internal bool IsPoolerTraceEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.PoolerTrace); + internal bool IsCorrelationEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.CorrelationTrace); [NonEvent] - internal bool IsAdvanceTraceOn() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Advanced); + internal bool IsStateDumpEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.StateDump); - [NonEvent] - internal bool IsStateDumpEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.StateDump); - - [NonEvent] - internal bool IsSqlClientEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.SqlClient); #endregion #region overloads //Never use event writer directly as they are not checking for enabled/disabled situations. Always use overloads. + + #region Trace [NonEvent] - internal void TraceEvent(string message, T0 args0) + internal void TraceEvent(string message) { if (Log.IsTraceEnabled()) { - TraceEvent(string.Format(message, args0?.ToString() ?? "Null")); + Trace(message); } } [NonEvent] - internal void TraceEvent(string message) + internal void TraceEvent(string message, T0 args0) { if (Log.IsTraceEnabled()) { - Trace(message); + Trace(string.Format(message, args0?.ToString() ?? "Null")); } } @@ -175,391 +285,424 @@ internal void TraceEvent(string message) Trace(string.Format(message, args0, args1, args2, args3, args4, args5)); } } + #endregion + #region Scope [NonEvent] - internal void AdvanceTrace(string message) + internal long ScopeEnterEvent(string message) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsScopeEnabled()) { - Trace(message); + return ScopeEnter(message); } + return 0; } [NonEvent] - internal void AdvanceTrace(string message, T0 args0) + internal long ScopeEnterEvent(string message, T0 args0) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0)); + return ScopeEnter(string.Format(message, args0)); } + return 0; } [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1) + internal long ScopeEnterEvent(string message, T0 args0, T1 args1) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0, args1)); + return ScopeEnter(string.Format(message, args0, args1)); } + return 0; } [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2) + internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0, args1, args2)); + return ScopeEnter(string.Format(message, args0, args1, args2)); } + return 0; } [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3)); + return ScopeEnter(string.Format(message, args0, args1, args2, args3)); } + return 0; } [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5) + internal void ScopeLeaveEvent(long scopeId) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsScopeEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3, args4, args5)); + ScopeLeave(scopeId); } } + #endregion + #region Notification Trace [NonEvent] - internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5, T6 args6, T7 args7) + internal void NotificationTraceEvent(string message) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationTraceEnabled()) { - Trace(string.Format(message, args0, args1, args2, args3, args4, args5, args6, args7)); + NotificationTrace(message); } } [NonEvent] - internal void AdvanceTraceBin(string message, T0 args0, T1 args1) + internal void NotificationTraceEvent(string message, T0 args0) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationTraceEnabled()) { - TraceBin(string.Format(message, args0, args1)); + NotificationTrace(string.Format(message, args0)); } } [NonEvent] - internal long ScopeEnterEvent(string message, T0 args0) + internal void NotificationTraceEvent(string message, T0 args0, T1 args1) { - if (Log.IsScopeEnabled()) + if (Log.IsNotificationTraceEnabled()) { - return ScopeEnter(string.Format(message, args0)); + NotificationTrace(string.Format(message, args0, args1)); } - return 0; } [NonEvent] - internal long AdvanceScopeEnter(string message, T0 args0) + internal void NotificationTraceEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsNotificationTraceEnabled()) { - return ScopeEnter(string.Format(message, args0)); + NotificationTrace(string.Format(message, args0, args1, args2)); } - return 0; } [NonEvent] - internal long ScopeEnterEvent(string message) + internal void NotificationTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsScopeEnabled()) + if (Log.IsNotificationTraceEnabled()) { - return ScopeEnter(message); + NotificationTrace(string.Format(message, args0, args1, args2, args3)); } - return 0; } + #endregion + #region Notification Scope [NonEvent] - internal long ScopeEnterEvent(string message, T0 args0, T1 args1) + internal long NotificationScopeEnterEvent(string message, T0 args0) { - if (Log.IsScopeEnabled()) + if (Log.IsNotificationScopeEnabled()) { - return ScopeEnter(string.Format(message, args0, args1)); + return NotificationScopeEnter(string.Format(message, args0)); } return 0; } [NonEvent] - internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2) + internal long NotificationScopeEnterEvent(string message, T0 args0, T1 args1) { - if (Log.IsScopeEnabled()) + if (Log.IsNotificationScopeEnabled()) { - return ScopeEnter(string.Format(message, args0, args1, args2)); + return NotificationScopeEnter(string.Format(message, args0, args1)); } return 0; } [NonEvent] - internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal long NotificationScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsScopeEnabled()) + if (Log.IsNotificationScopeEnabled()) { - return ScopeEnter(string.Format(message, args0, args1, args2, args3)); + return NotificationScopeEnter(string.Format(message, args0, args1, args2)); } return 0; } [NonEvent] - internal long PoolerScopeEnterEvent(string message, T0 args0) + internal long NotificationScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsPoolerScopeEnabled()) + if (Log.IsNotificationScopeEnabled()) { - return PoolerScopeEnter(string.Format(message, args0)); + return NotificationScopeEnter(string.Format(message, args0, args1, args2, args3)); } return 0; } [NonEvent] - internal long NotificationsScopeEnterEvent(string message, T0 args0) + internal void NotificationScopeLeaveEvent(long scopeId) { if (Log.IsNotificationScopeEnabled()) { - return NotificationsScopeEnter(string.Format(message, args0)); + NotificationScopeLeave(scopeId); } - return 0; } + #endregion + #region Pooler Trace [NonEvent] - internal long NotificationsScopeEnterEvent(string message, T0 args0, T1 args1) + internal void PoolerTraceEvent(string message, T0 args0) { - if (Log.IsNotificationScopeEnabled()) + if (Log.IsPoolerTraceEnabled()) { - return NotificationsScopeEnter(string.Format(message, args0, args1)); + PoolerTrace(string.Format(message, args0)); } - return 0; } [NonEvent] - internal long NotificationsScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2) + internal void PoolerTraceEvent(string message, T0 args0, T1 args1) { - if (Log.IsNotificationScopeEnabled()) + if (Log.IsPoolerTraceEnabled()) { - return NotificationsScopeEnter(string.Format(message, args0, args1, args2)); + PoolerTrace(string.Format(message, args0, args1)); } - return 0; } [NonEvent] - internal long NotificationsScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsNotificationScopeEnabled()) + if (Log.IsPoolerTraceEnabled()) { - return NotificationsScopeEnter(string.Format(message, args0, args1, args2, args3)); + PoolerTrace(string.Format(message, args0, args1, args2)); } - return 0; } [NonEvent] - internal void PoolerTraceEvent(string message, T0 args0) + internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { if (Log.IsPoolerTraceEnabled()) { - PoolerTrace(string.Format(message, args0)); + PoolerTrace(string.Format(message, args0, args1, args2, args3)); } } + #endregion + #region Pooler Scope [NonEvent] - internal void PoolerTraceEvent(string message, T0 args0, T1 args1) + internal long PoolerScopeEnterEvent(string message, T0 args0) { - if (Log.IsPoolerTraceEnabled()) + if (Log.IsPoolerScopeEnabled()) { - PoolerTrace(string.Format(message, args0, args1)); + return PoolerScopeEnter(string.Format(message, args0)); } + return 0; } [NonEvent] - internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2) + internal void PoolerScopeLeaveEvent(long scopeId) { - if (Log.IsPoolerTraceEnabled()) + if (Log.IsPoolerScopeEnabled()) { - PoolerTrace(string.Format(message, args0, args1, args2)); + PoolerScopeLeave(scopeId); } } + #endregion + #region AdvancedTrace [NonEvent] - internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal void AdvancedTraceEvent(string message) { - if (Log.IsPoolerTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - PoolerTrace(string.Format(message, args0, args1, args2, args3)); + AdvancedTrace(message); } } [NonEvent] - internal void CorrelationTraceEvent(string message, T0 args0) + internal void AdvancedTraceEvent(string message, T0 args0) { - if (Log.IsCorrelationEnabled()) + if (Log.IsAdvancedTraceOn()) { - CorrelationTrace(string.Format(message, args0?.ToString() ?? "Null")); + AdvancedTrace(string.Format(message, args0)); } } [NonEvent] - internal void CorrelationTraceEvent(string message, T0 args0, T1 args1) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1) { - if (Log.IsCorrelationEnabled()) + if (Log.IsAdvancedTraceOn()) { - CorrelationTrace(string.Format(message, args0?.ToString() ?? "Null", args1?.ToString() ?? "Null")); + AdvancedTrace(string.Format(message, args0, args1)); } } [NonEvent] - internal void CorrelationTraceEvent(string message, T0 args0, T1 args1, T2 args2) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsCorrelationEnabled()) + if (Log.IsAdvancedTraceOn()) { - CorrelationTrace(string.Format(message, args0?.ToString() ?? "Null", args1?.ToString() ?? "Null", args2?.ToString() ?? "Null")); + AdvancedTrace(string.Format(message, args0, args1, args2)); } } [NonEvent] - internal void NotificationsTraceEvent(string message) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - NotificationsTrace(message); + AdvancedTrace(string.Format(message, args0, args1, args2, args3)); } } [NonEvent] - internal void NotificationsTraceEvent(string message, T0 args0) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - NotificationsTrace(string.Format(message, args0)); + AdvancedTrace(string.Format(message, args0, args1, args2, args3, args4, args5)); } } [NonEvent] - internal void NotificationsTraceEvent(string message, T0 args0, T1 args1) + internal void AdvancedTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5, T6 args6, T7 args7) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - NotificationsTrace(string.Format(message, args0, args1)); + AdvancedTrace(string.Format(message, args0, args1, args2, args3, args4, args5, args6, args7)); } } [NonEvent] - internal void NotificationsTraceEvent(string message, T0 args0, T1 args1, T2 args2) + internal long AdvancedScopeEnterEvent(string message, T0 args0) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - NotificationsTrace(string.Format(message, args0, args1, args2)); + return AdvancedScopeEnter(string.Format(message, args0)); } + return 0; } [NonEvent] - internal void NotificationsTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3) + internal void AdvanceScopeLeave(long scopeId) { - if (Log.IsNotificationTraceEnabled()) + if (Log.IsAdvancedTraceOn()) { - NotificationsTrace(string.Format(message, args0, args1, args2, args3)); + AdvancedScopeLeave(scopeId); } } [NonEvent] - internal void TraceBinEvent(string message, T0 args0, T1 args1) + internal void AdvancedTraceBinEvent(string message, T0 args0, T1 args1) { - if (Log.IsTraceBinEnabled()) + if (Log.IsAdvancedTraceOn()) { - TraceBin(string.Format(message, args0, args1)); + AdvancedTraceBin(string.Format(message, args0, args1)); } } + #endregion + #region Correlation Trace [NonEvent] - internal void StateDumpEvent(string message, T0 args0, T1 args1) + internal void CorrelationTraceEvent(string message, T0 args0) { - if (Log.IsStateDumpEnabled()) + if (Log.IsCorrelationEnabled()) { - Trace(string.Format(message, args0, args1)); + CorrelationTrace(string.Format(message, args0?.ToString() ?? "Null")); } } [NonEvent] - internal void ScopeLeaveEvent(long scopeId) + internal void CorrelationTraceEvent(string message, T0 args0, T1 args1) { - if (Log.IsScopeEnabled()) + if (Log.IsCorrelationEnabled()) { - ScopeLeave(scopeId); + CorrelationTrace(string.Format(message, args0?.ToString() ?? "Null", args1?.ToString() ?? "Null")); } } [NonEvent] - internal void NotificationsScopeLeaveEvent(long scopeId) + internal void CorrelationTraceEvent(string message, T0 args0, T1 args1, T2 args2) { - if (Log.IsNotificationScopeEnabled()) + if (Log.IsCorrelationEnabled()) { - ScopeLeave(scopeId); + CorrelationTrace(string.Format(message, args0?.ToString() ?? "Null", args1?.ToString() ?? "Null", args2?.ToString() ?? "Null")); } } + #endregion + #region State Dump [NonEvent] - internal void PoolerScopeLeaveEvent(long scopeId) + internal void StateDumpEvent(string message, T0 args0, T1 args1) { - if (Log.IsPoolerScopeEnabled()) + if (Log.IsStateDumpEnabled()) { - ScopeLeave(scopeId); + StateDump(string.Format(message, args0, args1)); + } + } + #endregion + + #endregion + + #region Write Events + [Event(BeginExecuteEventId, Keywords = Keywords.ExecutionTrace, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Start)] + internal void BeginExecute(int objectId, string dataSource, string database, string commandText) + { + if (Log.IsExecutionTraceEnabled()) + { + WriteEvent(BeginExecuteEventId, objectId, dataSource, database, commandText); } } - [NonEvent] - internal void AdvanceScopeLeave(long scopeId) + [Event(EndExecuteEventId, Keywords = Keywords.ExecutionTrace, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Stop)] + internal void EndExecute(int objectId, int compositeState, int sqlExceptionNumber) { - if (Log.IsAdvanceTraceOn()) + if (Log.IsExecutionTraceEnabled()) { - ScopeLeave(scopeId); + WriteEvent(EndExecuteEventId, objectId, compositeState, sqlExceptionNumber); } } - #endregion - #region Events [Event(TraceEventId, Level = EventLevel.Informational, Keywords = Keywords.Trace)] internal void Trace(string message) { WriteEvent(TraceEventId, message); } - [Event(EnterScopeId, Level = EventLevel.Verbose, Keywords = Keywords.Scope)] + [Event(ScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.Scope)] internal long ScopeEnter(string message) { long scopeId = Interlocked.Increment(ref s_nextScopeId); - WriteEvent(EnterScopeId, message); + WriteEvent(ScopeEnterId, message); return scopeId; } - [Event(ExitScopeId, Level = EventLevel.Verbose, Keywords = Keywords.Scope)] + [Event(ScopeExitId, Level = EventLevel.Informational, Opcode = EventOpcode.Stop, Keywords = Keywords.Scope)] internal void ScopeLeave(long scopeId) { - WriteEvent(ExitScopeId, scopeId); + WriteEvent(ScopeExitId, scopeId); } - [Event(TraceBinId, Level = EventLevel.Informational, Keywords = Keywords.Trace)] - internal void TraceBin(string message) + [Event(NotificationTraceId, Level = EventLevel.Informational, Keywords = Keywords.NotificationTrace)] + internal void NotificationTrace(string message) { - WriteEvent(TraceBinId, message); + WriteEvent(NotificationTraceId, message); } - [Event(CorrelationTraceId, Level = EventLevel.Informational, Keywords = Keywords.Correlation, Opcode = EventOpcode.Start)] - internal void CorrelationTrace(string message) + [Event(NotificationScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.NotificationScope)] + internal long NotificationScopeEnter(string message) { - WriteEvent(CorrelationTraceId, message); + long scopeId = Interlocked.Increment(ref s_nextNotificationScopeId); + WriteEvent(NotificationScopeEnterId, message); + return scopeId; } - [Event(NotificationsScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.NotificationScope)] - internal long NotificationsScopeEnter(string message) + [Event(NotificationScopeExitId, Level = EventLevel.Informational, Opcode = EventOpcode.Stop, Keywords = Keywords.NotificationScope)] + internal void NotificationScopeLeave(long scopeId) { - long scopeId = Interlocked.Increment(ref s_nextNotificationScopeId); - WriteEvent(NotificationsScopeEnterId, message); - return scopeId; + WriteEvent(NotificationScopeExitId, scopeId); + } + + [Event(PoolerTraceId, Level = EventLevel.Informational, Keywords = Keywords.PoolerTrace)] + internal void PoolerTrace(string message) + { + WriteEvent(PoolerTraceId, message); } [Event(PoolerScopeEnterId, Level = EventLevel.Informational, Opcode = EventOpcode.Start, Keywords = Keywords.PoolerScope)] @@ -570,44 +713,48 @@ internal long PoolerScopeEnter(string message) return scopeId; } - [Event(NotificationsTraceId, Level = EventLevel.Informational, Keywords = Keywords.Trace)] - internal void NotificationsTrace(string message) + [Event(PoolerScopeExitId, Level = EventLevel.Informational, Opcode = EventOpcode.Stop, Keywords = Keywords.PoolerScope)] + internal void PoolerScopeLeave(long scopeId) { - WriteEvent(NotificationsTraceId, message); + WriteEvent(PoolerScopeExitId, scopeId); } - [Event(PoolerTraceId, Level = EventLevel.Informational, Keywords = Keywords.PoolerTrace)] - internal void PoolerTrace(string message) + [Event(AdvancedTraceId, Level = EventLevel.Verbose, Keywords = Keywords.AdvancedTrace)] + internal void AdvancedTrace(string message) { - WriteEvent(PoolerTraceId, message); + WriteEvent(AdvancedTraceId, message); } - // unfortunately these are not marked as Start/Stop opcodes. The reason is that we dont want them to participate in - // the EventSource activity IDs (because they currently don't use tasks and this simply confuses the logic) and - // because of versioning requirements we don't have ActivityOptions capability (because mscorlib and System.Data version - // at different rates) Sigh... - [Event(BeginExecuteEventId, Keywords = Keywords.SqlClient, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Start)] - public void BeginExecute(int objectId, string dataSource, string database, string commandText) + [Event(AdvancedScopeEnterId, Level = EventLevel.Verbose, Opcode = EventOpcode.Start, Keywords = Keywords.AdvancedTrace)] + internal long AdvancedScopeEnter(string message) { - // we do not use unsafe code for better performance optization here because optimized helpers make the code unsafe where that would not be the case otherwise. - // This introduces the question of partial trust, which is complex in the SQL case (there are a lot of scenarios and SQL has special security support). - if (Log.IsSqlClientEnabled()) - { - WriteEvent(BeginExecuteEventId, objectId, dataSource, database, commandText); - } + long scopeId = Interlocked.Increment(ref s_nextScopeId); + WriteEvent(AdvancedScopeEnterId, message); + return scopeId; } - // unfortunately these are not marked as Start/Stop opcodes. The reason is that we dont want them to participate in - // the EventSource activity IDs (because they currently don't use tasks and this simply confuses the logic) and - // because of versioning requirements we don't have ActivityOptions capability (because mscorlib and System.Data version - // at different rates) Sigh... - [Event(EndExecuteEventId, Keywords = Keywords.SqlClient, Task = Tasks.ExecuteCommand, Opcode = EventOpcode.Stop)] - public void EndExecute(int objectId, int compositeState, int sqlExceptionNumber) + [Event(AdvancedScopeExitId, Level = EventLevel.Verbose, Opcode = EventOpcode.Stop, Keywords = Keywords.AdvancedTrace)] + internal void AdvancedScopeLeave(long scopeId) { - if (Log.IsSqlClientEnabled()) - { - WriteEvent(EndExecuteEventId, objectId, compositeState, sqlExceptionNumber); - } + WriteEvent(AdvancedScopeExitId, scopeId); + } + + [Event(AdvancedTraceBinId, Level = EventLevel.Informational, Keywords = Keywords.AdvancedTraceBin)] + internal void AdvancedTraceBin(string message) + { + WriteEvent(AdvancedTraceBinId, message); + } + + [Event(CorrelationTraceId, Level = EventLevel.Informational, Keywords = Keywords.CorrelationTrace, Opcode = EventOpcode.Start)] + internal void CorrelationTrace(string message) + { + WriteEvent(CorrelationTraceId, message); + } + + [Event(StateDumpEventId, Level = EventLevel.Verbose, Keywords = Keywords.StateDump)] + internal void StateDump(string message) + { + WriteEvent(StateDumpEventId, message); } #endregion } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs index 951353e7ae..5a872bba67 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs @@ -343,7 +343,7 @@ internal CommandEventSink(SqlCommand command) : base() internal override void StatementCompleted(int rowsAffected) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, rowsAffected={1}.", _command.ObjectID, rowsAffected); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, rowsAffected={1}.", _command.ObjectID, rowsAffected); _command.InternalRecordsAffected = rowsAffected; // UNDONE: need to fire events back to user code, but this may be called @@ -355,20 +355,20 @@ internal override void StatementCompleted(int rowsAffected) internal override void BatchCompleted() { - SqlClientEventSource.Log.AdvanceTrace(" {0}#.", _command.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}.", _command.ObjectID); } internal override void ParametersAvailable(SmiParameterMetaData[] metaData, ITypedGettersV3 parameterValues) { - SqlClientEventSource.Log.AdvanceTrace(" {0}# metaData.Length={1}.", _command.ObjectID, (null != metaData) ? metaData.Length : -1); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} metaData.Length={1}.", _command.ObjectID, (null != metaData) ? metaData.Length : -1); - if (SqlClientEventSource.Log.IsAdvanceTraceOn()) + if (SqlClientEventSource.Log.IsAdvancedTraceOn()) { if (null != metaData) { for (int i = 0; i < metaData.Length; i++) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, metaData[{1}] is {2}{3}", _command.ObjectID, i, metaData[i].GetType().ToString(), metaData[i].TraceString()); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, metaData[{1}] is {2}{3}", _command.ObjectID, i, metaData[i].GetType().ToString(), metaData[i].TraceString()); } } } @@ -379,7 +379,7 @@ internal override void ParametersAvailable(SmiParameterMetaData[] metaData, ITyp internal override void ParameterAvailable(SmiParameterMetaData metaData, SmiTypedGetterSetter parameterValues, int ordinal) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, metaData[{1}] is {2}{ 3}", _command.ObjectID, ordinal, metaData.GetType().ToString(), metaData.TraceString()); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, metaData[{1}] is {2}{ 3}", _command.ObjectID, ordinal, metaData.GetType().ToString(), metaData.TraceString()); Debug.Assert(SmiContextFactory.Instance.NegotiatedSmiVersion >= SmiContextFactory.KatmaiVersion); _command.OnParameterAvailableSmi(metaData, parameterValues, ordinal); } @@ -562,7 +562,7 @@ private SqlCommand(SqlCommand from) : this() } } _activeConnection = value; // UNDONE: Designers need this setter. Should we block other scenarios? - SqlClientEventSource.Log.TraceEvent(" {0}#, {1}#", ObjectID, (null != value) ? value.ObjectID : -1); + SqlClientEventSource.Log.TraceEvent(" {0}, {1}", ObjectID, (null != value) ? value.ObjectID : -1); } } @@ -640,7 +640,7 @@ public SqlNotificationRequest Notification } set { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); _sqlDep = null; _notification = value; } @@ -690,7 +690,7 @@ internal SqlStatistics Statistics } // TODO: Add objid here - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); _transaction = value; } } @@ -725,7 +725,7 @@ override public string CommandText } set { - SqlClientEventSource.Log.TraceEvent(" {0}#, String Value = '{1}'", ObjectID, value); + SqlClientEventSource.Log.TraceEvent(" {0}, String Value = '{1}'", ObjectID, value); if (0 != ADP.SrcCompare(_commandText, value)) { @@ -763,7 +763,7 @@ override public int CommandTimeout } set { - SqlClientEventSource.Log.TraceEvent(" {0}#, {1}", ObjectID, value); + SqlClientEventSource.Log.TraceEvent(" {0}, {1}", ObjectID, value); if (value < 0) { throw ADP.InvalidCommandTimeout(value); @@ -808,7 +808,7 @@ override public CommandType CommandType } set { - SqlClientEventSource.Log.TraceEvent(" {0}#, {1}{2}", ObjectID, (int)value, _commandType); + SqlClientEventSource.Log.TraceEvent(" {0}, {1}{2}", ObjectID, (int)value, _commandType); if (_commandType != value) { switch (value) @@ -951,7 +951,7 @@ internal void OnStatementCompleted(int recordCount) { try { - SqlClientEventSource.Log.TraceEvent(" {0}#, recordCount={1}", ObjectID, recordCount); + SqlClientEventSource.Log.TraceEvent(" {0}, recordCount={1}", ObjectID, recordCount); handler(this, new StatementCompletedEventArgs(recordCount)); } catch (Exception e) @@ -989,8 +989,8 @@ override public void Prepare() } SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); statistics = SqlStatistics.StartTimer(Statistics); @@ -1156,7 +1156,7 @@ internal void Unprepare() } _cachedMetaData = null; - SqlClientEventSource.Log.TraceEvent(" {0}#, Command unprepared.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command unprepared.", ObjectID); } // Cancel is supposed to be multi-thread safe. @@ -1166,8 +1166,8 @@ internal void Unprepare() /// override public void Cancel() { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); SqlStatistics statistics = null; try @@ -1329,8 +1329,8 @@ override public object ExecuteScalar() _pendingCancel = false; SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); bool success = false; int? sqlExceptionNumber = null; @@ -1399,8 +1399,8 @@ override public int ExecuteNonQuery() SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); bool success = false; int? sqlExceptionNumber = null; @@ -1437,7 +1437,7 @@ internal void ExecuteToPipe(SmiContext pipeContext) _pendingCancel = false; SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -1463,7 +1463,7 @@ public IAsyncResult BeginExecuteNonQuery() [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public IAsyncResult BeginExecuteNonQuery(AsyncCallback callback, object stateObject) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); SqlConnection.ExecutePermission.Demand(); return BeginExecuteNonQueryInternal(0, callback, stateObject, 0, inRetry: false); } @@ -1689,7 +1689,7 @@ public int EndExecuteNonQuery(IAsyncResult asyncResult) } finally { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); } } @@ -1707,7 +1707,7 @@ private void ThrowIfReconnectionHasBeenCanceled() private int EndExecuteNonQueryAsync(IAsyncResult asyncResult) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Debug.Assert(!_internalEndExecuteInitiated || _stateObj == null); Exception asyncException = ((Task)asyncResult).Exception; @@ -1969,7 +1969,7 @@ private Task InternalExecuteNonQuery(TaskCompletionSource completion, st { // otherwise, use a full-fledged execute that can handle params and stored procs Debug.Assert(!sendToPipe, "trying to send non-context command to pipe"); - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as RPC.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as RPC.", ObjectID); SqlDataReader reader = RunExecuteReader(0, RunBehavior.UntilDone, false, methodName, completion, timeout, out task, out usedCache, asyncWrite, inRetry); if (null != reader) @@ -2023,8 +2023,8 @@ public XmlReader ExecuteXmlReader() SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); bool success = false; int? sqlExceptionNumber = null; @@ -2065,7 +2065,7 @@ public IAsyncResult BeginExecuteXmlReader() [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public IAsyncResult BeginExecuteXmlReader(AsyncCallback callback, object stateObject) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); SqlConnection.ExecutePermission.Demand(); return BeginExecuteXmlReaderInternal(CommandBehavior.SequentialAccess, callback, stateObject, 0, inRetry: false); } @@ -2218,13 +2218,13 @@ public XmlReader EndExecuteXmlReader(IAsyncResult asyncResult) } finally { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); } } private XmlReader EndExecuteXmlReaderAsync(IAsyncResult asyncResult) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Debug.Assert(!_internalEndExecuteInitiated || _stateObj == null); Exception asyncException = ((Task)asyncResult).Exception; @@ -2343,7 +2343,7 @@ public IAsyncResult BeginExecuteReader(AsyncCallback callback, object stateObjec /// override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); return ExecuteReader(behavior, ADP.ExecuteReader); } @@ -2351,8 +2351,8 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) new public SqlDataReader ExecuteReader() { SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); try { statistics = SqlStatistics.StartTimer(Statistics); @@ -2368,8 +2368,8 @@ override protected DbDataReader ExecuteDbDataReader(CommandBehavior behavior) /// new public SqlDataReader ExecuteReader(CommandBehavior behavior) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#, behavior={1}", ObjectID, (int)behavior); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}, behavior={1}", ObjectID, (int)behavior); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); try { @@ -2392,7 +2392,7 @@ public IAsyncResult BeginExecuteReader(CommandBehavior behavior) [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public IAsyncResult BeginExecuteReader(AsyncCallback callback, object stateObject, CommandBehavior behavior) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); SqlConnection.ExecutePermission.Demand(); return BeginExecuteReaderInternal(behavior, callback, stateObject, 0, inRetry: false); } @@ -2473,13 +2473,13 @@ public SqlDataReader EndExecuteReader(IAsyncResult asyncResult) } finally { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); } } private SqlDataReader EndExecuteReaderAsync(IAsyncResult asyncResult) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); Debug.Assert(!_internalEndExecuteInitiated || _stateObj == null); Exception asyncException = ((Task)asyncResult).Exception; @@ -2880,7 +2880,7 @@ private SqlDataReader InternalEndExecuteReader(IAsyncResult asyncResult, string /// public override Task ExecuteNonQueryAsync(CancellationToken cancellationToken) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); SqlConnection.ExecutePermission.Demand(); TaskCompletionSource source = new TaskCompletionSource(); @@ -2965,7 +2965,7 @@ 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); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, behavior={1}, ActivityID {2}", ObjectID, (int)behavior, ActivityCorrelator.Current); SqlConnection.ExecutePermission.Demand(); TaskCompletionSource source = new TaskCompletionSource(); @@ -3099,7 +3099,7 @@ public Task ExecuteXmlReaderAsync() /// public Task ExecuteXmlReaderAsync(CancellationToken cancellationToken) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current); SqlConnection.ExecutePermission.Demand(); TaskCompletionSource source = new TaskCompletionSource(); @@ -3705,7 +3705,7 @@ private Task RunExecuteNonQueryTds(string methodName, bool async, int timeout, b // no parameters are sent over // no data reader is returned // use this overload for "batch SQL" tds token type - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as SQLBATCH.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as SQLBATCH.", ObjectID); Task executeTask = _stateObj.Parser.TdsExecuteSQLBatch(this.CommandText, timeout, this.Notification, _stateObj, sync: true); Debug.Assert(executeTask == null, "Shouldn't get a task when doing sync writes"); @@ -3767,7 +3767,7 @@ private void RunExecuteNonQuerySmi(bool sendToPipe) SysTx.Transaction transaction; innerConnection.GetCurrentTransactionPair(out transactionId, out transaction); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, innerConnection={1}#, transactionId=0x{2}, cmdBehavior={3}.", ObjectID, innerConnection.ObjectID, transactionId, (int)CommandBehavior.Default); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, innerConnection={1}, transactionId=0x{2}, cmdBehavior={3}.", ObjectID, innerConnection.ObjectID, transactionId, (int)CommandBehavior.Default); if (SmiContextFactory.Instance.NegotiatedSmiVersion >= SmiContextFactory.KatmaiVersion) { @@ -5246,7 +5246,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi Debug.Assert(!IsUserPrepared, "CommandType.Text with no params should not be prepared!"); if (returnStream) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as SQLBATCH.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as SQLBATCH.", ObjectID); } string text = GetCommandText(cmdBehavior) + GetResetOptionsString(cmdBehavior); @@ -5311,7 +5311,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi rpc.options = TdsEnums.RPC_NOMETADATA; if (returnStream) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as RPC.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as RPC.", ObjectID); } // TODO: Medusa: Unprepare only happens for SQL 7.0 which may be broken anyway (it's not re-prepared). Consider removing the reset here if we're really dropping 7.0 support. @@ -5334,7 +5334,7 @@ private SqlDataReader RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavi optionSettings = GetSetOptionsString(cmdBehavior); if (returnStream) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Command executed as RPC.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Command executed as RPC.", ObjectID); } // turn set options ON @@ -5429,7 +5429,7 @@ private SqlDataReader RunExecuteReaderSmi(CommandBehavior cmdBehavior, RunBehavi long transactionId; SysTx.Transaction transaction; innerConnection.GetCurrentTransactionPair(out transactionId, out transaction); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, innerConnection={1}#, transactionId=0x{2}, commandBehavior={(int)cmdBehavior}.", ObjectID, innerConnection.ObjectID, transactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, innerConnection={1}, transactionId=0x{2}, commandBehavior={(int)cmdBehavior}.", ObjectID, innerConnection.ObjectID, transactionId); if (SmiContextFactory.Instance.NegotiatedSmiVersion >= SmiContextFactory.KatmaiVersion) { @@ -5649,7 +5649,7 @@ private void NotifyDependency() public SqlCommand Clone() { SqlCommand clone = new SqlCommand(this); - SqlClientEventSource.Log.TraceEvent(" {0}#, clone={1}#", ObjectID, clone.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, clone={1}", ObjectID, clone.ObjectID); return clone; } @@ -7450,7 +7450,7 @@ private void WriteBeginExecuteEvent() /// True if SQL command was executed synchronously, otherwise false. private void WriteEndExecuteEvent(bool success, int? sqlExceptionNumber, bool synchronous) { - if (SqlClientEventSource.Log.IsSqlClientEnabled()) + if (SqlClientEventSource.Log.IsExecutionTraceEnabled()) { // SqlEventSource.WriteEvent(int, int, int, int) is faster than provided overload SqlEventSource.WriteEvent(int, object[]). // that's why trying to fit several booleans in one integer value diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommandSet.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommandSet.cs index 66a92cf6bd..7f833e8907 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommandSet.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommandSet.cs @@ -129,7 +129,7 @@ internal int ObjectID internal void Append(SqlCommand command) { ADP.CheckArgumentNull(command, "command"); - SqlClientEventSource.Log.TraceEvent(" {0}#, command={1}, parameterCount={2}", ObjectID, command.ObjectID, command.Parameters.Count); + SqlClientEventSource.Log.TraceEvent(" {0}, command={1}, parameterCount={2}", ObjectID, command.ObjectID, command.Parameters.Count); string cmdText = command.CommandText; if (ADP.IsEmpty(cmdText)) @@ -264,7 +264,7 @@ internal static void BuildStoredProcedureName(StringBuilder builder, string part internal void Clear() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); DbCommand batchCommand = BatchCommand; if (null != batchCommand) { @@ -280,7 +280,7 @@ internal void Clear() internal void Dispose() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); SqlCommand command = _batchCommand; _commandList = null; _batchCommand = null; @@ -294,7 +294,7 @@ internal void Dispose() internal int ExecuteNonQuery() { SqlConnection.ExecutePermission.Demand(); - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs index f4f7831acd..02667f52c8 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnection.cs @@ -1101,7 +1101,7 @@ public SqlTransaction BeginTransaction(string transactionName) [SuppressMessage("Microsoft.Reliability", "CA2004:RemoveCallsToGCKeepAlive")] override protected DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#, isolationLevel={1}", ObjectID, (int)isolationLevel); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}, isolationLevel={1}", ObjectID, (int)isolationLevel); try { @@ -1126,7 +1126,7 @@ public SqlTransaction BeginTransaction(IsolationLevel iso, string transactionNam { WaitForPendingReconnection(); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#, iso={1}, transactionName='{2}'", ObjectID, (int)iso, (ADP.IsEmpty(transactionName) ? "None" : transactionName)); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}, iso={1}, transactionName='{2}'", ObjectID, (int)iso, (ADP.IsEmpty(transactionName) ? "None" : transactionName)); try { @@ -1164,7 +1164,7 @@ override public void ChangeDatabase(string database) { SqlStatistics statistics = null; RepairInnerConnection(); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID{0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); TdsParser bestEffortCleanupTarget = null; RuntimeHelpers.PrepareConstrainedRegions(); @@ -1258,8 +1258,8 @@ void CloseInnerConnection() /// override public void Close() { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); try { @@ -1398,7 +1398,7 @@ public void EnlistDistributedTransaction(System.EnterpriseServices.ITransaction override public void Open() { long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); try { @@ -1656,8 +1656,8 @@ void CancelOpenAndWait() /// public override Task OpenAsync(CancellationToken cancellationToken) { - long scopeID = SqlClientEventSource.Log.PoolerScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + long scopeID = SqlClientEventSource.Log.PoolerScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); try { @@ -1755,7 +1755,7 @@ public OpenAsyncRetry(SqlConnection parent, TaskCompletionSource retryTask) { - SqlClientEventSource.Log.TraceEvent(" {0}#", _parent.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", _parent.ObjectID); _registration.Dispose(); try @@ -2102,7 +2102,7 @@ internal void OnError(SqlException exception, bool breakConnection, Action {0}#, Connection broken.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection broken.", ObjectID); Close(); } }; @@ -2111,7 +2111,7 @@ internal void OnError(SqlException exception, bool breakConnection, Action {0}#, Connection broken.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection broken.", ObjectID); Close(); } } @@ -2219,7 +2219,7 @@ internal void OnInfoMessage(SqlInfoMessageEventArgs imevent, out bool notified) Debug.Assert(null != imevent, "null SqlInfoMessageEventArgs"); var imeventValue = (null != imevent) ? imevent.Message : ""; - SqlClientEventSource.Log.TraceEvent(" {0}#, Message='{1}'", ObjectID, imeventValue); + SqlClientEventSource.Log.TraceEvent(" {0}, Message='{1}'", ObjectID, imeventValue); SqlInfoMessageEventHandler handler = (SqlInfoMessageEventHandler)Events[EventInfoMessage]; if (null != handler) @@ -2500,7 +2500,6 @@ public static void ChangePassword(string connectionString, SqlCredential credent if (newSecurePassword == null || newSecurePassword.Length == 0) { throw SQL.ChangePasswordArgumentMissing("newSecurePassword"); - ; } if (!newSecurePassword.IsReadOnly()) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionString.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionString.cs index 9249f01995..37db14e50a 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionString.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlConnectionString.cs @@ -530,9 +530,9 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G throw SQL.IntegratedWithUserIDAndPassword(); } - if (Authentication == SqlAuthenticationMethod.ActiveDirectoryInteractive && (HasUserIdKeyword || HasPasswordKeyword)) + if (Authentication == SqlAuthenticationMethod.ActiveDirectoryInteractive && (HasPasswordKeyword)) { - throw SQL.InteractiveWithUserIDAndPassword(); + throw SQL.InteractiveWithPassword(); } #if ADONET_CERT_AUTH diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs index d41c3823ae..da0df01acd 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataAdapter.cs @@ -142,7 +142,7 @@ override public int UpdateBatchSize throw ADP.ArgumentOutOfRange("UpdateBatchSize"); } _updateBatchSize = value; - SqlClientEventSource.Log.TraceEvent(" {0}#, {1}", ObjectID, value); + SqlClientEventSource.Log.TraceEvent(" {0}, {1}", ObjectID, value); } } @@ -249,7 +249,7 @@ override protected RowUpdatingEventArgs CreateRowUpdatingEvent(DataRow dataRow, override protected int ExecuteBatch() { Debug.Assert(null != _commandSet && (0 < _commandSet.CommandCount), "no commands"); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); return _commandSet.ExecuteNonQuery(); } @@ -273,7 +273,7 @@ override protected bool GetBatchedRecordsAffected(int commandIdentifier, out int /// override protected void InitializeBatching() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); _commandSet = new SqlCommandSet(); SqlCommand command = SelectCommand; if (null == command) diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs index 9b7dc1ee75..b0aa416b24 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReader.cs @@ -939,7 +939,7 @@ private void CleanPartialReadReliable() override public void Close() { SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { @@ -1670,7 +1670,7 @@ override public int GetProviderSpecificValues(object[] values) override public DataTable GetSchemaTable() { SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { @@ -3597,7 +3597,7 @@ override public bool NextResult() private bool TryNextResult(out bool more) { SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try @@ -3803,7 +3803,7 @@ override public bool Read() private bool TryReadInternal(bool setTimeout, out bool more) { SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try @@ -4470,7 +4470,7 @@ private void RestoreServerSettings(TdsParser parser, TdsParserStateObject stateO // broken connection, so check state first. if (parser.State == TdsParserState.OpenLoggedIn) { - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID '{1}'", ObjectID, ActivityCorrelator.Current.ToString()); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID '{1}'", ObjectID, ActivityCorrelator.Current.ToString()); Task executeTask = parser.TdsExecuteSQLBatch(_resetOptionsString, (_command != null) ? _command.CommandTimeout : 0, null, stateObj, sync: true); Debug.Assert(executeTask == null, "Shouldn't get a task when doing sync writes"); @@ -4782,7 +4782,7 @@ private void AssertReaderState(bool requireData, bool permitAsync, int? columnIn /// public override Task NextResultAsync(CancellationToken cancellationToken) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { @@ -4828,7 +4828,7 @@ public override Task NextResultAsync(CancellationToken cancellationToken) { if (t != null) { - SqlClientEventSource.Log.TraceEvent(" attempt retry {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" attempt retry {0}", ObjectID); PrepareForAsyncContinuation(); } @@ -4910,7 +4910,7 @@ internal Task GetBytesAsync(int i, byte[] buffer, int index, int length, in { if (t != null) { - SqlClientEventSource.Log.TraceEvent(" attempt retry {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" attempt retry {0}", ObjectID); PrepareForAsyncContinuation(); } @@ -5081,7 +5081,7 @@ private Task GetBytesAsyncReadDataStage(int i, byte[] buffer, int index, in /// public override Task ReadAsync(CancellationToken cancellationToken) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); try { if (IsClosed) @@ -5201,7 +5201,7 @@ public override Task ReadAsync(CancellationToken cancellationToken) { if (t != null) { - SqlClientEventSource.Log.TraceEvent(" attempt retry {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" attempt retry {0}", ObjectID); PrepareForAsyncContinuation(); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs index 1f589c0de2..bc5d483954 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDataReaderSmi.cs @@ -374,7 +374,7 @@ public override void Close() private void CloseInternal(bool closeConnection) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); bool processFinallyBlock = true; try { @@ -433,7 +433,7 @@ public override Task NextResultAsync(CancellationToken cancellationToken) internal unsafe bool InternalNextResult(bool ignoreNonFatalMessages) { - long scopeID = SqlClientEventSource.Log.AdvanceScopeEnter(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.AdvancedScopeEnterEvent(" {0}", ObjectID); try { _hasRows = false; @@ -486,7 +486,7 @@ public override Task ReadAsync(CancellationToken cancellationToken) internal unsafe bool InternalRead(bool ignoreNonFatalErrors) { - long scopeID = SqlClientEventSource.Log.AdvanceScopeEnter(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.AdvancedScopeEnterEvent(" {0}", ObjectID); try { // Don't move unless currently in results. @@ -1316,15 +1316,15 @@ internal ReaderEventSink(SqlDataReaderSmi reader, SmiEventSink parent) internal override void MetaDataAvailable(SmiQueryMetaData[] md, bool nextEventIsRow) { var mdLength = (null != md) ? md.Length : -1; - SqlClientEventSource.Log.AdvanceTrace(" {0}#, md.Length={1} nextEventIsRow={2}.", reader.ObjectID, mdLength, nextEventIsRow); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, md.Length={1} nextEventIsRow={2}.", reader.ObjectID, mdLength, nextEventIsRow); - if (SqlClientEventSource.Log.IsAdvanceTraceOn()) + if (SqlClientEventSource.Log.IsAdvancedTraceOn()) { if (null != md) { for (int i = 0; i < md.Length; i++) { - SqlClientEventSource.Log.TraceEvent(" {0}#, metaData[{1}] is {2}{3}", reader.ObjectID, i, md[i].GetType().ToString(), md[i].TraceString()); + SqlClientEventSource.Log.TraceEvent(" {0}, metaData[{1}] is {2}{3}", reader.ObjectID, i, md[i].GetType().ToString(), md[i].TraceString()); } } } @@ -1334,25 +1334,25 @@ internal override void MetaDataAvailable(SmiQueryMetaData[] md, bool nextEventIs // Obsolete V2- method internal override void RowAvailable(ITypedGetters row) { - SqlClientEventSource.Log.AdvanceTrace(" {0}# (v2).", reader.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} (v2).", reader.ObjectID); this.reader.RowAvailable(row); } internal override void RowAvailable(ITypedGettersV3 row) { - SqlClientEventSource.Log.AdvanceTrace(" {0}# (ITypedGettersV3).", reader.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} (ITypedGettersV3).", reader.ObjectID); this.reader.RowAvailable(row); } internal override void RowAvailable(SmiTypedGetterSetter rowData) { - SqlClientEventSource.Log.AdvanceTrace(" {0}# (SmiTypedGetterSetter).", reader.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} (SmiTypedGetterSetter).", reader.ObjectID); this.reader.RowAvailable(rowData); } internal override void StatementCompleted(int recordsAffected) { - SqlClientEventSource.Log.AdvanceTrace(" {0}# recordsAffected= {1}.", reader.ObjectID, recordsAffected); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} recordsAffected= {1}.", reader.ObjectID, recordsAffected); // devnote: relies on SmiEventSink_Default to pass event to parent // Both command and reader care about StatementCompleted, but for different reasons. @@ -1362,7 +1362,7 @@ internal override void StatementCompleted(int recordsAffected) internal override void BatchCompleted() { - SqlClientEventSource.Log.AdvanceTrace(" {0}#.", reader.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}.", reader.ObjectID); // devnote: relies on SmiEventSink_Default to pass event to parent // parent's callback *MUST* come before reader's BatchCompleted, since diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs index 006fc1f15a..21a5966f3e 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDelegatedTransaction.cs @@ -89,7 +89,7 @@ public void Initialize() // transaction. SqlInternalConnection connection = _connection; SqlConnection usersConnection = connection.Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, delegating transaction.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, delegating transaction.", ObjectID, connection.ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try @@ -106,7 +106,7 @@ public void Initialize() #endif //DEBUG if (connection.IsEnlistedInTransaction) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, was enlisted, now defecting.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, was enlisted, now defecting.", ObjectID, connection.ObjectID); // defect first connection.EnlistNull(); @@ -168,7 +168,7 @@ public Byte[] Promote() Exception promoteException; byte[] returnValue = null; SqlConnection usersConnection = connection.Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, promoting transaction.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, promoting transaction.", ObjectID, connection.ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try @@ -268,7 +268,7 @@ public void Rollback(SysTx.SinglePhaseEnlistment enlistment) SqlInternalConnection connection = GetValidConnection(); SqlConnection usersConnection = connection.Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, aborting transaction.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, aborting transaction.", ObjectID, connection.ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try @@ -362,7 +362,7 @@ public void SinglePhaseCommit(SysTx.SinglePhaseEnlistment enlistment) SqlInternalConnection connection = GetValidConnection(); SqlConnection usersConnection = connection.Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, committing transaction.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, committing transaction.", ObjectID, connection.ObjectID); RuntimeHelpers.PrepareConstrainedRegions(); try @@ -494,7 +494,7 @@ internal void TransactionEnded(SysTx.Transaction transaction) if (connection != null) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Connection {1}#, transaction completed externally.", ObjectID, connection.ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Connection {1}, transaction completed externally.", ObjectID, connection.ObjectID); lock (connection) { diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependency.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependency.cs index 7264a88d1c..494459530c 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependency.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependency.cs @@ -316,7 +316,7 @@ public SqlDependency(SqlCommand command) : this(command, null, SQL.SqlDependency [System.Security.Permissions.HostProtectionAttribute(ExternalThreading = true)] public SqlDependency(SqlCommand command, string options, int timeout) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, options: '{1}', timeout: '{2}'", ObjectID, options, timeout); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, options: '{1}', timeout: '{2}'", ObjectID, options, timeout); try { if (InOutOfProcHelper.InProc) @@ -339,7 +339,7 @@ public SqlDependency(SqlCommand command, string options, int timeout) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -436,7 +436,7 @@ internal int Timeout // EventHandlers to be fired when dependency is notified. add { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { @@ -449,12 +449,12 @@ internal int Timeout if (_dependencyFired) { // If fired, fire the new event immediately. - SqlClientEventSource.Log.NotificationsTrace(" Dependency already fired, firing new event."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency already fired, firing new event."); sqlNotificationEvent = new SqlNotificationEventArgs(SqlNotificationType.Subscribe, SqlNotificationInfo.AlreadyChanged, SqlNotificationSource.Client); } else { - SqlClientEventSource.Log.NotificationsTrace(" Dependency has not fired, adding new event."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency has not fired, adding new event."); EventContextPair pair = new EventContextPair(value, this); if (!_eventList.Contains(pair)) { @@ -475,12 +475,12 @@ internal int Timeout } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } remove { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { if (null != value) @@ -498,7 +498,7 @@ internal int Timeout } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } @@ -515,7 +515,7 @@ public void AddCommandDependency(SqlCommand command) { // Adds command to dependency collection so we automatically create the SqlNotificationsRequest object // and listen for a notification for the added commands. - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { if (command == null) @@ -527,7 +527,7 @@ public void AddCommandDependency(SqlCommand command) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -553,10 +553,10 @@ private static void ObtainProcessDispatcher() if (nativeStorage == null) { - SqlClientEventSource.Log.NotificationsTrace(" nativeStorage null, obtaining dispatcher AppDomain and creating ProcessDispatcher."); + SqlClientEventSource.Log.NotificationTraceEvent(" nativeStorage null, obtaining dispatcher AppDomain and creating ProcessDispatcher."); #if DEBUG // Possibly expensive, limit to debug. - SqlClientEventSource.Log.NotificationsTraceEvent(" AppDomain.CurrentDomain.FriendlyName: {0}", AppDomain.CurrentDomain.FriendlyName); + SqlClientEventSource.Log.NotificationTraceEvent(" AppDomain.CurrentDomain.FriendlyName: {0}", AppDomain.CurrentDomain.FriendlyName); #endif _AppDomain masterDomain = SNINativeMethodWrapper.GetDefaultAppDomain(); @@ -582,33 +582,33 @@ private static void ObtainProcessDispatcher() } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - ObjectHandle.Unwrap returned null!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - ObjectHandle.Unwrap returned null!"); throw ADP.InternalError(ADP.InternalErrorCode.SqlDependencyObtainProcessDispatcherFailureObjectHandle); } } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - AppDomain.CreateInstance returned null!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - AppDomain.CreateInstance returned null!"); throw ADP.InternalError(ADP.InternalErrorCode.SqlDependencyProcessDispatcherFailureCreateInstance); } } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - unable to obtain default AppDomain!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - unable to obtain default AppDomain!"); throw ADP.InternalError(ADP.InternalErrorCode.SqlDependencyProcessDispatcherFailureAppDomain); } } else { - SqlClientEventSource.Log.NotificationsTrace(" nativeStorage not null, obtaining existing dispatcher AppDomain and ProcessDispatcher."); + SqlClientEventSource.Log.NotificationTraceEvent(" nativeStorage not null, obtaining existing dispatcher AppDomain and ProcessDispatcher."); #if DEBUG // Possibly expensive, limit to debug. - SqlClientEventSource.Log.NotificationsTraceEvent(" AppDomain.CurrentDomain.FriendlyName: {0}", AppDomain.CurrentDomain.FriendlyName); + SqlClientEventSource.Log.NotificationTraceEvent(" AppDomain.CurrentDomain.FriendlyName: {0}", AppDomain.CurrentDomain.FriendlyName); #endif BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(nativeStorage); _processDispatcher = GetDeserializedObject(formatter, stream); // Deserialize and set for appdomain. - SqlClientEventSource.Log.NotificationsTraceEvent(" processDispatcher obtained, ID: {0}", _processDispatcher.ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" processDispatcher obtained, ID: {0}", _processDispatcher.ObjectID); } } @@ -655,7 +655,7 @@ public static bool Start(string connectionString, string queue) internal static bool Start(string connectionString, string queue, bool useDefaults) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" AppDomainKey: '{0}', queue: '{1}'", AppDomainKey, queue); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" AppDomainKey: '{0}', queue: '{1}'", AppDomainKey, queue); try { // The following code exists in Stop as well. It exists here to demand permissions as high in the stack @@ -729,7 +729,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul out errorOccurred, out appDomainStart); - SqlClientEventSource.Log.NotificationsTraceEvent(" Start (defaults) returned: '{0}', with service: '{1}', server: '{2}', database: '{3}'", result, service, server, database); + SqlClientEventSource.Log.NotificationTraceEvent(" Start (defaults) returned: '{0}', with service: '{1}', server: '{2}', database: '{3}'", result, service, server, database); } finally { @@ -751,7 +751,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul } ADP.TraceExceptionWithoutRethrow(e); // Discard failure, but trace for now. - SqlClientEventSource.Log.NotificationsTrace(" Exception occurred from Stop() after duplicate was found on Start()."); + SqlClientEventSource.Log.NotificationTraceEvent(" Exception occurred from Stop() after duplicate was found on Start()."); } throw SQL.SqlDependencyDuplicateStart(); } @@ -764,7 +764,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul queue, _appDomainKey, SqlDependencyPerAppDomainDispatcher.SingletonInstance); - SqlClientEventSource.Log.NotificationsTraceEvent(" Start (user provided queue) returned: '{0}'", result); + SqlClientEventSource.Log.NotificationTraceEvent(" Start (user provided queue) returned: '{0}'", result); // No need to call AddToServerDatabaseHash since if not using default queue user is required // to provide options themselves. @@ -779,7 +779,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul ADP.TraceExceptionWithoutRethrow(e); // Discard failure, but trace for now. - SqlClientEventSource.Log.NotificationsTraceEvent(" Exception occurred from _processDispatcher.Start(...), calling Invalidate(...)."); + SqlClientEventSource.Log.NotificationTraceEvent(" Exception occurred from _processDispatcher.Start(...), calling Invalidate(...)."); throw; } } @@ -788,7 +788,7 @@ internal static bool Start(string connectionString, string queue, bool useDefaul } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -808,7 +808,7 @@ public static bool Stop(string connectionString, string queue) internal static bool Stop(string connectionString, string queue, bool useDefaults, bool startFailed) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" AppDomainKey: '{0}', queue: '{1}'", AppDomainKey, queue); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" AppDomainKey: '{0}', queue: '{1}'", AppDomainKey, queue); try { // The following code exists in Stop as well. It exists here to demand permissions as high in the stack @@ -918,7 +918,7 @@ internal static bool Stop(string connectionString, string queue, bool useDefault } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -928,7 +928,7 @@ internal static bool Stop(string connectionString, string queue, bool useDefault private static bool AddToServerUserHash(string server, IdentityUserNamePair identityUser, DatabaseServicePair databaseService) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" server: '{0}', database: '{1}', service: '{2}'", server, databaseService.Database, databaseService.Service); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" server: '{0}', database: '{1}', service: '{2}'", server, databaseService.Database, databaseService.Service); try { bool result = false; @@ -939,7 +939,7 @@ private static bool AddToServerUserHash(string server, IdentityUserNamePair iden if (!_serverUserHash.ContainsKey(server)) { - SqlClientEventSource.Log.NotificationsTrace(" Hash did not contain server, adding."); + SqlClientEventSource.Log.NotificationTraceEvent(" Hash did not contain server, adding."); identityDatabaseHash = new Dictionary>(); _serverUserHash.Add(server, identityDatabaseHash); } @@ -952,7 +952,7 @@ private static bool AddToServerUserHash(string server, IdentityUserNamePair iden if (!identityDatabaseHash.ContainsKey(identityUser)) { - SqlClientEventSource.Log.NotificationsTrace(" Hash contained server but not user, adding user."); + SqlClientEventSource.Log.NotificationTraceEvent(" Hash contained server but not user, adding user."); databaseServiceList = new List(); identityDatabaseHash.Add(identityUser, databaseServiceList); } @@ -963,13 +963,13 @@ private static bool AddToServerUserHash(string server, IdentityUserNamePair iden if (!databaseServiceList.Contains(databaseService)) { - SqlClientEventSource.Log.NotificationsTrace(" Adding database."); + SqlClientEventSource.Log.NotificationTraceEvent(" Adding database."); databaseServiceList.Add(databaseService); result = true; } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - hash already contained server, user, and database - we will throw!."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - hash already contained server, user, and database - we will throw!."); } } @@ -977,13 +977,13 @@ private static bool AddToServerUserHash(string server, IdentityUserNamePair iden } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private static void RemoveFromServerUserHash(string server, IdentityUserNamePair identityUser, DatabaseServicePair databaseService) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" server: '{0}', database: '{1}', service: '{2}'", server, databaseService.Database, databaseService.Service); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" server: '{0}', database: '{1}', service: '{2}'", server, databaseService.Database, databaseService.Service); try { lock (_serverUserHash) @@ -1003,43 +1003,43 @@ private static void RemoveFromServerUserHash(string server, IdentityUserNamePair int index = databaseServiceList.IndexOf(databaseService); if (index >= 0) { - SqlClientEventSource.Log.NotificationsTrace(" Hash contained server, user, and database - removing database."); + SqlClientEventSource.Log.NotificationTraceEvent(" Hash contained server, user, and database - removing database."); databaseServiceList.RemoveAt(index); if (databaseServiceList.Count == 0) { - SqlClientEventSource.Log.NotificationsTrace(" databaseServiceList count 0, removing the list for this server and user."); + SqlClientEventSource.Log.NotificationTraceEvent(" databaseServiceList count 0, removing the list for this server and user."); identityDatabaseHash.Remove(identityUser); if (identityDatabaseHash.Count == 0) { - SqlClientEventSource.Log.NotificationsTrace(" identityDatabaseHash count 0, removing the hash for this server."); + SqlClientEventSource.Log.NotificationTraceEvent(" identityDatabaseHash count 0, removing the hash for this server."); _serverUserHash.Remove(server); } } } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - hash contained server and user but not database!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - hash contained server and user but not database!"); Debug.Assert(false, "Unexpected state - hash did not contain database!"); } } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - hash contained server but not user!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - hash contained server but not user!"); Debug.Assert(false, "Unexpected state - hash did not contain user!"); } } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - hash did not contain server!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - hash did not contain server!"); Debug.Assert(false, "Unexpected state - hash did not contain server!"); } } } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1047,7 +1047,7 @@ internal static string GetDefaultComposedOptions(string server, string failoverS { // Server must be an exact match, but user and database only needs to match exactly if there is more than one // for the given user or database passed. That is ambiguious and we must fail. - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" server: '{0}', failoverServer: '{1}', database: '{2}'", server, failoverServer, database); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" server: '{0}', failoverServer: '{1}', database: '{2}'", server, failoverServer, database); try { @@ -1060,17 +1060,17 @@ internal static string GetDefaultComposedOptions(string server, string failoverS if (0 == _serverUserHash.Count) { // Special error for no calls to start. - SqlClientEventSource.Log.NotificationsTrace(" ERROR - no start calls have been made, about to throw."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - no start calls have been made, about to throw."); throw SQL.SqlDepDefaultOptionsButNoStart(); } else if (!ADP.IsEmpty(failoverServer) && _serverUserHash.ContainsKey(failoverServer)) { - SqlClientEventSource.Log.NotificationsTrace(" using failover server instead\n"); + SqlClientEventSource.Log.NotificationTraceEvent(" using failover server instead\n"); server = failoverServer; } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - not listening to this server, about to throw."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - not listening to this server, about to throw."); throw SQL.SqlDependencyNoMatchingServerStart(); } } @@ -1083,7 +1083,7 @@ internal static string GetDefaultComposedOptions(string server, string failoverS { if (identityDatabaseHash.Count > 1) { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - not listening for this user, " + + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - not listening for this user, " + "but listening to more than one other user, about to throw."); throw SQL.SqlDependencyNoMatchingServerStart(); } @@ -1131,19 +1131,19 @@ internal static string GetDefaultComposedOptions(string server, string failoverS else { // More than one database for given server, ambiguous - fail the default case! - SqlClientEventSource.Log.NotificationsTrace(" ERROR - SqlDependency.Start called multiple times for this server/user, but no matching database."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - SqlDependency.Start called multiple times for this server/user, but no matching database."); throw SQL.SqlDependencyNoMatchingServerDatabaseStart(); } } } Debug.Assert(!ADP.IsEmpty(result), "GetDefaultComposedOptions should never return null or empty string!"); - SqlClientEventSource.Log.NotificationsTraceEvent(" resulting options: '{0}'.", result); + SqlClientEventSource.Log.NotificationTraceEvent(" resulting options: '{0}'.", result); return result; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1155,7 +1155,7 @@ internal static string GetDefaultComposedOptions(string server, string failoverS // use this list for a reverse lookup based on server. internal void AddToServerList(string server) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, server: '{1}'", ObjectID, server); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, server: '{1}'", ObjectID, server); try { lock (_serverList) @@ -1164,7 +1164,7 @@ internal void AddToServerList(string server) if (0 > index) { // If less than 0, item was not found in list. - SqlClientEventSource.Log.NotificationsTraceEvent(" Server not present in hashtable, adding server: '{0}'.", server); + SqlClientEventSource.Log.NotificationTraceEvent(" Server not present in hashtable, adding server: '{0}'.", server); index = ~index; // BinarySearch returns the 2's compliment of where the item should be inserted to preserver a sorted list after insertion. _serverList.Insert(index, server); } @@ -1172,7 +1172,7 @@ internal void AddToServerList(string server) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1186,7 +1186,7 @@ internal bool ContainsServer(string server) internal string ComputeHashAndAddToDispatcher(SqlCommand command) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlCommand: {1}#", ObjectID, command.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlCommand: {1}", ObjectID, command.ObjectID); try { // Create a string representing the concatenation of the connection string, command text and .ToString on all parameter values. @@ -1201,18 +1201,18 @@ internal string ComputeHashAndAddToDispatcher(SqlCommand command) string commandHash = ComputeCommandHash(command.Connection.ConnectionString, command); // calculate the string representation of command string idString = SqlDependencyPerAppDomainDispatcher.SingletonInstance.AddCommandEntry(commandHash, this); // Add to map. - SqlClientEventSource.Log.NotificationsTraceEvent(" computed id string: '{0}'.", idString); + SqlClientEventSource.Log.NotificationTraceEvent(" computed id string: '{0}'.", idString); return idString; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } internal void Invalidate(SqlNotificationType type, SqlNotificationInfo info, SqlNotificationSource source) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { List eventList = null; @@ -1230,12 +1230,12 @@ internal void Invalidate(SqlNotificationType type, SqlNotificationInfo info, Sql // raises Timeout event but before removing this event from the list. If notification is received from // server in this case, we will hit this code path. // It is safe to ignore this race condition because no event is sent to user and no leak happens. - SqlClientEventSource.Log.NotificationsTrace(" ignore notification received after timeout!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ignore notification received after timeout!"); } else { Debug.Assert(false, "Received notification twice - we should never enter this state!"); - SqlClientEventSource.Log.NotificationsTrace(" ERROR - notification received twice - we should never enter this state!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - notification received twice - we should never enter this state!"); } } else @@ -1249,7 +1249,7 @@ internal void Invalidate(SqlNotificationType type, SqlNotificationInfo info, Sql if (eventList != null) { - SqlClientEventSource.Log.NotificationsTrace(" Firing events."); + SqlClientEventSource.Log.NotificationTraceEvent(" Firing events."); foreach (EventContextPair pair in eventList) { pair.Invoke(new SqlNotificationEventArgs(type, info, source)); @@ -1258,19 +1258,19 @@ internal void Invalidate(SqlNotificationType type, SqlNotificationInfo info, Sql } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // This method is used by SqlCommand. internal void StartTimer(SqlNotificationRequest notificationRequest) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { if (_expirationTime == DateTime.MaxValue) { - SqlClientEventSource.Log.NotificationsTrace(" We've timed out, executing logic."); + SqlClientEventSource.Log.NotificationTraceEvent(" We've timed out, executing logic."); int seconds = SQL.SqlDependencyServerTimeout; if (0 != _timeout) { @@ -1288,7 +1288,7 @@ internal void StartTimer(SqlNotificationRequest notificationRequest) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1301,7 +1301,7 @@ private void AddCommandInternal(SqlCommand cmd) if (cmd != null) { // Don't bother with BID if command null. - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlCommand: {1}#", ObjectID, cmd.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlCommand: {1}", ObjectID, cmd.ObjectID); try { SqlConnection connection = cmd.Connection; @@ -1311,7 +1311,7 @@ private void AddCommandInternal(SqlCommand cmd) // Fail if cmd has notification that is not already associated with this dependency. if (cmd._sqlDep == null || cmd._sqlDep != this) { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - throwing command has existing SqlNotificationRequest exception."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - throwing command has existing SqlNotificationRequest exception."); throw SQL.SqlCommandHasExistingSqlNotificationRequest(); } } @@ -1343,7 +1343,7 @@ private void AddCommandInternal(SqlCommand cmd) if (0 == _eventList.Count) { // Keep logic just in case. - SqlClientEventSource.Log.NotificationsTrace(" ERROR - firing events, though it is unexpected we have events at this point."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - firing events, though it is unexpected we have events at this point."); needToInvalidate = true; // Delay invalidation until outside of lock. } } @@ -1357,14 +1357,14 @@ private void AddCommandInternal(SqlCommand cmd) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } private string ComputeCommandHash(string connectionString, SqlCommand command) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlCommand: {1}#", ObjectID, command.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlCommand: {1}", ObjectID, command.ObjectID); try { // Create a string representing the concatenation of the connection string, the command text and .ToString on all its parameter values. @@ -1421,12 +1421,12 @@ private string ComputeCommandHash(string connectionString, SqlCommand command) } string result = builder.ToString(); - SqlClientEventSource.Log.NotificationsTraceEvent(" ComputeCommandHash result: '{0}'.", result); + SqlClientEventSource.Log.NotificationTraceEvent(" ComputeCommandHash result: '{0}'.", result); return result; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs index 91a98920d2..42783f430b 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependencyListener.cs @@ -78,7 +78,7 @@ internal int ObjectID // ----------- internal SqlConnectionContainer(SqlConnectionContainerHashHelper hashHelper, string appDomainKey, bool useDefaults) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, queue: '{1}'", ObjectID, HashHelper?.Queue); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, queue: '{1}'", ObjectID, HashHelper?.Queue); bool setupCompleted = false; try @@ -101,7 +101,7 @@ internal SqlConnectionContainer(SqlConnectionContainerHashHelper hashHelper, str #if DEBUG SqlConnectionString connectionStringOptions = new SqlConnectionString(_hashHelper.ConnectionStringBuilder.ConnectionString); - SqlClientEventSource.Log.NotificationsTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); + SqlClientEventSource.Log.NotificationTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); #endif // Always use ConnectionStringBuilder since in default case it is different from the @@ -216,7 +216,7 @@ internal SqlConnectionContainer(SqlConnectionContainerHashHelper hashHelper, str } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -276,7 +276,7 @@ internal string Server // SqlDependencyProcessDispatcher.QueueAppDomainUnload on AppDomain.Unload. internal bool AppDomainUnload(string appDomainKey) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, AppDomainKey: '{1}'", ObjectID, appDomainKey); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, AppDomainKey: '{1}'", ObjectID, appDomainKey); try { Debug.Assert(!ADP.IsEmpty(appDomainKey), "Unexpected empty appDomainKey!"); @@ -288,9 +288,9 @@ internal bool AppDomainUnload(string appDomainKey) if (_appDomainKeyHash.ContainsKey(appDomainKey)) { // Do nothing if AppDomain did not call Start! - SqlClientEventSource.Log.NotificationsTraceEvent(" _appDomainKeyHash contained AppDomainKey: '{0}'.", appDomainKey); + SqlClientEventSource.Log.NotificationTraceEvent(" _appDomainKeyHash contained AppDomainKey: '{0}'.", appDomainKey); int value = _appDomainKeyHash[appDomainKey]; - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> _appDomainKeyHash for AppDomainKey: '{0}' count: '{1}'.", appDomainKey, value); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> _appDomainKeyHash for AppDomainKey: '{0}' count: '{1}'.", appDomainKey, value); Debug.Assert(value > 0, "Why is value 0 or less?"); bool ignored = false; @@ -307,26 +307,26 @@ internal bool AppDomainUnload(string appDomainKey) if (_appDomainKeyHash.ContainsKey(appDomainKey)) { - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP|ERR> ERROR - after the Stop() loop, _appDomainKeyHash for AppDomainKey: '{0}' entry not removed from hash. Count: {1}'", appDomainKey, _appDomainKeyHash[appDomainKey]); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP|ERR> ERROR - after the Stop() loop, _appDomainKeyHash for AppDomainKey: '{0}' entry not removed from hash. Count: {1}'", appDomainKey, _appDomainKeyHash[appDomainKey]); } } else { - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> _appDomainKeyHash did not contain AppDomainKey: '{0}'.", appDomainKey); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> _appDomainKeyHash did not contain AppDomainKey: '{0}'.", appDomainKey); } } - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> Exiting, _stopped: '{0}'.", _stopped); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.AppDomainUnload|DEP> Exiting, _stopped: '{0}'.", _stopped); return _stopped; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void AsynchronouslyQueryServiceBrokerQueue() { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { AsyncCallback callback = new AsyncCallback(AsyncResultCallback); @@ -334,13 +334,13 @@ private void AsynchronouslyQueryServiceBrokerQueue() } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void AsyncResultCallback(IAsyncResult asyncResult) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { using (SqlDataReader reader = _com.EndExecuteReader(asyncResult)) @@ -366,7 +366,7 @@ private void AsyncResultCallback(IAsyncResult asyncResult) _errorState = true; throw; } - SqlClientEventSource.Log.NotificationsTrace(" Exception occurred."); + SqlClientEventSource.Log.NotificationTraceEvent(" Exception occurred."); if (!_stop) { // Only assert if not in cancel path. @@ -386,13 +386,13 @@ private void AsyncResultCallback(IAsyncResult asyncResult) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void CreateQueueAndService(bool restart) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { SqlCommand com = new SqlCommand(); @@ -522,18 +522,18 @@ private void CreateQueueAndService(bool restart) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } internal void IncrementStartCount(string appDomainKey, out bool appDomainStart) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { appDomainStart = false; // Reset out param. int result = Interlocked.Increment(ref _startCount); // Add to refCount. - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.IncrementStartCount|DEP> {0}#, incremented _startCount: {1}", _staticInstance.ObjectID, result); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.IncrementStartCount|DEP> {0}, incremented _startCount: {1}", _staticInstance.ObjectID, result); // Dictionary used to track how many times start has been called per app domain. // For each increment, add to count, and create entry if not present. @@ -542,25 +542,25 @@ internal void IncrementStartCount(string appDomainKey, out bool appDomainStart) if (_appDomainKeyHash.ContainsKey(appDomainKey)) { _appDomainKeyHash[appDomainKey] = _appDomainKeyHash[appDomainKey] + 1; - SqlClientEventSource.Log.NotificationsTraceEvent("SqlConnectionContainer.IncrementStartCount|DEP> _appDomainKeyHash contained AppDomainKey: '{0}', incremented count: '{1}'.", appDomainKey, _appDomainKeyHash[appDomainKey]); + SqlClientEventSource.Log.NotificationTraceEvent("SqlConnectionContainer.IncrementStartCount|DEP> _appDomainKeyHash contained AppDomainKey: '{0}', incremented count: '{1}'.", appDomainKey, _appDomainKeyHash[appDomainKey]); } else { _appDomainKeyHash[appDomainKey] = 1; appDomainStart = true; - SqlClientEventSource.Log.NotificationsTraceEvent(" _appDomainKeyHash did not contain AppDomainKey: '{0}', added to hashtable and value set to 1.", appDomainKey); + SqlClientEventSource.Log.NotificationTraceEvent(" _appDomainKeyHash did not contain AppDomainKey: '{0}', added to hashtable and value set to 1.", appDomainKey); } } } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void ProcessNotificationResults(SqlDataReader reader) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { Guid handle = Guid.Empty; // Conversation_handle. Always close this! @@ -570,18 +570,18 @@ private void ProcessNotificationResults(SqlDataReader reader) { while (reader.Read()) { - SqlClientEventSource.Log.NotificationsTrace(" Row read."); + SqlClientEventSource.Log.NotificationTraceEvent(" Row read."); #if DEBUG if (SqlClientEventSource.Log.IsNotificationTraceEnabled()) { for (int i = 0; i < reader.FieldCount; i++) { - SqlClientEventSource.Log.NotificationsTraceEvent(" column: {0}, value: {1}", reader.GetName(i), reader.GetValue(i).ToString()); + SqlClientEventSource.Log.NotificationTraceEvent(" column: {0}, value: {1}", reader.GetName(i), reader.GetValue(i).ToString()); } } #endif string msgType = reader.GetString(0); - SqlClientEventSource.Log.NotificationsTraceEvent(" msgType: '{0}'", msgType); + SqlClientEventSource.Log.NotificationTraceEvent(" msgType: '{0}'", msgType); handle = reader.GetGuid(1); // Only process QueryNotification messages. @@ -594,7 +594,7 @@ private void ProcessNotificationResults(SqlDataReader reader) if (null != notification) { string key = notification.Key; - SqlClientEventSource.Log.NotificationsTraceEvent(" Key: '{0}'", key); + SqlClientEventSource.Log.NotificationTraceEvent(" Key: '{0}'", key); int index = key.IndexOf(';'); // Our format is simple: "AppDomainKey;commandHash" if (index >= 0) @@ -623,25 +623,25 @@ private void ProcessNotificationResults(SqlDataReader reader) else { Debug.Assert(false, "Received notification but do not have an associated PerAppDomainDispatcher!"); - SqlClientEventSource.Log.NotificationsTrace(" Received notification but do not have an associated PerAppDomainDispatcher!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Received notification but do not have an associated PerAppDomainDispatcher!"); } } else { Debug.Assert(false, "Unexpected ID format received!"); - SqlClientEventSource.Log.NotificationsTrace(" Unexpected ID format received!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Unexpected ID format received!"); } } else { Debug.Assert(false, "Null notification returned from ProcessMessage!"); - SqlClientEventSource.Log.NotificationsTrace(" Null notification returned from ProcessMessage!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Null notification returned from ProcessMessage!"); } } else { Debug.Assert(false, "Null payload for QN notification type!"); - SqlClientEventSource.Log.NotificationsTrace(" Null payload for QN notification type!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Null payload for QN notification type!"); } } else @@ -649,7 +649,7 @@ private void ProcessNotificationResults(SqlDataReader reader) handle = Guid.Empty; // VSDD 546707: this assert was hit by SQL Notification fuzzing tests, disable it to let these tests run on Debug bits // Debug.Assert(false, "Unexpected message format received!"); - SqlClientEventSource.Log.NotificationsTrace(" Unexpected message format received!"); + SqlClientEventSource.Log.NotificationTraceEvent(" Unexpected message format received!"); } } } @@ -681,7 +681,7 @@ private void ProcessNotificationResults(SqlDataReader reader) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -692,7 +692,7 @@ private void ProcessNotificationResults(SqlDataReader reader) private void Restart(object unused) { // Unused arg required by TimerCallback. - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { try @@ -854,13 +854,13 @@ private void Restart(object unused) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } internal bool Stop(string appDomainKey, out bool appDomainStop) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { appDomainStop = false; @@ -880,7 +880,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) int value = _appDomainKeyHash[appDomainKey]; Debug.Assert(value > 0, "Unexpected count for appDomainKey"); - SqlClientEventSource.Log.NotificationsTraceEvent(" _appDomainKeyHash contained AppDomainKey: '{0}', pre-decrement Count: '{1}'.", appDomainKey, value); + SqlClientEventSource.Log.NotificationTraceEvent(" _appDomainKeyHash contained AppDomainKey: '{0}', pre-decrement Count: '{1}'.", appDomainKey, value); if (value > 0) { @@ -888,7 +888,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR pre-decremented count <= 0!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR pre-decremented count <= 0!"); Debug.Assert(false, "Unexpected AppDomainKey count in Stop()"); } @@ -900,7 +900,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR appDomainKey not null and not found in hash!"); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR appDomainKey not null and not found in hash!"); Debug.Assert(false, "Unexpected state on Stop() - no AppDomainKey entry in hashtable!"); } } @@ -913,7 +913,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) { // If we've reached refCount 0, destroy. // Lock to ensure Cancel() complete prior to other thread calling TearDown. - SqlClientEventSource.Log.NotificationsTrace(" Reached 0 count, cancelling and waiting."); + SqlClientEventSource.Log.NotificationTraceEvent(" Reached 0 count, cancelling and waiting."); lock (this) { @@ -957,7 +957,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) // TearDownAndDispose in the maximum retry period case as well as in the _errorState case. if (_errorState || retryStopwatch.Elapsed.Seconds >= 30) { - SqlClientEventSource.Log.NotificationsTraceEvent(" forcing cleanup. elapsedSeconds: '{0}', _errorState: '{1}'.", retryStopwatch.Elapsed.Seconds, _errorState); + SqlClientEventSource.Log.NotificationTraceEvent(" forcing cleanup. elapsedSeconds: '{0}', _errorState: '{1}'.", retryStopwatch.Elapsed.Seconds, _errorState); Timer retryTimer = _retryTimer; _retryTimer = null; if (retryTimer != null) @@ -976,7 +976,7 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) } else { - SqlClientEventSource.Log.NotificationsTraceEvent(" _startCount not 0 after decrement. _startCount: '{0}'.", _startCount); + SqlClientEventSource.Log.NotificationTraceEvent(" _startCount not 0 after decrement. _startCount: '{0}'.", _startCount); } Debug.Assert(0 <= _startCount, "Invalid start count state"); @@ -985,13 +985,13 @@ internal bool Stop(string appDomainKey, out bool appDomainStop) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private void SynchronouslyQueryServiceBrokerQueue() { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { @@ -1002,14 +1002,14 @@ private void SynchronouslyQueryServiceBrokerQueue() } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } [SuppressMessage("Microsoft.Security", "CA2100:ReviewSqlQueriesForSecurityVulnerabilities")] private void TearDownAndDispose() { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { @@ -1083,7 +1083,7 @@ private void TearDownAndDispose() } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } @@ -1227,42 +1227,42 @@ internal static SqlNotification ProcessMessage(SqlXml xmlMessage) catch (ArgumentException e) { ADP.TraceExceptionWithoutRethrow(e); // Discard failure, but trace. - SqlClientEventSource.Log.TraceEvent(" Exception thrown - Enum.Parse failed to parse the value '{0}' of the attribute '{1}'.", xmlReader.Value, xmlReader.LocalName); + SqlClientEventSource.Log.NotificationTraceEvent(" Exception thrown - Enum.Parse failed to parse the value '{0}' of the attribute '{1}'.", xmlReader.Value, xmlReader.LocalName); return null; } } if (MessageAttributes.All != messageAttributes) { - SqlClientEventSource.Log.TraceEvent(" Not all expected attributes in Message; messageAttributes = '{0}'.", (int)messageAttributes); + SqlClientEventSource.Log.NotificationTraceEvent(" Not all expected attributes in Message; messageAttributes = '{0}'.", (int)messageAttributes); return null; } // Proceed to the "Message" node. if (!xmlReader.Read()) { - SqlClientEventSource.Log.TraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); + SqlClientEventSource.Log.NotificationTraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); return null; } // Verify state after Read(). if ((XmlNodeType.Element != xmlReader.NodeType) || (0 != string.Compare(xmlReader.LocalName, MessageNode, StringComparison.OrdinalIgnoreCase))) { - SqlClientEventSource.Log.TraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); + SqlClientEventSource.Log.NotificationTraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); return null; } // Proceed to the Text Node. if (!xmlReader.Read()) { - SqlClientEventSource.Log.TraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); + SqlClientEventSource.Log.NotificationTraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); return null; } // Verify state after Read(). if (xmlReader.NodeType != XmlNodeType.Text) { - SqlClientEventSource.Log.TraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); + SqlClientEventSource.Log.NotificationTraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); return null; } @@ -1272,7 +1272,7 @@ internal static SqlNotification ProcessMessage(SqlXml xmlMessage) // Proceed to the Text Node. if (!xmlMessageReader.Read()) { - SqlClientEventSource.Log.TraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); + SqlClientEventSource.Log.NotificationTraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); return null; } @@ -1283,7 +1283,7 @@ internal static SqlNotification ProcessMessage(SqlXml xmlMessage) } else { - SqlClientEventSource.Log.TraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); + SqlClientEventSource.Log.NotificationTraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); return null; } } @@ -1292,7 +1292,7 @@ internal static SqlNotification ProcessMessage(SqlXml xmlMessage) } else { - SqlClientEventSource.Log.TraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); + SqlClientEventSource.Log.NotificationTraceEvent(" unexpected Read failure on xml or unexpected structure of xml."); return null; // failure } } @@ -1472,19 +1472,19 @@ internal int ObjectID private SqlDependencyProcessDispatcher(object dummyVariable) { Debug.Assert(null == _staticInstance, "Real constructor called with static instance already created!"); - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { #if DEBUG // Possibly expensive, limit to debug. - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, AppDomain.CurrentDomain.FriendlyName: {1}", ObjectID, AppDomain.CurrentDomain.FriendlyName); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, AppDomain.CurrentDomain.FriendlyName: {1}", ObjectID, AppDomain.CurrentDomain.FriendlyName); #endif _connectionContainers = new Dictionary(); _sqlDependencyPerAppDomainDispatchers = new Dictionary(); } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1492,18 +1492,18 @@ private SqlDependencyProcessDispatcher(object dummyVariable) // Required to be public, even on internal class, for Remoting infrastructure. public SqlDependencyProcessDispatcher() { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { // Empty constructor and object - dummy to obtain singleton. #if DEBUG // Possibly expensive, limit to debug. - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, AppDomain.CurrentDomain.FriendlyName: {1}", ObjectID, AppDomain.CurrentDomain.FriendlyName); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, AppDomain.CurrentDomain.FriendlyName: {1}", ObjectID, AppDomain.CurrentDomain.FriendlyName); #endif } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1529,7 +1529,7 @@ internal SqlDependencyProcessDispatcher SingletonProcessDispatcher out string user, string queue) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, queue: {1}", _staticInstance.ObjectID, queue); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, queue: {1}", _staticInstance.ObjectID, queue); try { // Force certain connection string properties to be used by SqlDependencyProcessDispatcher. @@ -1562,7 +1562,7 @@ internal SqlDependencyProcessDispatcher SingletonProcessDispatcher } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1574,7 +1574,7 @@ public override object InitializeLifetimeService() private void Invalidate(string server, SqlNotification sqlNotification) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, server: {1}", ObjectID, server); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, server: {1}", ObjectID, server); try { Debug.Assert(this == _staticInstance, "Instance method called on non _staticInstance instance!"); @@ -1606,7 +1606,7 @@ private void Invalidate(string server, SqlNotification sqlNotification) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1623,7 +1623,7 @@ internal void QueueAppDomainUnloading(string appDomainKey) // This method is only called by queued work-items from the method above. private void AppDomainUnloading(object state) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { string appDomainKey = (string)state; @@ -1655,7 +1655,7 @@ private void AppDomainUnloading(object state) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1722,7 +1722,7 @@ private void AppDomainUnloading(object state) out bool appDomainStart, bool useDefaults) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, queue: '{1}', appDomainKey: '{2}', perAppDomainDispatcher ID: '{3}'", ObjectID, queueService, appDomainKey, dispatcher.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, queue: '{1}', appDomainKey: '{2}', perAppDomainDispatcher ID: '{3}'", ObjectID, queueService, appDomainKey, dispatcher.ObjectID); try { Debug.Assert(this == _staticInstance, "Instance method called on non _staticInstance instance!"); @@ -1749,7 +1749,7 @@ private void AppDomainUnloading(object state) queueService); #if DEBUG SqlConnectionString connectionStringOptions = new SqlConnectionString(connectionStringBuilder.ConnectionString); - SqlClientEventSource.Log.NotificationsTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); + SqlClientEventSource.Log.NotificationTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); #endif bool started = false; @@ -1759,7 +1759,7 @@ private void AppDomainUnloading(object state) { if (!_connectionContainers.ContainsKey(hashHelper)) { - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, hashtable miss, creating new container.", ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, hashtable miss, creating new container.", ObjectID); container = new SqlConnectionContainer(hashHelper, appDomainKey, useDefaults); _connectionContainers.Add(hashHelper, container); started = true; @@ -1768,10 +1768,10 @@ private void AppDomainUnloading(object state) else { container = _connectionContainers[hashHelper]; - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, hashtable hit, container: {1}", ObjectID, container.ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, hashtable hit, container: {1}", ObjectID, container.ObjectID); if (container.InErrorState) { - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, container: {1} is in error state!", ObjectID, container.ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, container: {1} is in error state!", ObjectID, container.ObjectID); errorOccurred = true; // Set outparam errorOccurred true so we invalidate on Start(). } else @@ -1786,15 +1786,15 @@ private void AppDomainUnloading(object state) server = container.Server; database = container.Database; queueService = container.Queue; - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, default service: '{1}', server: '{2}', database: '{3}'", ObjectID, queueService, server, database); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, default service: '{1}', server: '{2}', database: '{3}'", ObjectID, queueService, server, database); } - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, started: {1}", ObjectID, started); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, started: {1}", ObjectID, started); return started; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -1811,7 +1811,7 @@ private void AppDomainUnloading(object state) string appDomainKey, out bool appDomainStop) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, queue: '{1}'", ObjectID, queueService); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, queue: '{1}'", ObjectID, queueService); try { Debug.Assert(this == _staticInstance, "Instance method called on non _staticInstance instance!"); @@ -1829,7 +1829,7 @@ private void AppDomainUnloading(object state) queueService); #if DEBUG SqlConnectionString connectionStringOptions = new SqlConnectionString(connectionStringBuilder.ConnectionString); - SqlClientEventSource.Log.NotificationsTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); + SqlClientEventSource.Log.NotificationTraceEvent(" Modified connection string: '{0}'", connectionStringOptions.UsersConnectionStringForTrace()); #endif bool stopped = false; @@ -1839,7 +1839,7 @@ private void AppDomainUnloading(object state) if (_connectionContainers.ContainsKey(hashHelper)) { SqlConnectionContainer container = _connectionContainers[hashHelper]; - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, hashtable hit, container: {1}", ObjectID, container.ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, hashtable hit, container: {1}", ObjectID, container.ObjectID); server = container.Server; // Return server, database, and queue info for use by calling SqlDependency. database = container.Database; @@ -1852,16 +1852,16 @@ private void AppDomainUnloading(object state) } else { - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, hashtable miss.", ObjectID); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, hashtable miss.", ObjectID); } } - SqlClientEventSource.Log.NotificationsTraceEvent(" {0}#, stopped: {1}", ObjectID, stopped); + SqlClientEventSource.Log.NotificationTraceEvent(" {0}, stopped: {1}", ObjectID, stopped); return stopped; } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } 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 index 2febbeed39..3de7a11191 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlDependencyUtils.cs @@ -92,7 +92,7 @@ internal int ObjectID private SqlDependencyPerAppDomainDispatcher() { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { _dependencyIdToDependencyHash = new Dictionary(); @@ -106,7 +106,7 @@ private SqlDependencyPerAppDomainDispatcher() } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -124,7 +124,7 @@ public override object InitializeLifetimeService() private void UnloadEventHandler(object sender, EventArgs e) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}", ObjectID); try { // Make non-blocking call to ProcessDispatcher to ThreadPool.QueueUserWorkItem to complete @@ -139,7 +139,7 @@ private void UnloadEventHandler(object sender, EventArgs e) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -150,7 +150,7 @@ private void UnloadEventHandler(object sender, EventArgs e) // This method is called upon SqlDependency constructor. internal void AddDependencyEntry(SqlDependency dep) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlDependency: {1}#", ObjectID, dep.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlDependency: {1}", ObjectID, dep.ObjectID); try { lock (this) @@ -160,7 +160,7 @@ internal void AddDependencyEntry(SqlDependency dep) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -168,7 +168,7 @@ internal void AddDependencyEntry(SqlDependency dep) internal string AddCommandEntry(string commandHash, SqlDependency dep) { string notificationId = string.Empty; - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, commandHash: '{1}', SqlDependency: {2}#", ObjectID, commandHash, dep.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, commandHash: '{1}', SqlDependency: {2}", ObjectID, commandHash, dep.ObjectID); try { lock (this) @@ -176,7 +176,7 @@ internal string AddCommandEntry(string commandHash, SqlDependency dep) if (!_dependencyIdToDependencyHash.ContainsKey(dep.Id)) { // Determine if depId->dep hashtable contains dependency. If not, it's been invalidated. - SqlClientEventSource.Log.NotificationsTrace(" Dependency not present in depId->dep hash, must have been invalidated."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency not present in depId->dep hash, must have been invalidated."); } else { @@ -197,12 +197,12 @@ internal string AddCommandEntry(string commandHash, SqlDependency dep) // join the new dependency to the list if (!dependencyList.Contains(dep)) { - SqlClientEventSource.Log.NotificationsTrace(" Dependency not present for commandHash, adding."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency not present for commandHash, adding."); dependencyList.Add(dep); } else { - SqlClientEventSource.Log.NotificationsTrace(" Dependency already present for commandHash."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency already present for commandHash."); } } else @@ -216,7 +216,7 @@ internal string AddCommandEntry(string commandHash, SqlDependency dep) SqlDependency.AppDomainKey, // must be first Guid.NewGuid().ToString("D", System.Globalization.CultureInfo.InvariantCulture) ); - SqlClientEventSource.Log.NotificationsTrace(" Creating new Dependencies list for commandHash."); + SqlClientEventSource.Log.NotificationTraceEvent(" Creating new Dependencies list for commandHash."); DependencyList dependencyList = new DependencyList(commandHash); dependencyList.Add(dep); @@ -238,7 +238,7 @@ internal string AddCommandEntry(string commandHash, SqlDependency dep) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } return notificationId; @@ -247,7 +247,7 @@ internal string AddCommandEntry(string commandHash, SqlDependency dep) // This method is called by the ProcessDispatcher upon a notification for this AppDomain. internal void InvalidateCommandID(SqlNotification sqlNotification) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, commandHash: '{1}'", ObjectID, sqlNotification.Key); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, commandHash: '{1}'", ObjectID, sqlNotification.Key); try { List dependencyList = null; @@ -258,7 +258,7 @@ internal void InvalidateCommandID(SqlNotification sqlNotification) if (null != dependencyList) { - SqlClientEventSource.Log.NotificationsTrace(" commandHash found in hashtable."); + SqlClientEventSource.Log.NotificationTraceEvent(" commandHash found in hashtable."); foreach (SqlDependency dependency in dependencyList) { // Ensure we remove from process static app domain hash for dependency initiated invalidates. @@ -270,7 +270,7 @@ internal void InvalidateCommandID(SqlNotification sqlNotification) } else { - SqlClientEventSource.Log.NotificationsTrace(" commandHash NOT found in hashtable."); + SqlClientEventSource.Log.NotificationTraceEvent(" commandHash NOT found in hashtable."); } } @@ -279,7 +279,7 @@ internal void InvalidateCommandID(SqlNotification sqlNotification) // After removal from hashtables, invalidate. foreach (SqlDependency dependency in dependencyList) { - SqlClientEventSource.Log.NotificationsTrace(" Dependency found in commandHash dependency ArrayList - calling invalidate."); + SqlClientEventSource.Log.NotificationTraceEvent(" Dependency found in commandHash dependency ArrayList - calling invalidate."); try { dependency.Invalidate(sqlNotification.Type, sqlNotification.Info, sqlNotification.Source); @@ -300,14 +300,14 @@ internal void InvalidateCommandID(SqlNotification sqlNotification) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(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.NotificationsScopeEnterEvent(" {0}#, server: '{1}'", ObjectID, server); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, server: '{1}'", ObjectID, server); try { List dependencies = new List(); @@ -354,14 +354,14 @@ internal void InvalidateServer(string server, SqlNotification sqlNotification) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(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.NotificationsScopeEnterEvent(" {0}#, Key: '{1}'", ObjectID, id); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, Key: '{1}'", ObjectID, id); try { if (null == id) @@ -383,7 +383,7 @@ internal SqlDependency LookupDependencyEntry(string id) } else { - SqlClientEventSource.Log.NotificationsTrace(" ERROR - dependency ID mismatch - not throwing."); + SqlClientEventSource.Log.NotificationTraceEvent(" ERROR - dependency ID mismatch - not throwing."); } } @@ -391,21 +391,21 @@ internal SqlDependency LookupDependencyEntry(string id) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // Remove the dependency from the hashtable with the passed id. private void LookupDependencyEntryWithRemove(string id) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, id: '{1}'", ObjectID, id); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, id: '{1}'", ObjectID, id); try { lock (this) { if (_dependencyIdToDependencyHash.ContainsKey(id)) { - SqlClientEventSource.Log.NotificationsTrace(" Entry found in hashtable - removing."); + SqlClientEventSource.Log.NotificationTraceEvent(" Entry found in hashtable - removing."); _dependencyIdToDependencyHash.Remove(id); // if there are no more dependencies then we can dispose the timer. @@ -417,20 +417,20 @@ private void LookupDependencyEntryWithRemove(string id) } else { - SqlClientEventSource.Log.NotificationsTrace(" Entry NOT found in hashtable."); + SqlClientEventSource.Log.NotificationTraceEvent(" Entry NOT found in hashtable."); } } } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // Find and return arraylist, and remove passed hash value. private List LookupCommandEntryWithRemove(string notificationId) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, commandHash: '{1}'", ObjectID, notificationId); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, commandHash: '{1}'", ObjectID, notificationId); try { DependencyList entry = null; @@ -439,7 +439,7 @@ private List LookupCommandEntryWithRemove(string notificationId) { if (_notificationIdToDependenciesHash.TryGetValue(notificationId, out entry)) { - SqlClientEventSource.Log.NotificationsTrace(" Entries found in hashtable - removing."); + SqlClientEventSource.Log.NotificationTraceEvent(" Entries found in hashtable - removing."); // update the tables - do it inside finally block to avoid ThreadAbort exception interrupt this operation try @@ -453,7 +453,7 @@ private List LookupCommandEntryWithRemove(string notificationId) } else { - SqlClientEventSource.Log.NotificationsTrace(" Entries NOT found in hashtable."); + SqlClientEventSource.Log.NotificationTraceEvent(" Entries NOT found in hashtable."); } Debug.Assert(_notificationIdToDependenciesHash.Count == _commandHashToNotificationId.Count, "always keep these maps in sync!"); @@ -463,14 +463,14 @@ private List LookupCommandEntryWithRemove(string notificationId) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } // Remove from commandToDependenciesHash all references to the passed dependency. private void RemoveDependencyFromCommandToDependenciesHash(SqlDependency dependency) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlDependency: {1}#", ObjectID, dependency.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlDependency: {1}", ObjectID, dependency.ObjectID); try { lock (this) @@ -483,7 +483,7 @@ private void RemoveDependencyFromCommandToDependenciesHash(SqlDependency depende DependencyList dependencies = entry.Value; if (dependencies.Remove(dependency)) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Removed SqlDependency: {0}#, with ID: '{1}'.", dependency.ObjectID, dependency.Id); + SqlClientEventSource.Log.NotificationTraceEvent(" 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 @@ -516,7 +516,7 @@ private void RemoveDependencyFromCommandToDependenciesHash(SqlDependency depende } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } @@ -526,7 +526,7 @@ private void RemoveDependencyFromCommandToDependenciesHash(SqlDependency depende internal void StartTimer(SqlDependency dep) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" {0}#, SqlDependency: {1}#", ObjectID, dep.ObjectID); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" {0}, SqlDependency: {1}", ObjectID, dep.ObjectID); try { // If this dependency expires sooner than the current next timeout, change @@ -537,7 +537,7 @@ internal void StartTimer(SqlDependency dep) // Enable the timer if needed (disable when empty, enable on the first addition). if (!_SqlDependencyTimeOutTimerStarted) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Timer not yet started, starting."); + SqlClientEventSource.Log.NotificationTraceEvent(" Timer not yet started, starting."); _timeoutTimer.Change(15000 /* 15 secs */, 15000 /* 15 secs */); // Save this as the earlier timeout to come. @@ -546,7 +546,7 @@ internal void StartTimer(SqlDependency dep) } else if (_nextTimeout > dep.ExpirationTime) { - SqlClientEventSource.Log.NotificationsTraceEvent(" Timer already started, resetting time."); + SqlClientEventSource.Log.NotificationTraceEvent(" Timer already started, resetting time."); // Save this as the earlier timeout to come. _nextTimeout = dep.ExpirationTime; @@ -555,13 +555,13 @@ internal void StartTimer(SqlDependency dep) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } private static void TimeoutTimerCallback(object state) { - long scopeID = SqlClientEventSource.Log.NotificationsScopeEnterEvent(" AppDomainKey: '{0}'", SqlDependency.AppDomainKey); + long scopeID = SqlClientEventSource.Log.NotificationScopeEnterEvent(" AppDomainKey: '{0}'", SqlDependency.AppDomainKey); try { SqlDependency[] dependencies; @@ -574,12 +574,12 @@ private static void TimeoutTimerCallback(object state) if (0 == SingletonInstance._dependencyIdToDependencyHash.Count) { // Nothing to check. - SqlClientEventSource.Log.NotificationsTrace(" No dependencies, exiting."); + SqlClientEventSource.Log.NotificationTraceEvent(" No dependencies, exiting."); return; } if (SingletonInstance._nextTimeout > DateTime.UtcNow) { - SqlClientEventSource.Log.NotificationsTrace(" No timeouts expired, exiting."); + SqlClientEventSource.Log.NotificationTraceEvent(" No timeouts expired, exiting."); // No dependency timed-out yet. return; @@ -650,7 +650,7 @@ private static void TimeoutTimerCallback(object state) } finally { - SqlClientEventSource.Log.NotificationsScopeLeaveEvent(scopeID); + SqlClientEventSource.Log.NotificationScopeLeaveEvent(scopeID); } } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs index d7079a0dcb..b39a0963e2 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnection.cs @@ -313,7 +313,7 @@ override protected DbReferenceCollection CreateReferenceCollection() override protected void Deactivate() { - SqlClientEventSource.Log.AdvanceTrace(" {0}# deactivating", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} deactivating", ObjectID); TdsParser bestEffortCleanupTarget = null; RuntimeHelpers.PrepareConstrainedRegions(); try @@ -435,12 +435,12 @@ protected void Enlist(SysTx.Transaction tx) private void EnlistNonNull(SysTx.Transaction tx) { Debug.Assert(null != tx, "null transaction?"); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, transaction {1}#.", ObjectID, tx.GetHashCode()); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, transaction {1}.", ObjectID, tx.GetHashCode()); bool hasDelegatedTransaction = false; if (IsYukonOrNewer) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, attempting to delegate", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, attempting to delegate", ObjectID); // Promotable transactions are only supported on Yukon // servers or newer. @@ -507,7 +507,7 @@ private void EnlistNonNull(SysTx.Transaction tx) if (hasDelegatedTransaction) { this.DelegatedTransaction = delegatedTransaction; - SqlClientEventSource.Log.AdvanceTrace(" {0}#, delegated to transaction {1}# with transactionId=0x{2}", ObjectID, null != CurrentTransaction ? CurrentTransaction.ObjectID : 0, null != CurrentTransaction ? CurrentTransaction.TransactionId : SqlInternalTransaction.NullTransactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, delegated to transaction {1} with transactionId=0x{2}", ObjectID, null != CurrentTransaction ? CurrentTransaction.ObjectID : 0, null != CurrentTransaction ? CurrentTransaction.TransactionId : SqlInternalTransaction.NullTransactionId); } } catch (SqlException e) @@ -540,7 +540,7 @@ private void EnlistNonNull(SysTx.Transaction tx) if (!hasDelegatedTransaction) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, delegation not possible, enlisting.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, delegation not possible, enlisting.", ObjectID); byte[] cookie = null; if (_isGlobalTransaction) @@ -570,7 +570,7 @@ private void EnlistNonNull(SysTx.Transaction tx) // send cookie to server to finish enlistment PropagateTransactionCookie(cookie); _isEnlistedInTransaction = true; - SqlClientEventSource.Log.AdvanceTrace(" {0}#, enlisted with transaction {1}# with transactionId=0x{2}", ObjectID, null != CurrentTransaction ? CurrentTransaction.ObjectID : 0, null != CurrentTransaction ? CurrentTransaction.TransactionId : SqlInternalTransaction.NullTransactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, enlisted with transaction {1} with transactionId=0x{2}", ObjectID, null != CurrentTransaction ? CurrentTransaction.ObjectID : 0, null != CurrentTransaction ? CurrentTransaction.TransactionId : SqlInternalTransaction.NullTransactionId); } EnlistedTransaction = tx; // Tell the base class about our enlistment @@ -593,7 +593,7 @@ private void EnlistNonNull(SysTx.Transaction tx) internal void EnlistNull() { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, unenlisting.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, unenlisting.", ObjectID); // We were in a transaction, but now we are not - so send // message to server with empty transaction - confirmed proper @@ -611,7 +611,7 @@ internal void EnlistNull() _isEnlistedInTransaction = false; EnlistedTransaction = null; // Tell the base class about our enlistment - SqlClientEventSource.Log.AdvanceTrace(" {0}#, unenlisted.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, unenlisted.", ObjectID); // The EnlistTransaction above will return an TransactionEnded event, // which causes the TdsParser or SmiEventSink should to clear the diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs index 8252977f10..5150a54dc8 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionSmi.cs @@ -65,37 +65,37 @@ internal EventSink(SqlInternalConnectionSmi connection) internal override void DefaultDatabaseChanged(string databaseName) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, databaseName='{1}'.", _connection.ObjectID, databaseName); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, databaseName='{1}'.", _connection.ObjectID, databaseName); _connection.CurrentDatabase = databaseName; } internal override void TransactionCommitted(long transactionId) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, transactionId=0x{1}.", _connection.ObjectID, transactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId); _connection.TransactionEnded(transactionId, TransactionState.Committed); } internal override void TransactionDefected(long transactionId) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, transactionId=0x{1}.", _connection.ObjectID, transactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId); _connection.TransactionEnded(transactionId, TransactionState.Unknown); } internal override void TransactionEnlisted(long transactionId) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, transactionId=0x{1}.", _connection.ObjectID, transactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId); _connection.TransactionStarted(transactionId, true); // distributed; } internal override void TransactionEnded(long transactionId) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, transactionId=0x{1}.", _connection.ObjectID, transactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId); _connection.TransactionEndedByServer(transactionId, TransactionState.Unknown); } internal override void TransactionRolledBack(long transactionId) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, transactionId=0x{1}.", _connection.ObjectID, transactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId); // Dev11 1066: ensure delegated transaction is rolled back _connection.TransactionEndedByServer(transactionId, TransactionState.Aborted); @@ -103,7 +103,7 @@ internal override void TransactionRolledBack(long transactionId) internal override void TransactionStarted(long transactionId) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, transactionId=0x{1}.", _connection.ObjectID, transactionId); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, transactionId=0x{1}.", _connection.ObjectID, transactionId); _connection.TransactionStarted(transactionId, false); // not distributed; } } @@ -119,7 +119,7 @@ internal SqlInternalConnectionSmi(SqlConnectionString connectionOptions, SmiCont Debug.Assert(null != _smiConnection, "null SmiContext.ContextConnection?"); _smiEventSink = new EventSink(this); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, constructed new SMI internal connection", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, constructed new SMI internal connection", ObjectID); } internal SmiContext InternalContext @@ -269,7 +269,7 @@ internal void AutomaticEnlistment() SysTx.Transaction currentSystemTransaction = ADP.GetCurrentTransaction(); // NOTE: Must be first to ensure _smiContext.ContextTransaction is set! SysTx.Transaction contextTransaction = _smiContext.ContextTransaction; // returns the transaction that was handed to SysTx that wraps the ContextTransactionId. long contextTransactionId = _smiContext.ContextTransactionId; - SqlClientEventSource.Log.AdvanceTrace(" {0}#, contextTransactionId=0x{1}, contextTransaction={2}#, currentSystemTransaction={3}#.", ObjectID, contextTransactionId, (null != contextTransaction) ? contextTransaction.GetHashCode() : 0, (null != currentSystemTransaction) ? currentSystemTransaction.GetHashCode() : 0); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, contextTransactionId=0x{1}, contextTransaction={2}, currentSystemTransaction={3}.", ObjectID, contextTransactionId, (null != contextTransaction) ? contextTransaction.GetHashCode() : 0, (null != currentSystemTransaction) ? currentSystemTransaction.GetHashCode() : 0); if (SqlInternalTransaction.NullTransactionId != contextTransactionId) { @@ -278,18 +278,18 @@ internal void AutomaticEnlistment() throw SQL.NestedTransactionScopesNotSupported(); // can't use TransactionScope(RequiresNew) inside a Sql Transaction. } - SqlClientEventSource.Log.TraceEvent(" {0}#, using context transaction with transactionId=0x{1}", ObjectID, contextTransactionId); + SqlClientEventSource.Log.TraceEvent(" {0}, using context transaction with transactionId=0x{1}", ObjectID, contextTransactionId); _currentTransaction = new SqlInternalTransaction(this, TransactionType.Context, null, contextTransactionId); ContextTransaction = contextTransaction; } else if (null == currentSystemTransaction) { _currentTransaction = null; // there really isn't a transaction. - SqlClientEventSource.Log.AdvanceTrace(" {0}#, no transaction.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, no transaction.", ObjectID); } else { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, using current System.Transaction.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, using current System.Transaction.", ObjectID); base.Enlist(currentSystemTransaction); } } @@ -302,7 +302,7 @@ override protected void ChangeDatabaseInternal(string database) override protected void InternalDeactivate() { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Deactivating.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Deactivating.", ObjectID); // When we put this to bed, we should not hold on to the transaction // or any activity (commit/rollback) may cause it to stop responding. @@ -331,13 +331,13 @@ override protected void InternalDeactivate() override internal void DelegatedTransactionEnded() { base.DelegatedTransactionEnded(); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, cleaning up after Delegated Transaction Completion", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, cleaning up after Delegated Transaction Completion", ObjectID); _currentTransaction = null; // clean up our current transaction too } override internal void DisconnectTransaction(SqlInternalTransaction internalTransaction) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Disconnecting Transaction {1}#.", ObjectID, internalTransaction.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Disconnecting Transaction {1}.", ObjectID, internalTransaction.ObjectID); // VSTS 215465/15029: allow _currentTransaction to be null - it can be cleared before by server's callback Debug.Assert(_currentTransaction == null || _currentTransaction == internalTransaction, "disconnecting different transaction"); @@ -361,7 +361,7 @@ override public void Dispose() SqlInternalTransaction internalTransaction, bool isDelegateControlRequest) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, transactionRequest={1}, " + + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, transactionRequest={1}, " + "transactionName='{2}', isolationLevel={3}, internalTransaction=#{4} transactionId=0x{5}.", ObjectID, transactionRequest.ToString(), transactionName ?? "null", iso.ToString(), (null != internalTransaction) ? internalTransaction.ObjectID : 0, (null != internalTransaction) ? internalTransaction.TransactionId : SqlInternalTransaction.NullTransactionId); switch (transactionRequest) @@ -419,11 +419,11 @@ override protected byte[] GetDTCAddress() if (null != whereAbouts) { - SqlClientEventSource.Log.AdvanceTrace(" whereAbouts = {0}, Length = {1}", whereAbouts, (ushort)whereAbouts.Length); + SqlClientEventSource.Log.AdvancedTraceEvent(" whereAbouts = {0}, Length = {1}", whereAbouts, (ushort)whereAbouts.Length); } else { - SqlClientEventSource.Log.AdvanceTrace(" whereAbouts=null"); + SqlClientEventSource.Log.AdvancedTraceEvent(" whereAbouts=null"); } return whereAbouts; @@ -449,7 +449,7 @@ private void OnOutOfScope(object s, EventArgs e) // Called whenever the context goes out of scope, we need to make // sure that we close the connection, or the next person that uses // the context may appear to have the connection in use. - SqlClientEventSource.Log.AdvanceTrace(" {0}# context is out of scope", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} context is out of scope", ObjectID); // TODO: This is suspect to me -- if I go out of scope, who will commit the transaction? DelegatedTransaction = null; // we don't want to hold this over to the next usage; it will automatically be reused as the context transaction... @@ -480,11 +480,11 @@ override protected void PropagateTransactionCookie(byte[] transactionCookie) if (null != transactionCookie) { - SqlClientEventSource.Log.AdvanceTrace(" transactionCookie", transactionCookie, (UInt16)transactionCookie.Length); + SqlClientEventSource.Log.AdvancedTraceEvent(" transactionCookie", transactionCookie, (UInt16)transactionCookie.Length); } else { - SqlClientEventSource.Log.AdvanceTrace(" null"); + SqlClientEventSource.Log.AdvancedTraceEvent(" null"); } // Propagate the transaction cookie to the server 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 f0039d046a..61af55918e 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 @@ -516,7 +516,7 @@ static SqlInternalConnectionTds() ThreadHasParserLockForClose = false; _parserLock.Release(); } - SqlClientEventSource.Log.AdvanceTrace(" {0}#, constructed new TDS internal connection", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, constructed new TDS internal connection", ObjectID); } // The erros in the transient error set are contained in @@ -771,7 +771,7 @@ override protected void ChangeDatabaseInternal(string database) override public void Dispose() { - SqlClientEventSource.Log.AdvanceTrace(" {0}# disposing", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} disposing", ObjectID); try { TdsParser parser = Interlocked.Exchange(ref _parser, null); // guard against multiple concurrent dispose calls -- Delegated Transactions might cause this. @@ -1363,12 +1363,12 @@ private void CompleteLogin(bool enlistOK) // ROR should not affect state of connection recovery if (_federatedAuthenticationRequested && !_federatedAuthenticationAcknowledged) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Server did not acknowledge the federated authentication request", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Server did not acknowledge the federated authentication request", ObjectID); throw SQL.ParsingError(ParsingErrorState.FedAuthNotAcknowledged); } if (_federatedAuthenticationInfoRequested && !_federatedAuthenticationInfoReceived) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Server never sent the requested federated authentication info", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Server never sent the requested federated authentication info", ObjectID); throw SQL.ParsingError(ParsingErrorState.FedAuthInfoNotReceived); } @@ -1406,7 +1406,7 @@ private void CompleteLogin(bool enlistOK) _parser.EnableMars(); _fConnectionOpen = true; // mark connection as open - SqlClientEventSource.Log.AdvanceTrace(" Post-Login Phase: Server connection obtained."); + SqlClientEventSource.Log.AdvancedTraceEvent(" Post-Login Phase: Server connection obtained."); // for non-pooled connections, enlist in a distributed transaction // if present - and user specified to enlist @@ -1535,7 +1535,7 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword, private void LoginFailure() { - SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}", ObjectID); // If the parser was allocated and we failed, then we must have failed on // either the Connect or Login, either way we should call Disconnect. @@ -1661,7 +1661,7 @@ private bool IsDoNotRetryConnectError(SqlException exc) int routingAttempts = 0; ServerInfo originalServerInfo = serverInfo; // serverInfo may end up pointing to new object due to routing, original object is used to set CurrentDatasource - SqlClientEventSource.Log.AdvanceTrace(" {0}#, host={1}", ObjectID, serverInfo.UserServerName); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, host={1}", ObjectID, serverInfo.UserServerName); int sleepInterval = 100; //milliseconds to sleep (back off) between attempts. @@ -1856,7 +1856,7 @@ private bool IsDoNotRetryConnectError(SqlException exc) // Sleep for a bit to prevent clogging the network with requests, // then update sleep interval for next iteration (max 1 second interval) - SqlClientEventSource.Log.AdvanceTrace(" {0}#, sleeping {1}[milisec]", ObjectID, sleepInterval); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, sleeping {1}[milisec]", ObjectID, sleepInterval); Thread.Sleep(sleepInterval); sleepInterval = (sleepInterval < 500) ? sleepInterval * 2 : 1000; @@ -1938,7 +1938,7 @@ TimeoutTimer timeout { Debug.Assert(!connectionOptions.MultiSubnetFailover, "MultiSubnetFailover should not be set if failover partner is used"); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, useFailover={1}[bool], primary={2}, failover={3}", ObjectID, useFailoverHost, primaryServerInfo.UserServerName, failoverHost ?? "null"); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, useFailover={1}[bool], primary={2}, failover={3}", ObjectID, useFailoverHost, primaryServerInfo.UserServerName, failoverHost ?? "null"); int sleepInterval = 100; //milliseconds to sleep (back off) between attempts. long timeoutUnitInterval; @@ -2006,7 +2006,7 @@ TimeoutTimer timeout // Primary server may give us a different failover partner than the connection string indicates. Update it if (null != ServerProvidedFailOverPartner && failoverServerInfo.ResolvedServerName != ServerProvidedFailOverPartner) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, new failover partner={1}", ObjectID, ServerProvidedFailOverPartner); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, new failover partner={1}", ObjectID, ServerProvidedFailOverPartner); failoverServerInfo.SetDerivedNames(protocol, ServerProvidedFailOverPartner); } currentServerInfo = failoverServerInfo; @@ -2108,7 +2108,7 @@ TimeoutTimer timeout // the network with requests, then update sleep interval for next iteration (max 1 second interval) if (1 == attemptNumber % 2) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, sleeping {1}[milisec]", ObjectID, sleepInterval); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, sleeping {1}[milisec]", ObjectID, sleepInterval); Thread.Sleep(sleepInterval); sleepInterval = (sleepInterval < 500) ? sleepInterval * 2 : 1000; } @@ -2183,7 +2183,7 @@ private void ResolveExtendedServerName(ServerInfo serverInfo, bool aliasLookup, // Common code path for making one attempt to establish a connection and log in to server. private void AttemptOneLogin(ServerInfo serverInfo, string newPassword, SecureString newSecurePassword, bool ignoreSniOpenTimeout, TimeoutTimer timeout, bool withFailover = false, bool isFirstTransparentAttempt = true, bool disableTnir = false) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, timout={1}[msec], server={2}", ObjectID, timeout.MillisecondsRemaining, serverInfo.ExtendedServerName); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, timout={1}[msec], server={2}", ObjectID, timeout.MillisecondsRemaining, serverInfo.ExtendedServerName); _routingInfo = null; // forget routing information @@ -2335,7 +2335,7 @@ internal bool GetSessionAndReconnectIfNeeded(SqlConnection parent, int timeout = internal void BreakConnection() { SqlConnection connection = Connection; - SqlClientEventSource.Log.TraceEvent(" {0}#, Breaking connection.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Breaking connection.", ObjectID); DoomThisConnection(); // Mark connection as unusable, so it will be destroyed if (null != connection) @@ -2427,7 +2427,7 @@ internal void OnEnvChange(SqlEnvChange rec) break; case TdsEnums.ENV_ROUTING: - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received routing info", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received routing info", ObjectID); if (string.IsNullOrEmpty(rec.newRoutingInfo.ServerName) || rec.newRoutingInfo.Protocol != 0 || rec.newRoutingInfo.Port == 0) { throw SQL.ROR_InvalidRoutingInfo(this); @@ -2471,7 +2471,7 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo) "Credentials aren't provided for calling MSAL"); Debug.Assert(fedAuthInfo != null, "info should not be null."); Debug.Assert(_dbConnectionPoolAuthenticationContextKey == null, "_dbConnectionPoolAuthenticationContextKey should be null."); - SqlClientEventSource.Log.TraceEvent(" {0}#, Generating federated authentication token", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Generating federated authentication token", ObjectID); DbConnectionPoolAuthenticationContext dbConnectionPoolAuthenticationContext = null; // We want to refresh the token without taking a lock on the context, allowed when the access token is expiring within the next 10 mins. @@ -2502,7 +2502,7 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo) // And on successful login, try to update the cache with the new token. if (contextValidity <= _dbAuthenticationContextUnLockedRefreshTimeSpan) { - SqlClientEventSource.Log.TraceEvent(" {0}#, " + + SqlClientEventSource.Log.TraceEvent(" {0}, " + "The expiration time is less than 10 mins, so trying to get new access token regardless of if an other thread is also trying to update it." + "The expiration time is {1}. Current Time is {2}.", ObjectID, dbConnectionPoolAuthenticationContext.ExpirationTime.ToLongTimeString(), DateTime.UtcNow.ToLongTimeString()); @@ -2525,7 +2525,7 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo) // If a thread is already doing the refresh, just use the existing token in the cache and proceed. else if (contextValidity <= _dbAuthenticationContextLockedRefreshTimeSpan) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, " + + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, " + "The authentication context needs a refresh.The expiration time is {1}. " + "Current Time is {2}.", ObjectID, dbConnectionPoolAuthenticationContext.ExpirationTime.ToLongTimeString(), DateTime.UtcNow.ToLongTimeString()); @@ -2541,10 +2541,10 @@ internal void OnFedAuthInfo(SqlFedAuthInfo fedAuthInfo) // Indicate in Bid Trace that we are successful with the update. if (attemptRefreshTokenLocked) { - SqlClientEventSource.Log.TraceEvent(" {0}#, The attempt to get a new access token succeeded under the locked mode.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, The attempt to get a new access token succeeded under the locked mode.", ObjectID); } } - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Found an authentication context in the cache that does not need a refresh at this time. Re-using the cached token.", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Found an authentication context in the cache that does not need a refresh at this time. Re-using the cached token.", ObjectID); } } @@ -2604,7 +2604,7 @@ internal bool TryGetFedAuthTokenLocked(SqlFedAuthInfo fedAuthInfo, DbConnectionP // Else some other thread is already updating it, so just proceed forward with the existing token in the cache. if (dbConnectionPoolAuthenticationContext.LockToUpdate()) { - SqlClientEventSource.Log.TraceEvent(" {0}#, " + + SqlClientEventSource.Log.TraceEvent(" {0}, " + "Acquired the lock to update the authentication context.The expiration time is {1}. " + "Current Time is {2}.", ObjectID, dbConnectionPoolAuthenticationContext.ExpirationTime.ToLongTimeString(), DateTime.UtcNow.ToLongTimeString()); @@ -2612,7 +2612,7 @@ internal bool TryGetFedAuthTokenLocked(SqlFedAuthInfo fedAuthInfo, DbConnectionP } else { - SqlClientEventSource.Log.TraceEvent(" {0}#, Refreshing the context is already in progress by another thread.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Refreshing the context is already in progress by another thread.", ObjectID); } if (authenticationContextLocked) @@ -2770,7 +2770,7 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo) || _timeout.IsExpired || _timeout.MillisecondsRemaining <= sleepInterval) { - SqlClientEventSource.Log.TraceEvent(" {0}#", msalException.ErrorCode); + SqlClientEventSource.Log.TraceEvent(" {0}", msalException.ErrorCode); // Error[0] SqlErrorCollection sqlErs = new SqlErrorCollection(); @@ -2789,8 +2789,8 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo) throw exc; } - SqlClientEventSource.Log.AdvanceTrace(" {0}#, sleeping {1}[Milliseconds]", ObjectID, sleepInterval); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, remaining {1}[Milliseconds]", ObjectID, _timeout.MillisecondsRemaining); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, sleeping {1}[Milliseconds]", ObjectID, sleepInterval); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, remaining {1}[Milliseconds]", ObjectID, _timeout.MillisecondsRemaining); Thread.Sleep(sleepInterval); sleepInterval *= 2; @@ -2806,7 +2806,7 @@ internal SqlFedAuthToken GetFedAuthToken(SqlFedAuthInfo fedAuthInfo) DateTime expirationTime = DateTime.FromFileTimeUtc(fedAuthToken.expirationFileTime); _newDbConnectionPoolAuthenticationContext = new DbConnectionPoolAuthenticationContext(fedAuthToken.accessToken, expirationTime); } - SqlClientEventSource.Log.TraceEvent(" {0}#, Finished generating federated authentication token.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Finished generating federated authentication token.", ObjectID); return fedAuthToken; } @@ -2869,11 +2869,11 @@ internal void OnFeatureExtAck(int featureId, byte[] data) } case TdsEnums.FEATUREEXT_FEDAUTH: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for federated authentication", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for federated authentication", ObjectID); if (!_federatedAuthenticationRequested) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Did not request federated authentication", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Did not request federated authentication", ObjectID); throw SQL.ParsingErrorFeatureId(ParsingErrorState.UnrequestedFeatureAckReceived, featureId); } @@ -2886,7 +2886,7 @@ internal void OnFeatureExtAck(int featureId, byte[] data) // The server shouldn't have sent any additional data with the ack (like a nonce) if (data.Length != 0) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Federated authentication feature extension ack for MSAL and Security Token includes extra data", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Federated authentication feature extension ack for MSAL and Security Token includes extra data", ObjectID); throw SQL.ParsingError(ParsingErrorState.FedAuthFeatureAckContainsExtraData); } break; @@ -2894,7 +2894,7 @@ internal void OnFeatureExtAck(int featureId, byte[] data) default: Debug.Fail("Unknown _fedAuthLibrary type"); - SqlClientEventSource.Log.TraceEvent(" {0}#, Attempting to use unknown federated authentication library", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Attempting to use unknown federated authentication library", ObjectID); throw SQL.ParsingErrorLibraryType(ParsingErrorState.FedAuthFeatureAckUnknownLibraryType, (int)_fedAuthFeatureExtensionData.Value.libraryType); } _federatedAuthenticationAcknowledged = true; @@ -2913,11 +2913,11 @@ internal void OnFeatureExtAck(int featureId, byte[] data) // For debug purposes, assert and trace if we ended up updating the cache with the new one or some other thread's context won the expiration race. if (newAuthenticationContextInCacheAfterAddOrUpdate == _newDbConnectionPoolAuthenticationContext) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Updated the new dbAuthenticationContext in the _dbConnectionPool.AuthenticationContexts.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Updated the new dbAuthenticationContext in the _dbConnectionPool.AuthenticationContexts.", ObjectID); } else { - SqlClientEventSource.Log.TraceEvent(" {0}#, AddOrUpdate attempted on _dbConnectionPool.AuthenticationContexts, but it did not update the new value.", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, AddOrUpdate attempted on _dbConnectionPool.AuthenticationContexts, but it did not update the new value.", ObjectID); } #endif } @@ -2926,17 +2926,17 @@ internal void OnFeatureExtAck(int featureId, byte[] data) } case TdsEnums.FEATUREEXT_TCE: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for TCE", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for TCE", ObjectID); if (data.Length < 1) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown version number for TCE", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown version number for TCE", ObjectID); throw SQL.ParsingError(ParsingErrorState.TceUnknownVersion); } byte supportedTceVersion = data[0]; if (0 == supportedTceVersion || supportedTceVersion > TdsEnums.MAX_SUPPORTED_TCE_VERSION) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Invalid version number for TCE", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Invalid version number for TCE", ObjectID); throw SQL.ParsingErrorValue(ParsingErrorState.TceInvalidVersion, supportedTceVersion); } @@ -2955,11 +2955,11 @@ internal void OnFeatureExtAck(int featureId, byte[] data) case TdsEnums.FEATUREEXT_GLOBALTRANSACTIONS: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for GlobalTransactions", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for GlobalTransactions", ObjectID); if (data.Length < 1) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown version number for GlobalTransactions", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown version number for GlobalTransactions", ObjectID); throw SQL.ParsingError(ParsingErrorState.CorruptedTdsStream); } @@ -2973,7 +2973,7 @@ internal void OnFeatureExtAck(int featureId, byte[] data) case TdsEnums.FEATUREEXT_AZURESQLSUPPORT: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for AzureSQLSupport", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for AzureSQLSupport", ObjectID); if (data.Length < 1) { @@ -2985,31 +2985,31 @@ internal void OnFeatureExtAck(int featureId, byte[] data) // Bit 0 for RO/FP support if ((data[0] & 1) == 1 && SqlClientEventSource.Log.IsTraceEnabled()) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, FailoverPartner enabled with Readonly intent for AzureSQL DB", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, FailoverPartner enabled with Readonly intent for AzureSQL DB", ObjectID); } break; } case TdsEnums.FEATUREEXT_DATACLASSIFICATION: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for DATACLASSIFICATION", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for DATACLASSIFICATION", ObjectID); if (data.Length < 1) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown token for DATACLASSIFICATION", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown token for DATACLASSIFICATION", ObjectID); throw SQL.ParsingError(ParsingErrorState.CorruptedTdsStream); } byte supportedDataClassificationVersion = data[0]; if ((0 == supportedDataClassificationVersion) || (supportedDataClassificationVersion > TdsEnums.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION)) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Invalid version number for DATACLASSIFICATION", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Invalid version number for DATACLASSIFICATION", ObjectID); throw SQL.ParsingErrorValue(ParsingErrorState.DataClassificationInvalidVersion, supportedDataClassificationVersion); } if (data.Length != 2) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown token for DATACLASSIFICATION", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown token for DATACLASSIFICATION", ObjectID); throw SQL.ParsingError(ParsingErrorState.CorruptedTdsStream); } byte enabled = data[1]; @@ -3019,11 +3019,11 @@ internal void OnFeatureExtAck(int featureId, byte[] data) case TdsEnums.FEATUREEXT_UTF8SUPPORT: { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Received feature extension acknowledgement for UTF8 support", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Received feature extension acknowledgement for UTF8 support", ObjectID); if (data.Length < 1) { - SqlClientEventSource.Log.TraceEvent(" {0}#, Unknown value for UTF8 support", ObjectID); + SqlClientEventSource.Log.TraceEvent(" {0}, Unknown value for UTF8 support", ObjectID); throw SQL.ParsingError(ParsingErrorState.CorruptedTdsStream); } break; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlTransaction.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlTransaction.cs index 6ce35ec499..7a70ebee70 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlTransaction.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlTransaction.cs @@ -142,8 +142,8 @@ override public void Commit() ZombieCheck(); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); TdsParser bestEffortCleanupTarget = null; RuntimeHelpers.PrepareConstrainedRegions(); @@ -268,7 +268,7 @@ override public void Rollback() if (IsYukonPartialZombie) { // Put something in the trace in case a customer has an issue - SqlClientEventSource.Log.AdvanceTrace(" {0}# partial zombie no rollback required", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} partial zombie no rollback required", ObjectID); _internalTransaction = null; // yukon zombification } @@ -277,8 +277,8 @@ override public void Rollback() ZombieCheck(); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); - SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}#, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); + SqlClientEventSource.Log.CorrelationTraceEvent(" ObjectID {0}, ActivityID {1}", ObjectID, ActivityCorrelator.Current.ToString()); TdsParser bestEffortCleanupTarget = null; RuntimeHelpers.PrepareConstrainedRegions(); @@ -342,7 +342,7 @@ public void Rollback(string transactionName) ZombieCheck(); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}# transactionName='{1}'", ObjectID, transactionName); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} transactionName='{1}'", ObjectID, transactionName); TdsParser bestEffortCleanupTarget = null; RuntimeHelpers.PrepareConstrainedRegions(); try @@ -404,7 +404,7 @@ public void Save(string savePointName) ZombieCheck(); SqlStatistics statistics = null; - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}# savePointName='{1}'", ObjectID, savePointName); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} savePointName='{1}'", ObjectID, savePointName); TdsParser bestEffortCleanupTarget = null; RuntimeHelpers.PrepareConstrainedRegions(); @@ -470,7 +470,7 @@ internal void Zombie() if (null != internalConnection && internalConnection.IsYukonOrNewer && !_isFromAPI) { - SqlClientEventSource.Log.AdvanceTrace(" {0}# yukon deferred zombie", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} yukon deferred zombie", ObjectID); } else { diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs index 2c43a9b253..31b4ddc9ed 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlUtil.cs @@ -326,9 +326,9 @@ static internal Exception IntegratedWithUserIDAndPassword() return ADP.Argument(StringsHelper.GetString(Strings.SQL_IntegratedWithUserIDAndPassword)); } - static internal Exception InteractiveWithUserIDAndPassword() + static internal Exception InteractiveWithPassword() { - return ADP.Argument(StringsHelper.GetString(Strings.SQL_InteractiveWithUserIDAndPassword)); + return ADP.Argument(StringsHelper.GetString(Strings.SQL_InteractiveWithPassword)); } static internal Exception SettingIntegratedWithCredential() 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 abd058d16a..a2b94c2129 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 @@ -726,7 +726,7 @@ internal void EnableMars() internal TdsParserStateObject CreateSession() { TdsParserStateObject session = new TdsParserStateObject(this, (SNIHandle)_pMarsPhysicalConObj.Handle, true); - SqlClientEventSource.Log.AdvanceTrace(" {0}# created session {1}", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} created session {1}", ObjectID, session.ObjectID); return session; } @@ -741,12 +741,12 @@ internal TdsParserStateObject GetSession(object owner) session = _sessionPool.GetSession(owner); Debug.Assert(!session._pendingData, "pending data on a pooled MARS session"); - SqlClientEventSource.Log.AdvanceTrace(" {0}# getting session {1} from pool", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} getting session {1} from pool", ObjectID, session.ObjectID); } else { session = _physicalStateObj; - SqlClientEventSource.Log.AdvanceTrace(" {0}# getting physical session {1}", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} getting physical session {1}", ObjectID, session.ObjectID); } Debug.Assert(session._outputPacketNumber == 1, "The packet number is expected to be 1"); return session; @@ -1134,10 +1134,8 @@ private void SendPreLoginHandshake(byte[] instanceName, bool encrypt, bool clien UInt32 error = 0; - // If we're using legacy server certificate validation behavior (Authentication keyword not provided and not using access token), then validate if - // Encrypt=true and Trust Sever Certificate = false. - // If using Authentication keyword or access token, validate if Trust Server Certificate=false. - bool shouldValidateServerCert = (encrypt && !trustServerCert) || ((authType != SqlAuthenticationMethod.NotSpecified || _connHandler._accessTokenInBytes != null) && !trustServerCert); + // Validate Certificate if Trust Server Certificate=false and Encryption forced (EncryptionOptions.ON) from Server. + bool shouldValidateServerCert = (_encryptionOption == EncryptionOptions.ON && !trustServerCert) || ((authType != SqlAuthenticationMethod.NotSpecified || _connHandler._accessTokenInBytes != null) && !trustServerCert); UInt32 info = (shouldValidateServerCert ? TdsEnums.SNI_SSL_VALIDATE_CERTIFICATE : 0) | (isYukonOrLater && (_encryptionOption & EncryptionOptions.CLIENT_CERT) == 0 ? TdsEnums.SNI_SSL_USE_SCHANNEL_CACHE : 0); @@ -1272,7 +1270,7 @@ private void SendPreLoginHandshake(byte[] instanceName, bool encrypt, bool clien // Only 0x00 and 0x01 are accepted values from the server. if (payload[payloadOffset] != 0x00 && payload[payloadOffset] != 0x01) { - SqlClientEventSource.Log.TraceEvent(" {0}#, " + + SqlClientEventSource.Log.TraceEvent(" {0}, " + "Server sent an unexpected value for FedAuthRequired PreLogin Option. Value was {1}.", ObjectID, (int)payload[payloadOffset]); throw SQL.ParsingErrorValue(ParsingErrorState.FedAuthRequiredPreLoginResponseInvalidValue, (int)payload[payloadOffset]); @@ -1315,8 +1313,11 @@ internal void Deactivate(bool connectionIsDoomed) { // Called when the connection that owns us is deactivated. - SqlClientEventSource.Log.AdvanceTrace(" {0}# deactivating", ObjectID); - SqlClientEventSource.Log.StateDumpEvent(" {0}#, {1}", ObjectID, TraceString()); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} deactivating", ObjectID); + if (SqlClientEventSource.Log.IsStateDumpEnabled()) + { + SqlClientEventSource.Log.StateDumpEvent(" {0}, {1}", ObjectID, TraceString()); + } if (MARSOn) { @@ -1472,7 +1473,7 @@ internal void ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool calle Debug.Assert(temp.Count > 0, "TdsParser::ThrowExceptionAndWarning called with no exceptions or warnings!"); if (temp.Count == 0) { - SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, unexpectedly empty warnings/errors under lock {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, unexpectedly empty warnings/errors under lock {0}", ObjectID); } Debug.Assert(_connHandler != null, "TdsParser::ThrowExceptionAndWarning called with null connectionHandler!"); @@ -2191,7 +2192,7 @@ internal bool TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataRead Debug.Fail($"unexpected token; token = {token,-2:X2}"); _state = TdsParserState.Broken; _connHandler.BreakConnection(); - SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, unexpected TDS token found {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, unexpected TDS token found {0}", ObjectID); throw SQL.ParsingErrorToken(ParsingErrorState.InvalidTdsTokenReceived, token); // MDAC 82443 } @@ -3984,7 +3985,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, SqlFedAuthInfo tempFedAuthInfo = new SqlFedAuthInfo(); // Skip reading token length, since it has already been read in caller - SqlClientEventSource.Log.AdvanceTrace(" FEDAUTHINFO token stream length = {0}", tokenLen); + SqlClientEventSource.Log.AdvancedTraceEvent(" FEDAUTHINFO token stream length = {0}", tokenLen); if (tokenLen < sizeof(uint)) { @@ -4003,7 +4004,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, } tokenLen -= sizeof(uint); // remaining length is shortened since we read optCount - SqlClientEventSource.Log.AdvanceTrace(" CountOfInfoIDs = {0}", optionsCount.ToString(CultureInfo.InvariantCulture)); + SqlClientEventSource.Log.AdvancedTraceEvent(" CountOfInfoIDs = {0}", optionsCount.ToString(CultureInfo.InvariantCulture)); if (tokenLen > 0) { @@ -4012,7 +4013,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, int totalRead = 0; bool successfulRead = stateObj.TryReadByteArray(tokenData, 0, tokenLen, out totalRead); - SqlClientEventSource.Log.AdvanceTrace(" Read rest of FEDAUTHINFO token stream: {0}", BitConverter.ToString(tokenData, 0, totalRead)); + SqlClientEventSource.Log.AdvancedTraceEvent(" Read rest of FEDAUTHINFO token stream: {0}", BitConverter.ToString(tokenData, 0, totalRead)); if (!successfulRead || totalRead != tokenLen) { @@ -4037,7 +4038,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, byte id = tokenData[currentOptionOffset]; uint dataLen = BitConverter.ToUInt32(tokenData, checked((int)(currentOptionOffset + 1))); uint dataOffset = BitConverter.ToUInt32(tokenData, checked((int)(currentOptionOffset + 5))); - SqlClientEventSource.Log.AdvanceTrace(" FedAuthInfoOpt: ID={0}, DataLen={1}, Offset={2}", id, dataLen.ToString(CultureInfo.InvariantCulture), dataOffset.ToString(CultureInfo.InvariantCulture)); + SqlClientEventSource.Log.AdvancedTraceEvent(" FedAuthInfoOpt: ID={0}, DataLen={1}, Offset={2}", id, dataLen.ToString(CultureInfo.InvariantCulture), dataOffset.ToString(CultureInfo.InvariantCulture)); // offset is measured from optCount, so subtract to make offset measured // from the beginning of tokenData @@ -4069,7 +4070,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, SqlClientEventSource.Log.TraceEvent(" FedAuthInfoData is not in unicode format.", "ERR"); throw SQL.ParsingError(ParsingErrorState.FedAuthInfoDataNotUnicode, e); } - SqlClientEventSource.Log.AdvanceTrace(" FedAuthInfoData: {0}", data); + SqlClientEventSource.Log.AdvancedTraceEvent(" FedAuthInfoData: {0}", data); // store data in tempFedAuthInfo switch ((TdsEnums.FedAuthInfoId)id) @@ -4081,7 +4082,7 @@ private bool TryProcessFedAuthInfo(TdsParserStateObject stateObj, int tokenLen, tempFedAuthInfo.stsurl = data; break; default: - SqlClientEventSource.Log.AdvanceTrace(" Ignoring unknown federated authentication info option: {0}", id); + SqlClientEventSource.Log.AdvancedTraceEvent(" Ignoring unknown federated authentication info option: {0}", id); break; } } @@ -8794,7 +8795,7 @@ internal int WriteUTF8SupportFeatureRequest(bool write /* if false just calculat } WriteInt(log7Flags, _physicalStateObj); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, TDS Login7 flags = {1}:", ObjectID, log7Flags); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, TDS Login7 flags = {1}:", ObjectID, log7Flags); WriteInt(0, _physicalStateObj); // ClientTimeZone is not used WriteInt(0, _physicalStateObj); // LCID is unused by server @@ -9506,7 +9507,7 @@ internal Task TdsExecuteSQLBatch(string text, int timeout, SqlNotificationReques stateObj.SetTimeoutSeconds(timeout); if ((!_fMARS) && (_physicalStateObj.HasOpenResult)) { - SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, non-MARs connection with an open result {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, non-MARs connection with an open result {0}", ObjectID); } stateObj.SniContext = SniContext.Snix_Execute; @@ -9635,7 +9636,7 @@ internal Task TdsExecuteSQLBatch(string text, int timeout, SqlNotificationReques stateObj.SetTimeoutSeconds(timeout); if ((!_fMARS) && (_physicalStateObj.HasOpenResult)) { - SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, non-MARs connection with an open result {0}#", ObjectID); + SqlClientEventSource.Log.TraceEvent(" Potential multi-threaded misuse of connection, non-MARs connection with an open result {0}", ObjectID); } stateObj.SniContext = SniContext.Snix_Execute; @@ -10499,7 +10500,7 @@ private void WriteSmiParameter(SqlParameter param, int paramIndex, bool sendDefa } var sendDefaultValue = sendDefault ? 1 : 0; - SqlClientEventSource.Log.AdvanceTrace(" {0}#, Sending parameter '{1}', default flag={2}, metadata:{3}", ObjectID, param.ParameterName, sendDefaultValue, metaData.TraceString(3)); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, Sending parameter '{1}', default flag={2}, metadata:{3}", ObjectID, param.ParameterName, sendDefaultValue, metaData.TraceString(3)); // // Write parameter metadata @@ -11555,7 +11556,7 @@ private void WriteQueryNotificationHeaderData(SqlNotificationRequest notificatio Debug.Assert(-1 <= timeout, "Timeout"); - SqlClientEventSource.Log.NotificationsTraceEvent(" NotificationRequest: userData: '{0}', options: '{1}', timeout: '{2}'", notificationRequest.UserData, notificationRequest.Options, notificationRequest.Timeout); + SqlClientEventSource.Log.NotificationTraceEvent(" NotificationRequest: userData: '{0}', options: '{1}', timeout: '{2}'", notificationRequest.UserData, notificationRequest.Options, notificationRequest.Timeout); WriteShort(TdsEnums.HEADERTYPE_QNOTIFICATION, stateObj); // Query notifications Type @@ -13506,13 +13507,13 @@ internal ulong PlpBytesTotalLength(TdsParserStateObject stateObj) ; internal string TraceString() { - return String.Format(/*IFormatProvider*/ null, + return string.Format(/*IFormatProvider*/ null, StateTraceFormatString, - null == _physicalStateObj, - null == _pMarsPhysicalConObj, + null == _physicalStateObj ? bool.TrueString : bool.FalseString, + null == _pMarsPhysicalConObj ? bool.TrueString : bool.FalseString, _state, _server, - _fResetConnection, + _fResetConnection ? bool.TrueString : bool.FalseString, null == _defaultCollation ? "(null)" : _defaultCollation.TraceString(), _defaultCodePage, _defaultLCID, @@ -13524,19 +13525,19 @@ internal string TraceString() _retainedTransactionId, _nonTransactedOpenResultCount, null == _connHandler ? "(null)" : _connHandler.ObjectID.ToString((IFormatProvider)null), - _fMARS, + _fMARS ? bool.TrueString : bool.FalseString, null == _sessionPool ? "(null)" : _sessionPool.TraceString(), - _isShiloh, - _isShilohSP1, - _isYukon, + _isShiloh ? bool.TrueString : bool.FalseString, + _isShilohSP1 ? bool.TrueString : bool.FalseString, + _isYukon ? bool.TrueString : bool.FalseString, null == _sniSpnBuffer ? "(null)" : _sniSpnBuffer.Length.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.ErrorCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.WarningCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionErrorCount.ToString((IFormatProvider)null), _physicalStateObj != null ? "(null)" : _physicalStateObj.PreAttentionWarningCount.ToString((IFormatProvider)null), - null == _statistics, - _statisticsIsInTransaction, - _fPreserveTransaction, + null == _statistics ? bool.TrueString : bool.FalseString, + _statisticsIsInTransaction ? bool.TrueString : bool.FalseString, + _fPreserveTransaction ? bool.TrueString : bool.FalseString, null == _connHandler ? "(null)" : _connHandler.ConnectionOptions.MultiSubnetFailover.ToString((IFormatProvider)null), null == _connHandler ? "(null)" : _connHandler.ConnectionOptions.TransparentNetworkIPResolution.ToString((IFormatProvider)null)); } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs index a0f55550cc..eb732e95bf 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserSessionPool.cs @@ -36,7 +36,7 @@ internal TdsParserSessionPool(TdsParser parser) _cache = new List(); _freeStateObjects = new TdsParserStateObject[MaxInactiveCount]; _freeStateObjectCount = 0; - SqlClientEventSource.Log.AdvanceTrace(" {0}# created session pool for parser {1}", ObjectID, parser.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} created session pool for parser {1}", ObjectID, parser.ObjectID); } private bool IsDisposed @@ -60,7 +60,7 @@ internal void Deactivate() // When being deactivated, we check all the sessions in the // cache to make sure they're cleaned up and then we dispose of // sessions that are past what we want to keep around. - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}# deactivating cachedCount={1}", ObjectID, _cachedCount); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} deactivating cachedCount={1}", ObjectID, _cachedCount); try { lock (_cache) @@ -79,7 +79,7 @@ internal void Deactivate() if (session.IsOrphaned) { // TODO: consider adding a performance counter for the number of sessions we reclaim - SqlClientEventSource.Log.AdvanceTrace(" {0}# reclaiming session {1}", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} reclaiming session {1}", ObjectID, session.ObjectID); PutSession(session); } } @@ -113,7 +113,7 @@ internal void BestEffortCleanup() internal void Dispose() { - SqlClientEventSource.Log.AdvanceTrace(" {0}# disposing cachedCount={1}", ObjectID, _cachedCount); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} disposing cachedCount={1}", ObjectID, _cachedCount); lock (_cache) { // Dispose free sessions @@ -172,7 +172,7 @@ internal TdsParserStateObject GetSession(object owner) { // No free objects, create a new one session = _parser.CreateSession(); - SqlClientEventSource.Log.AdvanceTrace(" {0}# adding session {1} to pool", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} adding session {1} to pool", ObjectID, session.ObjectID); _cache.Add(session); _cachedCount = _cache.Count; @@ -180,7 +180,7 @@ internal TdsParserStateObject GetSession(object owner) session.Activate(owner); } - SqlClientEventSource.Log.AdvanceTrace(" {0}# using session {1}", ObjectID, session.ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} using session {1}", ObjectID, session.ObjectID); return session; } @@ -202,7 +202,7 @@ internal void PutSession(TdsParserStateObject session) else if ((okToReuse) && (_freeStateObjectCount < MaxInactiveCount)) { // Session is good to re-use and our cache has space - SqlClientEventSource.Log.AdvanceTrace(" {0}# keeping session {1} cachedCount={2}", ObjectID, session.ObjectID, _cachedCount); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} keeping session {1} cachedCount={2}", ObjectID, session.ObjectID, _cachedCount); Debug.Assert(!session._pendingData, "pending data on a pooled session?"); _freeStateObjects[_freeStateObjectCount] = session; @@ -211,7 +211,7 @@ internal void PutSession(TdsParserStateObject session) else { // Either the session is bad, or we have no cache space - so dispose the session and remove it - SqlClientEventSource.Log.AdvanceTrace(" {0}# disposing session {1} cachedCount={2}", ObjectID, session.ObjectID, _cachedCount); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0} disposing session {1} cachedCount={2}", ObjectID, session.ObjectID, _cachedCount); bool removed = _cache.Remove(session); Debug.Assert(removed, "session not in pool?"); diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs index bb0a5e542f..a722b83771 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs @@ -558,8 +558,8 @@ internal bool TryInitialize(TdsParserStateObject stateObj, int columnsCount) { return false; } - SqlClientEventSource.Log.TraceEvent(" {0}#, NBCROW bitmap received, column count = {1}", stateObj.ObjectID, columnsCount); - SqlClientEventSource.Log.TraceBinEvent(" NBCROW bitmap data: ", _nullBitmap, (ushort)_nullBitmap.Length); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, NBCROW bitmap received, column count = {1}", stateObj.ObjectID, columnsCount); + SqlClientEventSource.Log.AdvancedTraceBinEvent(" NBCROW bitmap data: ", _nullBitmap, (ushort)_nullBitmap.Length); return true; } @@ -912,11 +912,11 @@ internal void DecrementOpenResultCount() internal int DecrementPendingCallbacks(bool release) { int remaining = Interlocked.Decrement(ref _pendingCallbacks); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, after decrementing _pendingCallbacks: {1}", ObjectID, _pendingCallbacks); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, after decrementing _pendingCallbacks: {1}", ObjectID, _pendingCallbacks); if ((0 == remaining || release) && _gcHandle.IsAllocated) { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, FREEING HANDLE!", ObjectID); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, FREEING HANDLE!", ObjectID); _gcHandle.Free(); } @@ -1025,7 +1025,7 @@ internal int IncrementPendingCallbacks() { int remaining = Interlocked.Increment(ref _pendingCallbacks); - SqlClientEventSource.Log.AdvanceTrace(" {0}#, after incrementing _pendingCallbacks: {1}", ObjectID, _pendingCallbacks); + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, after incrementing _pendingCallbacks: {1}", ObjectID, _pendingCallbacks); Debug.Assert(0 < remaining && remaining <= 3, $"_pendingCallbacks values is invalid after incrementing: {remaining}"); return remaining; } @@ -2795,7 +2795,7 @@ public void ProcessSniPacket(IntPtr packet, UInt32 error) } } SniReadStatisticsAndTracing(); - SqlClientEventSource.Log.AdvanceTraceBin(" Packet read", _inBuff, (ushort)_inBytesRead); + SqlClientEventSource.Log.AdvancedTraceBinEvent(" Packet read", _inBuff, (ushort)_inBytesRead); AssertValidState(); } else @@ -3541,7 +3541,7 @@ internal void SendAttention(bool mustTakeWriteLock = false) _attentionSending = false; } - SqlClientEventSource.Log.AdvanceTraceBin(" Packet sent", _outBuff, (ushort)_outBytesUsed); + SqlClientEventSource.Log.AdvancedTraceBinEvent(" Packet sent", _outBuff, (ushort)_outBytesUsed); SqlClientEventSource.Log.TraceEvent(" Attention sent to the server.", "Info"); AssertValidState(); @@ -3698,7 +3698,7 @@ private void SniWriteStatisticsAndTracing() statistics.SafeAdd(ref statistics._bytesSent, _outBytesUsed); statistics.RequestNetworkServerTimer(); } - if (SqlClientEventSource.Log.IsAdvanceTraceOn()) + if (SqlClientEventSource.Log.IsAdvancedTraceOn()) { // If we have tracePassword variables set, we are flushing TDSLogin and so we need to // blank out password in buffer. Buffer has already been sent to netlib, so no danger @@ -3728,7 +3728,7 @@ private void SniWriteStatisticsAndTracing() _traceChangePasswordLength = 0; } } - SqlClientEventSource.Log.AdvanceTraceBin(" Packet sent", _outBuff, (ushort)_outBytesUsed); + SqlClientEventSource.Log.AdvancedTraceBinEvent(" Packet sent", _outBuff, (ushort)_outBytesUsed); } [Conditional("DEBUG")] diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/sqlinternaltransaction.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/sqlinternaltransaction.cs index 6e1c1beac9..650a1652a4 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/sqlinternaltransaction.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/sqlinternaltransaction.cs @@ -53,7 +53,7 @@ internal SqlInternalTransaction(SqlInternalConnection innerConnection, Transacti internal SqlInternalTransaction(SqlInternalConnection innerConnection, TransactionType type, SqlTransaction outerTransaction, long transactionId) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Created for connection {1}#, outer transaction {2}#, Type {3}", ObjectID, innerConnection.ObjectID, (null != outerTransaction) ? outerTransaction.ObjectID : -1, (int)type); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Created for connection {1}, outer transaction {2}, Type {3}", ObjectID, innerConnection.ObjectID, (null != outerTransaction) ? outerTransaction.ObjectID : -1, (int)type); _innerConnection = innerConnection; _transactionType = type; @@ -268,7 +268,7 @@ internal void CloseFromConnection() SqlInternalConnection innerConnection = _innerConnection; Debug.Assert(innerConnection != null, "How can we be here if the connection is null?"); - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Closing", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Closing", ObjectID); bool processFinallyBlock = true; try @@ -296,7 +296,7 @@ internal void CloseFromConnection() internal void Commit() { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); if (_innerConnection.IsLockedForBulkCopy) { throw SQL.ConnectionLockedForBcpEvent(); @@ -369,7 +369,7 @@ internal void Dispose() private /*protected override*/ void Dispose(bool disposing) { - SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Disposing", ObjectID); + SqlClientEventSource.Log.PoolerTraceEvent(" {0}, Disposing", ObjectID); if (disposing) { @@ -425,7 +425,7 @@ internal void InitParent(SqlTransaction transaction) internal void Rollback() { - var scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID); + var scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}", ObjectID); if (_innerConnection.IsLockedForBulkCopy) { @@ -472,7 +472,7 @@ internal void Rollback() internal void Rollback(string transactionName) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#, transactionName='{transactionName}'", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}, transactionName='{1}'", ObjectID, transactionName); if (_innerConnection.IsLockedForBulkCopy) { @@ -521,7 +521,7 @@ internal void Rollback(string transactionName) internal void Save(string savePointName) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#, savePointName='{savePointName}'", ObjectID); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}, savePointName='{1}'", ObjectID, savePointName); _innerConnection.ValidateConnectionForExecute(null); try diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlTypes/SqlFileStream.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlTypes/SqlFileStream.cs index a66e9f186a..3fb3ffe338 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlTypes/SqlFileStream.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlTypes/SqlFileStream.cs @@ -65,7 +65,7 @@ public SqlFileStream Int64 allocationSize ) { - long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}# access={1} options={2} path='{3}'", ObjectID, (int)access, (int)options, path); + long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0} access={1} options={2} path='{3}'", ObjectID, (int)access, (int)options, path); try { //----------------------------------------------------------------- @@ -713,7 +713,7 @@ Int64 allocationSize UnsafeNativeMethods.SetErrorModeWrapper(UnsafeNativeMethods.SEM_FAILCRITICALERRORS, out oldMode); try { - SqlClientEventSource.Log.AdvanceTrace(" {0}#, desiredAccess=0x{1}, allocationSize={2}, " + + SqlClientEventSource.Log.AdvancedTraceEvent(" {0}, desiredAccess=0x{1}, allocationSize={2}, " + "fileAttributes=0x{3}, shareAccess=0x{4}, dwCreateDisposition=0x{5}, createOptions=0x{ dwCreateOptions}", ObjectID, (int)nDesiredAccess, allocationSize, 0, (int)shareAccess, dwCreateDisposition); retval = UnsafeNativeMethods.NtCreateFile(out hFile, nDesiredAccess, diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.Designer.cs b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.Designer.cs index 0e7cf7910a..a32b1d243b 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.Designer.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.Designer.cs @@ -9379,11 +9379,11 @@ internal class Strings { } /// - /// Looks up a localized string similar to Cannot use 'Authentication=Active Directory Interactive' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords.. + /// Looks up a localized string similar to Cannot use 'Authentication=Active Directory Interactive' with 'Password' or 'PWD' connection string keywords.. /// - internal static string SQL_InteractiveWithUserIDAndPassword { + internal static string SQL_InteractiveWithPassword { get { - return ResourceManager.GetString("SQL_InteractiveWithUserIDAndPassword", resourceCulture); + return ResourceManager.GetString("SQL_InteractiveWithPassword", resourceCulture); } } diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx index 20193d1e49..dee8e16190 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx +++ b/src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.resx @@ -2496,8 +2496,8 @@ Cannot use 'Authentication=Active Directory Integrated' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords. - - Cannot use 'Authentication=Active Directory Interactive' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords. + + Cannot use 'Authentication=Active Directory Interactive' with 'Password' or 'PWD' connection string keywords. Cannot use 'Authentication=Active Directory Integrated', if the Credential property has been set. diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandTest.cs index 7fe0d7af6d..ae9e097dfd 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlCommandTest.cs @@ -555,8 +555,15 @@ public void UpdatedRowSource_Value_Invalid() [Fact] public void ParameterCollectionTest() { - SqlCommand cmd = new SqlCommand(); - cmd.Parameters.AddRange(new SqlParameter[] { }); + using (var cmd = new SqlCommand()) + { + cmd.Parameters.Add(new SqlParameter()); + cmd.Parameters.AddRange(new SqlParameter[] { }); + cmd.Parameters.Insert(0, new SqlParameter()); + cmd.Parameters.Insert(1, new SqlParameter()); + cmd.Parameters.RemoveAt(0); + cmd.Parameters.Remove(cmd.Parameters[0]); + } } } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs index f30e381f24..7110e506f5 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs @@ -3,16 +3,13 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.SqlTypes; +using System.Diagnostics.Tracing; using System.Globalization; using System.IO; -using System.Linq; -using System.Reflection; using System.Security; -using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Identity.Client; @@ -38,24 +35,23 @@ public static class DataTestUtility public static List AEConnStrings = new List(); public static List AEConnStringsSetup = new List(); public static readonly bool EnclaveEnabled = false; + public static readonly bool TracingEnabled = false; public static readonly bool SupportsIntegratedSecurity = false; public static readonly bool SupportsLocalDb = false; public static readonly bool SupportsFileStream = false; + public static readonly bool UseManagedSNIOnWindows = false; public const string UdtTestDbName = "UdtTestDb"; public const string AKVKeyName = "TestSqlClientAzureKeyVaultProvider"; - private const string ManagedNetworkingAppContextSwitch = "Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows"; - private static bool UseManagedSNI = - bool.TryParse(Environment.GetEnvironmentVariable("Microsoft_Data_SqlClient_UseManagedSniOnWindows"), out UseManagedSNI) ? UseManagedSNI : false; - private static readonly string[] AzureSqlServerEndpoints = {".database.windows.net", ".database.cloudapi.de", ".database.usgovcloudapi.net", ".database.chinacloudapi.cn"}; private static Dictionary AvailableDatabases; + private static TraceEventListener TraceListener; private class Config { @@ -70,21 +66,15 @@ private class Config public string AzureKeyVaultClientId = null; public string AzureKeyVaultClientSecret = null; public bool EnclaveEnabled = false; + public bool TracingEnabled = false; public bool SupportsIntegratedSecurity = false; public bool SupportsLocalDb = false; public bool SupportsFileStream = false; + public bool UseManagedSNIOnWindows = false; } static DataTestUtility() { - if (UseManagedSNI) - { - AppContext.SetSwitch(ManagedNetworkingAppContextSwitch, true); - Console.WriteLine($"App Context switch {ManagedNetworkingAppContextSwitch} enabled on {Environment.OSVersion}"); - } - - AppContext.SetSwitch("TestSwitch.LocalAppContext.DisableCaching", true); //disable caching on LocalAppContext for defined switches - using (StreamReader r = new StreamReader("config.json")) { string json = r.ReadToEnd(); @@ -101,6 +91,21 @@ static DataTestUtility() SupportsIntegratedSecurity = c.SupportsIntegratedSecurity; SupportsFileStream = c.SupportsFileStream; EnclaveEnabled = c.EnclaveEnabled; + TracingEnabled = c.TracingEnabled; + UseManagedSNIOnWindows = c.UseManagedSNIOnWindows; + + if (TracingEnabled) + { + TraceListener = new DataTestUtility.TraceEventListener(); + } + + if (UseManagedSNIOnWindows) + { + AppContext.SetSwitch(ManagedNetworkingAppContextSwitch, true); + Console.WriteLine($"App Context switch {ManagedNetworkingAppContextSwitch} enabled on {Environment.OSVersion}"); + } + + AppContext.SetSwitch("TestSwitch.LocalAppContext.DisableCaching", true); //disable caching on LocalAppContext for defined switches if (IsAADPasswordConnStrSetup() && IsAADAuthorityURLSetup()) { @@ -240,7 +245,7 @@ public static bool IsAKVSetupAvailable() return !string.IsNullOrEmpty(AKVUrl) && !string.IsNullOrEmpty(AKVClientId) && !string.IsNullOrEmpty(AKVClientSecret); } - public static bool IsUsingManagedSNI() => UseManagedSNI; + public static bool IsUsingManagedSNI() => UseManagedSNIOnWindows; public static bool IsUsingNativeSNI() => !IsUsingManagedSNI(); @@ -663,5 +668,24 @@ public static string RetrieveValueFromConnStr(string connStr, string[] keywords) } return res; } + + public class TraceEventListener : EventListener + { + public List IDs = new List(); + + protected override void OnEventSourceCreated(EventSource eventSource) + { + if (eventSource.Name.Equals("Microsoft.Data.SqlClient.EventSource")) + { + // Collect all traces for better code coverage + EnableEvents(eventSource, EventLevel.Informational, EventKeywords.All); + } + } + + protected override void OnEventWritten(EventWrittenEventArgs eventData) + { + IDs.Add(eventData.EventId); + } + } } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/EventSource/EventSourceTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/EventSource/EventSourceTest.cs index 74eac0d06d..a6a1d2287c 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/EventSource/EventSourceTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/EventSource/EventSourceTest.cs @@ -2,60 +2,36 @@ // 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.Collections.Generic; -using System.Diagnostics.Tracing; +using System.Linq; using Xunit; namespace Microsoft.Data.SqlClient.ManualTesting.Tests { - [SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp, "Not Implemented")] public class EventSourceTest { - List ids = new List(); - [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))] - public void EventTraceTests() - { - GetIds(); - //Trace EventKeyword is 3. - //We did not want to break the SqlEventSource for BeginExexute and EndExecute - // BeginExexute and EndExecute are Enabled when any kind of Event logging is enabled, so we check for those values as well. - Assert.All(ids, item => { Assert.True(3 == item || 1 == item || item == 2); }); - } - - private void GetIds() + public void EventSourceTestAll() { - using (var TraceListener = new TraceEventListener()) + using (var TraceListener = new DataTestUtility.TraceEventListener()) { using (SqlConnection connection = new SqlConnection(DataTestUtility.TCPConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand("SELECT * From [Customers]", connection)) + using (SqlDataReader reader = command.ExecuteReader()) { - command.ExecuteNonQuery(); + while (reader.Read()) + { + // Flush data + } } - ids = TraceListener.IDs; } - ids = TraceListener.IDs; - } - } - } - [SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp, "Not Implemented")] - public class TraceEventListener : EventListener - { - public List IDs = new List(); - protected override void OnEventSourceCreated(EventSource eventSource) - { - if (eventSource.Name.Equals("Microsoft.Data.SqlClient.EventSource")) - { - EnableEvents(eventSource, EventLevel.Informational, (EventKeywords)1); - } - } + // Need to investigate better way of validating traces in sequential runs, + // For now we're collecting all traces to improve code coverage. - protected override void OnEventWritten(EventWrittenEventArgs eventData) - { - IDs.Add(eventData.EventId); + Assert.All(TraceListener.IDs, item => { Assert.Contains(item, Enumerable.Range(1, 21)); }); + } } } } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj index 96034040fc..3a596dd237 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj @@ -8,6 +8,7 @@ Debug;Release;net46-Release;net46-Debug;netcoreapp2.1-Debug;netcoreapp2.1-Release;netcoreapp3.1-Debug;netcoreapp3.1-Release AnyCPU;x86;x64 $(DefineConstants);netcoreapp + $(DefineConstants);netfx $(ObjFolder)$(Configuration).ManualTests $(BinFolder)$(Configuration).ManualTests diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs index b2f29b6abe..308e0e9599 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs @@ -224,14 +224,14 @@ public static void IntegratedAuthWithCred() [ConditionalFact(nameof(IsAADConnStringsSetup))] [SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp)] - public static void MFAAuthWithCred() + public static void MFAAuthWithPassword() { // connection fails with expected error message. string[] AuthKey = { "Authentication" }; string connStr = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, AuthKey) + "Authentication=Active Directory Interactive;"; ArgumentException e = Assert.Throws(() => ConnectAndDisconnect(connStr)); - string expectedMessage = "Cannot use 'Authentication=Active Directory Interactive' with 'User ID', 'UID', 'Password' or 'PWD' connection string keywords."; + string expectedMessage = "Cannot use 'Authentication=Active Directory Interactive' with 'Password' or 'PWD' connection string keywords."; Assert.Contains(expectedMessage, e.Message); } diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/config.default.json b/src/Microsoft.Data.SqlClient/tests/ManualTests/config.default.json index 263291d462..54fdd927f6 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/config.default.json +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/config.default.json @@ -5,6 +5,7 @@ "TCPConnectionStringAASVBS": "", "TCPConnectionStringAASSGX": "", "EnclaveEnabled": false, + "TracingEnabled": false, "AADAuthorityURL": "", "AADPasswordConnectionString": "", "AzureKeyVaultURL": "", @@ -12,5 +13,6 @@ "AzureKeyVaultClientSecret": "", "SupportsIntegratedSecurity": true, "SupportsLocalDb": false, - "SupportsFileStream": false + "SupportsFileStream": false, + "UseManagedSNIOnWindows": false } diff --git a/tools/props/Versions.props b/tools/props/Versions.props index 84f11ff682..d1724e7806 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -9,7 +9,7 @@ - [1.1.0,1.2.0) + 1.1.* 4.3.1 4.3.0 diff --git a/tools/specs/Microsoft.Data.SqlClient.nuspec b/tools/specs/Microsoft.Data.SqlClient.nuspec index d3d1ac7677..c4b3efc0c2 100644 --- a/tools/specs/Microsoft.Data.SqlClient.nuspec +++ b/tools/specs/Microsoft.Data.SqlClient.nuspec @@ -27,7 +27,7 @@ When using NuGet 3.x this package requires at least version 3.4. sqlclient microsoft.data.sqlclient - +