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/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
index 4592fb2259..f0e39b5f7e 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
@@ -979,7 +979,10 @@ 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());
+ if (SqlClientEventSource.Log.IsStateDumpEnabled())
+ {
+ SqlClientEventSource.Log.StateDumpEvent(" {0}# {1}", ObjectID, TraceString());
+ }
if (MARSOn)
{
@@ -12631,13 +12634,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,
@@ -12649,17 +12652,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));
}