diff --git a/src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/AssemblyTemplate_BID.cs b/src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/AssemblyTemplate_BID.cs
deleted file mode 100644
index 8c61c8dc29..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/AssemblyTemplate_BID.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Text;
-using System.Security;
-using System.Reflection;
-using System.Security.Permissions;
-using System.Runtime.InteropServices;
-using System.Runtime.Versioning;
-
-[module: BidIdentity("MyAssemblyName.1")]
-[module: BidMetaText(":FormatControl: InstanceID='' ")]
-
-internal static partial class Bid
-{
- private const string dllName = "BidLdr.dll";
-
- //
- // Strongly Typed Overloads example.
- // Use SignatureGenerator or edit manually in order to create actual set of overloads.
- //
- internal static void Trace(string fmtPrintfW, System.Int32 a1) {
- if ((modFlags & ApiGroup.Trace) != 0 && modID != NoData)
- NativeMethods.Trace (modID, UIntPtr.Zero, UIntPtr.Zero, fmtPrintfW,a1);
- }
-
- internal static void TraceEx(uint flags, string fmtPrintfW, System.Int32 a1) {
- if (modID != NoData)
- NativeMethods.Trace (modID, UIntPtr.Zero, (UIntPtr)flags, fmtPrintfW,a1);
- }
-
- //
- // Interop calls to pluggable hooks [SuppressUnmanagedCodeSecurity] applied
- //
- private static partial class NativeMethods
- {
- [ResourceExposure(ResourceScope.None)]
- [DllImport(dllName, CharSet=CharSet.Unicode, CallingConvention=CallingConvention.Cdecl, EntryPoint="DllBidTraceCW")] extern
- internal static void Trace (IntPtr hID, UIntPtr src, UIntPtr info, string fmtPrintfW, System.Int32 a1);
- } // Native
-} // Bid
-
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/BidPrivateBase.cs b/src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/BidPrivateBase.cs
deleted file mode 100644
index 7562835bf8..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/BidPrivateBase.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Runtime.InteropServices;
-
-[ComVisible(false)]
-internal static partial class Bid
-{
- //+//////////////////////////////////////////////////////////////////////////////////////////
- // //
- // INTERFACE //
- // //
- //+//////////////////////////////////////////////////////////////////////////////////////////
- //
- // ApiGroup control flags are accessible from attached diagnostic subsystem via corresponding
- // delegate, so the output can be enabled/disabled on the fly.
- //
- internal enum ApiGroup : uint
- {
- Off = 0x00000000,
-
- Default = 0x00000001, // Bid.TraceEx (Always ON)
- Trace = 0x00000002, // Bid.Trace, Bid.PutStr
- Scope = 0x00000004, // Bid.Scope{Enter|Leave|Auto}
- Perf = 0x00000008, // TBD..
- Resource = 0x00000010, // TBD..
- Memory = 0x00000020, // TBD..
- StatusOk = 0x00000040, // S_OK, STATUS_SUCCESS, etc.
- Advanced = 0x00000080, // Bid.TraceEx
-
- Pooling = 0x00001000,
- Dependency = 0x00002000,
- StateDump = 0x00004000,
- Correlation = 0x00040000,
-
- MaskBid = 0x00000FFF,
- MaskUser = 0xFFFFF000,
- MaskAll = 0xFFFFFFFF
- }
-
- internal static bool TraceOn
- {
- get { return (modFlags & ApiGroup.Trace) != 0; }
- }
-
- internal static bool AdvancedOn
- {
- get { return (modFlags & ApiGroup.Advanced) != 0; }
- }
-
- internal static bool IsOn(ApiGroup flag)
- {
- return (modFlags & flag) != 0;
- }
-
- private static IntPtr __noData = (IntPtr)(-1);
-
- internal static IntPtr NoData
- {
- get { return __noData; }
- }
-
- internal static void PutStr(string str)
- {
- }
-
- internal static void Trace(string strConst)
- {
- }
-
- internal static void Trace(string fmtPrintfW, string a1)
- {
- }
-
- internal static void ScopeLeave(ref IntPtr hScp)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string strConst)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, int a1)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, int a1, int a2)
- {
- hScp = NoData;
- }
-
- internal static void TraceBin(string constStrHeader, byte[] buff, UInt16 length)
- {
- }
-
- private static ApiGroup modFlags = ApiGroup.Off;
-
-} // Bid{PrivateBase}
-
-///
-/// This attribute is used by FxCopBid rule to mark methods that accept format string and list of arguments that match it
-/// FxCopBid rule uses this attribute to check if the method needs to be included in checks and to read type mappings
-/// between the argument type to printf Type spec.
-///
-/// If you need to rename/remove the attribute or change its properties, make sure to update the FxCopBid rule!
-///
-[System.Diagnostics.ConditionalAttribute("CODE_ANALYSIS")]
-[System.AttributeUsage(AttributeTargets.Method)]
-internal sealed class BidMethodAttribute : Attribute
-{
- internal BidMethodAttribute()
- {
- }
-}
-
-///
-/// This attribute is used by FxCopBid rule to tell FXCOP the 'real' type sent to the native trace call for this argument. For
-/// example, if Bid.Trace accepts enumeration value, but marshals it as string to the native trace method, set this attribute
-/// on the argument and set ArgumentType = typeof(string)
-///
-/// It can be applied on a parameter, to let FxCopBid rule know the format spec type used for the argument, or it can be applied on a method,
-/// to insert additional format spec arguments at specific location.
-///
-/// If you need to rename/remove the attribute or change its properties, make sure to update the FxCopBid rule!
-///
-[System.Diagnostics.ConditionalAttribute("CODE_ANALYSIS")]
-[System.AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)]
-internal sealed class BidArgumentTypeAttribute : Attribute
-{
- // this overload can be used on the argument itself
- internal BidArgumentTypeAttribute(Type bidArgumentType)
- {
- this.ArgumentType = bidArgumentType;
- this.Index = -1; // if this c-tor is used on methods, default index value is 'last'
- }
-
- public readonly Type ArgumentType;
- // should be used only if attribute is applied on the method
- public readonly int Index;
-}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/InProcSxSBid.htm b/src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/InProcSxSBid.htm
deleted file mode 100644
index 727033f3ae..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/BID/INC/CS/InProcSxSBid.htm
+++ /dev/null
@@ -1,647 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Bid is ‘safe’ for InProcSxS, but I’ve added an initial trace line for each AppDomain to make it more human friendly.
via System.Runtime.Versioning.VersionHelper.MakeVersionSafeName(AppDomain.CurrentDomain.FriendlyName,
-ResourceScope.Machine, ResourceScope.AppDomain);
-For every managed AppDomain and native Dll that loads, a new unique (recyclable) module id is
-acquired from the loader via DllBidEntryPoint.
-
-
There is only a single loader (aka.
-AdoNetDiag.dll running in native code) loaded per process.
-
-
-Yes, you could be malicious and change the registry key that identifies the
-loader per DLL load - but that’s not supported scenario.
-
-
-
-
-The Thread ID and Module ID are included with every trace.
-
-
-The Module ID is agnostic to the NetFx40 or NetFx35 instance since it is a
-unique identifiers for the process; the ‘friendly name’ and ad# are not unique
-to the process.
-
-
-Allows a single thread to be followed through the process and
-different application domains uniquely identified.
-
-
-For managed code to be more human friendly, that initial trace point per
-application domain helps identify the running instance/domain more clearly.
-
-
-
-
Removed the following files to share a common Bid\inc\cs\BidPrivateBase.cs
The common file was originally not shared in V2.0 because
-when the work started
-
-
a)partial
-class hadn’t been introduced yet
-
-
b)reliability
-work with constrained execution regions hadn’t been introduced yet
-
-
c)the supposed common code was modified with each copy for
-individual needs at the time.
-
-
-
-
In bid\inc\cs\bidprivatebase.cs
-
-
-Dead code removal relating to tracing.
-
-
-Removed the V1 support code
-
-
-Added other #defines to “remove unused” code by System.Data.dll
-, System.Data.OracleClient.dll and System.Data.Entity.dll
-
-
Added [ResourceExposure(ResourceScope.None)] to all Bid.NativeMethods
-since they don’t expose any resources.
-
-
-
-
-Did not add ResourceExposure to modID
-since it doesn’t expose a resource, it just represents a unique identitifer.
-
-
-Similar to how XmlReader doesn’t expose the resource,
-however its creation with a filename does.
-
-
-
-
I have already checked in the start of a tracing unit test (changeset #629692, #629897)
-
-
-It can enable BidStub, BidLabProto
-or AdoNetDiag for tracing. AdoNetDiag
-is the one used by the unit test.
-
-
-Then launches a program to traces the 24 permutations of (FullTrust
-tracing first or partial trust tracing first) and (initial domain tracing first
-or secondary domain tracing first).
-
-
-Remaining work: programmatically analyze the output to verify the expected
-traces.
-
-
-
-
-
-
-
-
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
index ed6135157b..6f77a7d592 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -116,6 +116,7 @@
+
@@ -227,7 +228,6 @@
-
@@ -268,7 +268,6 @@
-
@@ -302,8 +301,6 @@
-
-
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 90f4981b4b..550cbf24e0 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
@@ -14,7 +14,6 @@ namespace Microsoft.Data.Common
internal static class ActivityCorrelator
{
- internal const Bid.ApiGroup CorrelationTracePoints = Bid.ApiGroup.Correlation;
internal class ActivityId
{
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/AdapterUtil.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/AdapterUtil.cs
index d067507056..0947158b5f 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/AdapterUtil.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/AdapterUtil.cs
@@ -96,15 +96,12 @@ static internal Task FalseTask
}
}
- [BidMethod] // this method accepts BID format as an argument, this attribute allows FXCopBid rule to validate calls to it
- static private void TraceException(
- string trace,
- [BidArgumentType(typeof(String))] Exception e)
+ static private void TraceException(string trace, Exception e)
{
Debug.Assert(null != e, "TraceException: null Exception");
if (null != e)
{
- Bid.Trace(trace, e.ToString()); // will include callstack if permission is available
+ SqlClientEventSource.Log.TraceEvent(trace, e.ToString()); // will include callstack if permission is available
}
}
@@ -115,12 +112,12 @@ static internal void TraceExceptionAsReturnValue(Exception e)
static internal void TraceExceptionForCapture(Exception e)
{
Debug.Assert(ADP.IsCatchableExceptionType(e), "Invalid exception type, should have been re-thrown!");
- TraceException(" '%ls'\n", e);
+ TraceException(" '{0}'", e);
}
static internal void TraceExceptionWithoutRethrow(Exception e)
{
Debug.Assert(ADP.IsCatchableExceptionType(e), "Invalid exception type, should have been re-thrown!");
- TraceException(" '%ls'\n", e);
+ TraceException(" '{0}'", e);
}
//
@@ -475,11 +472,12 @@ static internal ArgumentOutOfRangeException NotSupportedEnumerationValue(Type ty
static internal ArgumentOutOfRangeException InvalidAcceptRejectRule(AcceptRejectRule value)
{
#if DEBUG
- switch(value) {
- case AcceptRejectRule.None:
- case AcceptRejectRule.Cascade:
- Debug.Assert(false, "valid AcceptRejectRule " + value.ToString());
- break;
+ switch (value)
+ {
+ case AcceptRejectRule.None:
+ case AcceptRejectRule.Cascade:
+ Debug.Assert(false, "valid AcceptRejectRule " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(AcceptRejectRule), (int)value);
@@ -488,11 +486,12 @@ static internal ArgumentOutOfRangeException InvalidAcceptRejectRule(AcceptReject
static internal ArgumentOutOfRangeException InvalidCatalogLocation(CatalogLocation value)
{
#if DEBUG
- switch(value) {
- case CatalogLocation.Start:
- case CatalogLocation.End:
- Debug.Assert(false, "valid CatalogLocation " + value.ToString());
- break;
+ switch (value)
+ {
+ case CatalogLocation.Start:
+ case CatalogLocation.End:
+ Debug.Assert(false, "valid CatalogLocation " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(CatalogLocation), (int)value);
@@ -501,7 +500,8 @@ static internal ArgumentOutOfRangeException InvalidCatalogLocation(CatalogLocati
static internal ArgumentOutOfRangeException InvalidCommandBehavior(CommandBehavior value)
{
#if DEBUG
- if ((0 <= (int)value) && ((int)value <= 0x3F)) {
+ if ((0 <= (int)value) && ((int)value <= 0x3F))
+ {
Debug.Assert(false, "valid CommandType " + value.ToString());
}
#endif
@@ -528,12 +528,13 @@ static internal ArgumentException MustBeReadOnly(string argumentName)
static internal ArgumentOutOfRangeException InvalidCommandType(CommandType value)
{
#if DEBUG
- switch(value) {
- case CommandType.Text:
- case CommandType.StoredProcedure:
- case CommandType.TableDirect:
- Debug.Assert(false, "valid CommandType " + value.ToString());
- break;
+ switch (value)
+ {
+ case CommandType.Text:
+ case CommandType.StoredProcedure:
+ case CommandType.TableDirect:
+ Debug.Assert(false, "valid CommandType " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(CommandType), (int)value);
@@ -542,12 +543,13 @@ static internal ArgumentOutOfRangeException InvalidCommandType(CommandType value
static internal ArgumentOutOfRangeException InvalidConflictOptions(ConflictOption value)
{
#if DEBUG
- switch(value) {
- case ConflictOption.CompareAllSearchableValues:
- case ConflictOption.CompareRowVersion:
- case ConflictOption.OverwriteChanges:
- Debug.Assert(false, "valid ConflictOption " + value.ToString());
- break;
+ switch (value)
+ {
+ case ConflictOption.CompareAllSearchableValues:
+ case ConflictOption.CompareRowVersion:
+ case ConflictOption.OverwriteChanges:
+ Debug.Assert(false, "valid ConflictOption " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(ConflictOption), (int)value);
@@ -557,14 +559,15 @@ static internal ArgumentOutOfRangeException InvalidConflictOptions(ConflictOptio
static internal ArgumentOutOfRangeException InvalidDataRowState(DataRowState value)
{
#if DEBUG
- switch(value) {
- case DataRowState.Detached:
- case DataRowState.Unchanged:
- case DataRowState.Added:
- case DataRowState.Deleted:
- case DataRowState.Modified:
- Debug.Assert(false, "valid DataRowState " + value.ToString());
- break;
+ switch (value)
+ {
+ case DataRowState.Detached:
+ case DataRowState.Unchanged:
+ case DataRowState.Added:
+ case DataRowState.Deleted:
+ case DataRowState.Modified:
+ Debug.Assert(false, "valid DataRowState " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(DataRowState), (int)value);
@@ -574,13 +577,14 @@ static internal ArgumentOutOfRangeException InvalidDataRowState(DataRowState val
static internal ArgumentOutOfRangeException InvalidDataRowVersion(DataRowVersion value)
{
#if DEBUG
- switch(value) {
- case DataRowVersion.Default:
- case DataRowVersion.Current:
- case DataRowVersion.Original:
- case DataRowVersion.Proposed:
- Debug.Assert(false, "valid DataRowVersion " + value.ToString());
- break;
+ switch (value)
+ {
+ case DataRowVersion.Default:
+ case DataRowVersion.Current:
+ case DataRowVersion.Original:
+ case DataRowVersion.Proposed:
+ Debug.Assert(false, "valid DataRowVersion " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(DataRowVersion), (int)value);
@@ -590,16 +594,17 @@ static internal ArgumentOutOfRangeException InvalidDataRowVersion(DataRowVersion
static internal ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value)
{
#if DEBUG
- switch(value) {
- case IsolationLevel.Unspecified:
- case IsolationLevel.Chaos:
- case IsolationLevel.ReadUncommitted:
- case IsolationLevel.ReadCommitted:
- case IsolationLevel.RepeatableRead:
- case IsolationLevel.Serializable:
- case IsolationLevel.Snapshot:
- Debug.Assert(false, "valid IsolationLevel " + value.ToString());
- break;
+ switch (value)
+ {
+ case IsolationLevel.Unspecified:
+ case IsolationLevel.Chaos:
+ case IsolationLevel.ReadUncommitted:
+ case IsolationLevel.ReadCommitted:
+ case IsolationLevel.RepeatableRead:
+ case IsolationLevel.Serializable:
+ case IsolationLevel.Snapshot:
+ Debug.Assert(false, "valid IsolationLevel " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(IsolationLevel), (int)value);
@@ -609,11 +614,12 @@ static internal ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel
static internal ArgumentOutOfRangeException InvalidKeyRestrictionBehavior(KeyRestrictionBehavior value)
{
#if DEBUG
- switch(value) {
- case KeyRestrictionBehavior.PreventUsage:
- case KeyRestrictionBehavior.AllowOnly:
- Debug.Assert(false, "valid KeyRestrictionBehavior " + value.ToString());
- break;
+ switch (value)
+ {
+ case KeyRestrictionBehavior.PreventUsage:
+ case KeyRestrictionBehavior.AllowOnly:
+ Debug.Assert(false, "valid KeyRestrictionBehavior " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(KeyRestrictionBehavior), (int)value);
@@ -623,12 +629,13 @@ static internal ArgumentOutOfRangeException InvalidKeyRestrictionBehavior(KeyRes
static internal ArgumentOutOfRangeException InvalidLoadOption(LoadOption value)
{
#if DEBUG
- switch(value) {
- case LoadOption.OverwriteChanges:
- case LoadOption.PreserveChanges:
- case LoadOption.Upsert:
- Debug.Assert(false, "valid LoadOption " + value.ToString());
- break;
+ switch (value)
+ {
+ case LoadOption.OverwriteChanges:
+ case LoadOption.PreserveChanges:
+ case LoadOption.Upsert:
+ Debug.Assert(false, "valid LoadOption " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(LoadOption), (int)value);
@@ -638,12 +645,13 @@ static internal ArgumentOutOfRangeException InvalidLoadOption(LoadOption value)
static internal ArgumentOutOfRangeException InvalidMissingMappingAction(MissingMappingAction value)
{
#if DEBUG
- switch(value) {
- case MissingMappingAction.Passthrough:
- case MissingMappingAction.Ignore:
- case MissingMappingAction.Error:
- Debug.Assert(false, "valid MissingMappingAction " + value.ToString());
- break;
+ switch (value)
+ {
+ case MissingMappingAction.Passthrough:
+ case MissingMappingAction.Ignore:
+ case MissingMappingAction.Error:
+ Debug.Assert(false, "valid MissingMappingAction " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(MissingMappingAction), (int)value);
@@ -653,13 +661,14 @@ static internal ArgumentOutOfRangeException InvalidMissingMappingAction(MissingM
static internal ArgumentOutOfRangeException InvalidMissingSchemaAction(MissingSchemaAction value)
{
#if DEBUG
- switch(value) {
- case MissingSchemaAction.Add:
- case MissingSchemaAction.Ignore:
- case MissingSchemaAction.Error:
- case MissingSchemaAction.AddWithKey:
- Debug.Assert(false, "valid MissingSchemaAction " + value.ToString());
- break;
+ switch (value)
+ {
+ case MissingSchemaAction.Add:
+ case MissingSchemaAction.Ignore:
+ case MissingSchemaAction.Error:
+ case MissingSchemaAction.AddWithKey:
+ Debug.Assert(false, "valid MissingSchemaAction " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(MissingSchemaAction), (int)value);
@@ -669,13 +678,14 @@ static internal ArgumentOutOfRangeException InvalidMissingSchemaAction(MissingSc
static internal ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value)
{
#if DEBUG
- switch(value) {
- case ParameterDirection.Input:
- case ParameterDirection.Output:
- case ParameterDirection.InputOutput:
- case ParameterDirection.ReturnValue:
- Debug.Assert(false, "valid ParameterDirection " + value.ToString());
- break;
+ switch (value)
+ {
+ case ParameterDirection.Input:
+ case ParameterDirection.Output:
+ case ParameterDirection.InputOutput:
+ case ParameterDirection.ReturnValue:
+ Debug.Assert(false, "valid ParameterDirection " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(ParameterDirection), (int)value);
@@ -684,11 +694,12 @@ static internal ArgumentOutOfRangeException InvalidParameterDirection(ParameterD
static internal ArgumentOutOfRangeException InvalidPermissionState(PermissionState value)
{
#if DEBUG
- switch(value) {
- case PermissionState.Unrestricted:
- case PermissionState.None:
- Debug.Assert(false, "valid PermissionState " + value.ToString());
- break;
+ switch (value)
+ {
+ case PermissionState.Unrestricted:
+ case PermissionState.None:
+ Debug.Assert(false, "valid PermissionState " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(PermissionState), (int)value);
@@ -697,13 +708,14 @@ static internal ArgumentOutOfRangeException InvalidPermissionState(PermissionSta
static internal ArgumentOutOfRangeException InvalidRule(Rule value)
{
#if DEBUG
- switch(value) {
- case Rule.None:
- case Rule.Cascade:
- case Rule.SetNull:
- case Rule.SetDefault:
- Debug.Assert(false, "valid Rule " + value.ToString());
- break;
+ switch (value)
+ {
+ case Rule.None:
+ case Rule.Cascade:
+ case Rule.SetNull:
+ case Rule.SetDefault:
+ Debug.Assert(false, "valid Rule " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(Rule), (int)value);
@@ -713,11 +725,12 @@ static internal ArgumentOutOfRangeException InvalidRule(Rule value)
static internal ArgumentOutOfRangeException InvalidSchemaType(SchemaType value)
{
#if DEBUG
- switch(value) {
- case SchemaType.Source:
- case SchemaType.Mapped:
- Debug.Assert(false, "valid SchemaType " + value.ToString());
- break;
+ switch (value)
+ {
+ case SchemaType.Source:
+ case SchemaType.Mapped:
+ Debug.Assert(false, "valid SchemaType " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(SchemaType), (int)value);
@@ -727,14 +740,15 @@ static internal ArgumentOutOfRangeException InvalidSchemaType(SchemaType value)
static internal ArgumentOutOfRangeException InvalidStatementType(StatementType value)
{
#if DEBUG
- switch(value) {
- case StatementType.Select:
- case StatementType.Insert:
- case StatementType.Update:
- case StatementType.Delete:
- case StatementType.Batch:
- Debug.Assert(false, "valid StatementType " + value.ToString());
- break;
+ switch (value)
+ {
+ case StatementType.Select:
+ case StatementType.Insert:
+ case StatementType.Update:
+ case StatementType.Delete:
+ case StatementType.Batch:
+ Debug.Assert(false, "valid StatementType " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(StatementType), (int)value);
@@ -744,13 +758,14 @@ static internal ArgumentOutOfRangeException InvalidStatementType(StatementType v
static internal ArgumentOutOfRangeException InvalidUpdateRowSource(UpdateRowSource value)
{
#if DEBUG
- switch(value) {
- case UpdateRowSource.None:
- case UpdateRowSource.OutputParameters:
- case UpdateRowSource.FirstReturnedRecord:
- case UpdateRowSource.Both:
- Debug.Assert(false, "valid UpdateRowSource " + value.ToString());
- break;
+ switch (value)
+ {
+ case UpdateRowSource.None:
+ case UpdateRowSource.OutputParameters:
+ case UpdateRowSource.FirstReturnedRecord:
+ case UpdateRowSource.Both:
+ Debug.Assert(false, "valid UpdateRowSource " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(UpdateRowSource), (int)value);
@@ -760,13 +775,14 @@ static internal ArgumentOutOfRangeException InvalidUpdateRowSource(UpdateRowSour
static internal ArgumentOutOfRangeException InvalidUpdateStatus(UpdateStatus value)
{
#if DEBUG
- switch(value) {
- case UpdateStatus.Continue:
- case UpdateStatus.ErrorsOccurred:
- case UpdateStatus.SkipAllRemainingRows:
- case UpdateStatus.SkipCurrentRow:
- Debug.Assert(false, "valid UpdateStatus " + value.ToString());
- break;
+ switch (value)
+ {
+ case UpdateStatus.Continue:
+ case UpdateStatus.ErrorsOccurred:
+ case UpdateStatus.SkipAllRemainingRows:
+ case UpdateStatus.SkipCurrentRow:
+ Debug.Assert(false, "valid UpdateStatus " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(UpdateStatus), (int)value);
@@ -785,12 +801,13 @@ static internal ArgumentOutOfRangeException NotSupportedStatementType(StatementT
static internal ArgumentOutOfRangeException InvalidUserDefinedTypeSerializationFormat(Format value)
{
#if DEBUG
- switch(value) {
- case Format.Unknown:
- case Format.Native:
- case Format.UserDefined:
- Debug.Assert(false, "valid UserDefinedTypeSerializationFormat " + value.ToString());
- break;
+ switch (value)
+ {
+ case Format.Unknown:
+ case Format.Native:
+ case Format.UserDefined:
+ Debug.Assert(false, "valid UserDefinedTypeSerializationFormat " + value.ToString());
+ break;
}
#endif
return InvalidEnumerationValue(typeof(Format), (int)value);
@@ -1301,9 +1318,9 @@ static internal InvalidOperationException UpdateConnectionRequired(StatementType
resource = Strings.ADP_ConnectionRequired_Batch;
goto default;
#if DEBUG
- case StatementType.Select:
- Debug.Assert(false, "shouldn't be here");
- goto default;
+ case StatementType.Select:
+ Debug.Assert(false, "shouldn't be here");
+ goto default;
#endif
default:
throw ADP.InvalidStatementType(statementType);
@@ -1316,16 +1333,17 @@ static internal InvalidOperationException ConnectionRequired_Res(string method)
{
string resource = "ADP_ConnectionRequired_" + method;
#if DEBUG
- switch(resource) {
- case StringsHelper.ResourceNames.ADP_ConnectionRequired_Fill:
- case StringsHelper.ResourceNames.ADP_ConnectionRequired_FillPage:
- case StringsHelper.ResourceNames.ADP_ConnectionRequired_FillSchema:
- case StringsHelper.ResourceNames.ADP_ConnectionRequired_Update:
- case StringsHelper.ResourceNames.ADP_ConnecitonRequired_UpdateRows:
- break;
- default:
- Debug.Assert(false, "missing resource string: " + resource);
- break;
+ switch (resource)
+ {
+ case StringsHelper.ResourceNames.ADP_ConnectionRequired_Fill:
+ case StringsHelper.ResourceNames.ADP_ConnectionRequired_FillPage:
+ case StringsHelper.ResourceNames.ADP_ConnectionRequired_FillSchema:
+ case StringsHelper.ResourceNames.ADP_ConnectionRequired_Update:
+ case StringsHelper.ResourceNames.ADP_ConnecitonRequired_UpdateRows:
+ break;
+ default:
+ Debug.Assert(false, "missing resource string: " + resource);
+ break;
}
#endif
return InvalidOperation(StringsHelper.GetString(resource));
@@ -1351,12 +1369,12 @@ static internal InvalidOperationException UpdateOpenConnectionRequired(Statement
resource = Strings.ADP_OpenConnectionRequired_Delete;
break;
#if DEBUG
- case StatementType.Select:
- Debug.Assert(false, "shouldn't be here");
- goto default;
- case StatementType.Batch:
- Debug.Assert(false, "isRowUpdatingCommand should have been true");
- goto default;
+ case StatementType.Select:
+ Debug.Assert(false, "shouldn't be here");
+ goto default;
+ case StatementType.Batch:
+ Debug.Assert(false, "isRowUpdatingCommand should have been true");
+ goto default;
#endif
default:
throw ADP.InvalidStatementType(statementType);
@@ -1519,10 +1537,10 @@ static internal Exception UpdateConcurrencyViolation(StatementType statementType
resource = Strings.ADP_UpdateConcurrencyViolation_Batch;
break;
#if DEBUG
- case StatementType.Select:
- case StatementType.Insert:
- Debug.Assert(false, "should be here");
- goto default;
+ case StatementType.Select:
+ case StatementType.Insert:
+ Debug.Assert(false, "should be here");
+ goto default;
#endif
default:
throw ADP.InvalidStatementType(statementType);
@@ -1556,9 +1574,9 @@ static internal InvalidOperationException UpdateRequiresCommand(StatementType st
resource = Strings.ADP_UpdateRequiresCommandDelete;
break;
#if DEBUG
- case StatementType.Batch:
- Debug.Assert(false, "isRowUpdatingCommand should have been true");
- goto default;
+ case StatementType.Batch:
+ Debug.Assert(false, "isRowUpdatingCommand should have been true");
+ goto default;
#endif
default:
throw ADP.InvalidStatementType(statementType);
@@ -2929,15 +2947,17 @@ static internal bool IsDirection(IDataParameter value, ParameterDirection condit
return (condition == (condition & value.Direction));
}
#if DEBUG
- static private void IsDirectionValid(ParameterDirection value) {
- switch (value) { // @perfnote: Enum.IsDefined
- case ParameterDirection.Input:
- case ParameterDirection.Output:
- case ParameterDirection.InputOutput:
- case ParameterDirection.ReturnValue:
- break;
- default:
- throw ADP.InvalidParameterDirection(value);
+ static private void IsDirectionValid(ParameterDirection value)
+ {
+ switch (value)
+ { // @perfnote: Enum.IsDefined
+ case ParameterDirection.Input:
+ case ParameterDirection.Output:
+ case ParameterDirection.InputOutput:
+ case ParameterDirection.ReturnValue:
+ break;
+ default:
+ throw ADP.InvalidParameterDirection(value);
}
}
#endif
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 2f502a12ef..df45de05c9 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
@@ -12,6 +12,7 @@ namespace Microsoft.Data.Common
using System.Diagnostics;
using System.Linq;
using System.Text;
+ using Microsoft.Data.SqlClient;
[Serializable] // MDAC 83147
internal sealed class DBConnectionString
@@ -175,7 +176,8 @@ internal string Restrictions
builder.Append("=;");
}
#if DEBUG
- else {
+ else
+ {
Debug.Assert(false, "empty restriction");
}
#endif
@@ -468,9 +470,7 @@ static private string[] NoDuplicateUnion(string[] a, string[] b)
private static string[] ParseRestrictions(string restrictions, Hashtable synonyms)
{
#if DEBUG
- if (Bid.AdvancedOn) {
- Bid.Trace(" Restrictions='%ls'\n", restrictions);
- }
+ SqlClientEventSource.Log.AdvanceTrace(" Restrictions='{0}'", restrictions);
#endif
List restrictionValues = new List();
StringBuilder buffer = new StringBuilder(restrictions.Length);
@@ -486,9 +486,7 @@ private static string[] ParseRestrictions(string restrictions, Hashtable synonym
if (!ADP.IsEmpty(keyname))
{
#if DEBUG
- if (Bid.AdvancedOn) {
- Bid.Trace(" KeyName='%ls'\n", keyname);
- }
+ SqlClientEventSource.Log.AdvanceTrace(" 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 f446add866..62510f14ab 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
@@ -12,6 +12,7 @@ namespace Microsoft.Data.Common
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
+ using Microsoft.Data.SqlClient;
internal class DbConnectionOptions
{
@@ -39,13 +40,13 @@ internal class DbConnectionOptions
+ "(?([^=\\s\\p{Cc}]|\\s+[^=\\s\\p{Cc}]|\\s+==|==)+)" // allow any visible character for keyname except '=' which must quoted as '=='
+ "\\s*=(?!=)\\s*" // the equal sign divides the key and value parts
+ "(?"
- + "(\"([^\"\u0000]|\"\")*\")" // double quoted string, " must be quoted as ""
- + "|"
- + "('([^'\u0000]|'')*')" // single quoted string, ' must be quoted as ''
- + "|"
- + "((?![\"'\\s])" // unquoted value must not start with " or ' or space, would also like = but too late to change
- + "([^;\\s\\p{Cc}]|\\s+[^;\\s\\p{Cc}])*" // control characters must be quoted
- + "(?([^=\\s\\p{Cc}]|\\s+[^=\\s\\p{Cc}])+)" // allow any visible character for keyname except '='
+ "\\s*=\\s*" // the equal sign divides the key and value parts
+ "(?"
- + "(\\{([^\\}\u0000]|\\}\\})*\\})" // quoted string, starts with { and ends with }
- + "|"
- + "((?![\\{\\s])" // unquoted value must not start with { or space, would also like = but too late to change
- + "([^;\\s\\p{Cc}]|\\s+[^;\\s\\p{Cc}])*" // control characters must be quoted
+ + "(\\{([^\\}\u0000]|\\}\\})*\\})" // quoted string, starts with { and ends with }
+ + "|"
+ + "((?![\\{\\s])" // unquoted value must not start with { or space, would also like = but too late to change
+ + "([^;\\s\\p{Cc}]|\\s+[^;\\s\\p{Cc}])*" // control characters must be quoted
- + ")" // VSTFDEVDIV 94761: although the spec does not allow {}
- // embedded within a value, the retail code does.
- // + "(? KeyName='%ls', KeyValue='%ls'\n", keyname, keyvalue);
+
+ if ((KEY.Password != realkeyname) && (SYNONYM.Pwd != realkeyname))
+ {
+ // don't trace passwords ever!
+ if (null != keyvalue)
+ {
+ SqlClientEventSource.Log.AdvanceTrace(" KeyName='{0}', KeyValue='{1}'", keyname, keyvalue);
}
- else {
- Bid.Trace(" KeyName='%ls'\n", keyname);
+ else
+ {
+ SqlClientEventSource.Log.AdvanceTrace(" KeyName='{0}'", keyname);
}
}
}
@@ -918,7 +925,8 @@ static private bool IsKeyNameValid(string keyname)
}
#if DEBUG
- private static Hashtable SplitConnectionString(string connectionString, Hashtable synonyms, bool firstKey) {
+ private static Hashtable SplitConnectionString(string connectionString, Hashtable synonyms, bool firstKey)
+ {
Hashtable parsetable = new Hashtable();
Regex parser = (firstKey ? ConnectionStringRegexOdbc : ConnectionStringRegex);
@@ -926,61 +934,75 @@ private static Hashtable SplitConnectionString(string connectionString, Hashtabl
Debug.Assert(KeyIndex == parser.GroupNumberFromName("key"), "wrong key index");
Debug.Assert(ValueIndex == parser.GroupNumberFromName("value"), "wrong value index");
- if (null != connectionString) {
+ if (null != connectionString)
+ {
Match match = parser.Match(connectionString);
- if (!match.Success || (match.Length != connectionString.Length)) {
+ if (!match.Success || (match.Length != connectionString.Length))
+ {
throw ADP.ConnectionStringSyntax(match.Length);
}
int indexValue = 0;
CaptureCollection keyvalues = match.Groups[ValueIndex].Captures;
- foreach(Capture keypair in match.Groups[KeyIndex].Captures) {
+ foreach (Capture keypair in match.Groups[KeyIndex].Captures)
+ {
string keyname = (firstKey ? keypair.Value : keypair.Value.Replace("==", "=")).ToLower(CultureInfo.InvariantCulture);
string keyvalue = keyvalues[indexValue++].Value;
- if (0 < keyvalue.Length) {
- if (!firstKey) {
- switch(keyvalue[0]) {
- case '\"':
- keyvalue = keyvalue.Substring(1, keyvalue.Length-2).Replace("\"\"", "\"");
- break;
- case '\'':
- keyvalue = keyvalue.Substring(1, keyvalue.Length-2).Replace("\'\'", "\'");
- break;
- default:
- break;
+ if (0 < keyvalue.Length)
+ {
+ if (!firstKey)
+ {
+ switch (keyvalue[0])
+ {
+ case '\"':
+ keyvalue = keyvalue.Substring(1, keyvalue.Length - 2).Replace("\"\"", "\"");
+ break;
+ case '\'':
+ keyvalue = keyvalue.Substring(1, keyvalue.Length - 2).Replace("\'\'", "\'");
+ break;
+ default:
+ break;
}
}
}
- else {
+ else
+ {
keyvalue = null;
}
DebugTraceKeyValuePair(keyname, keyvalue, synonyms);
string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname);
- if (!IsKeyNameValid(realkeyname)) {
+ if (!IsKeyNameValid(realkeyname))
+ {
throw ADP.KeywordNotSupported(keyname);
}
- if (!firstKey || !parsetable.ContainsKey(realkeyname)) {
- parsetable[realkeyname] = keyvalue; // last key-value pair wins (or first)
+ if (!firstKey || !parsetable.ContainsKey(realkeyname))
+ {
+ parsetable[realkeyname] = keyvalue; // last key-value pair wins (or first)
}
}
}
return parsetable;
}
- private static void ParseComparison(Hashtable parsetable, string connectionString, Hashtable synonyms, bool firstKey, Exception e) {
- try {
+ private static void ParseComparison(Hashtable parsetable, string connectionString, Hashtable synonyms, bool firstKey, Exception e)
+ {
+ try
+ {
Hashtable parsedvalues = SplitConnectionString(connectionString, synonyms, firstKey);
- foreach(DictionaryEntry entry in parsedvalues) {
- string keyname = (string) entry.Key;
- string value1 = (string) entry.Value;
- string value2 = (string) parsetable[keyname];
+ foreach (DictionaryEntry entry in parsedvalues)
+ {
+ string keyname = (string)entry.Key;
+ string value1 = (string)entry.Value;
+ string value2 = (string)parsetable[keyname];
Debug.Assert(parsetable.Contains(keyname), "ParseInternal code vs. regex mismatch keyname <" + keyname + ">");
- Debug.Assert(value1 == value2, "ParseInternal code vs. regex mismatch keyvalue <" + value1 + "> <" + value2 +">");
+ Debug.Assert(value1 == value2, "ParseInternal code vs. regex mismatch keyvalue <" + value1 + "> <" + value2 + ">");
}
}
- catch(ArgumentException f) {
- if (null != e) {
+ catch (ArgumentException f)
+ {
+ if (null != e)
+ {
string msg1 = e.Message;
string msg2 = f.Message;
@@ -991,20 +1013,24 @@ private static void ParseComparison(Hashtable parsetable, string connectionStrin
{
// VSTFDEVDIV 479587: we also accept cases were Regex parser (debug only) reports "wrong format" and
// retail parsing code reports format exception in different location or "keyword not supported"
- if (msg2.StartsWith(WrongFormatMessagePrefix, StringComparison.Ordinal)) {
- if (msg1.StartsWith(KeywordNotSupportedMessagePrefix, StringComparison.Ordinal) || msg1.StartsWith(WrongFormatMessagePrefix, StringComparison.Ordinal)) {
+ if (msg2.StartsWith(WrongFormatMessagePrefix, StringComparison.Ordinal))
+ {
+ if (msg1.StartsWith(KeywordNotSupportedMessagePrefix, StringComparison.Ordinal) || msg1.StartsWith(WrongFormatMessagePrefix, StringComparison.Ordinal))
+ {
isEquivalent = true;
}
}
}
- Debug.Assert(isEquivalent, "ParseInternal code vs regex message mismatch: <"+msg1+"> <"+msg2+">");
+ Debug.Assert(isEquivalent, "ParseInternal code vs regex message mismatch: <" + msg1 + "> <" + msg2 + ">");
}
- else {
+ else
+ {
Debug.Assert(false, "ParseInternal code vs regex throw mismatch " + f.Message);
}
e = null;
}
- if (null != e) {
+ if (null != e)
+ {
Debug.Assert(false, "ParseInternal code threw exception vs regex mismatch");
}
}
@@ -1015,49 +1041,51 @@ private static NameValuePair ParseInternal(Hashtable parsetable, string connecti
StringBuilder buffer = new StringBuilder();
NameValuePair localKeychain = null, keychain = null;
#if DEBUG
- try {
-#endif
- int nextStartPosition = 0;
- int endPosition = connectionString.Length;
- while (nextStartPosition < endPosition)
+ try
{
- int startPosition = nextStartPosition;
-
- string keyname, keyvalue;
- nextStartPosition = GetKeyValuePair(connectionString, startPosition, buffer, firstKey, out keyname, out keyvalue);
- if (ADP.IsEmpty(keyname))
+#endif
+ int nextStartPosition = 0;
+ int endPosition = connectionString.Length;
+ while (nextStartPosition < endPosition)
{
- // if (nextStartPosition != endPosition) { throw; }
- break;
- }
+ int startPosition = nextStartPosition;
+
+ string keyname, keyvalue;
+ nextStartPosition = GetKeyValuePair(connectionString, startPosition, buffer, firstKey, out keyname, out keyvalue);
+ if (ADP.IsEmpty(keyname))
+ {
+ // if (nextStartPosition != endPosition) { throw; }
+ break;
+ }
#if DEBUG
DebugTraceKeyValuePair(keyname, keyvalue, synonyms);
Debug.Assert(IsKeyNameValid(keyname), "ParseFailure, invalid keyname");
Debug.Assert(IsValueValidInternal(keyvalue), "parse failure, invalid keyvalue");
#endif
- string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname);
- if (!IsKeyNameValid(realkeyname))
- {
- throw ADP.KeywordNotSupported(keyname);
- }
- if (!firstKey || !parsetable.Contains(realkeyname))
- {
- parsetable[realkeyname] = keyvalue; // last key-value pair wins (or first)
- }
+ string realkeyname = ((null != synonyms) ? (string)synonyms[keyname] : keyname);
+ if (!IsKeyNameValid(realkeyname))
+ {
+ throw ADP.KeywordNotSupported(keyname);
+ }
+ if (!firstKey || !parsetable.Contains(realkeyname))
+ {
+ parsetable[realkeyname] = keyvalue; // last key-value pair wins (or first)
+ }
- if (null != localKeychain)
- {
- localKeychain = localKeychain.Next = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition);
- }
- else if (buildChain)
- { // first time only - don't contain modified chain from UDL file
- keychain = localKeychain = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition);
+ if (null != localKeychain)
+ {
+ localKeychain = localKeychain.Next = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition);
+ }
+ else if (buildChain)
+ { // first time only - don't contain modified chain from UDL file
+ keychain = localKeychain = new NameValuePair(realkeyname, keyvalue, nextStartPosition - startPosition);
+ }
}
- }
#if DEBUG
}
- catch(ArgumentException e) {
+ catch (ArgumentException e)
+ {
ParseComparison(parsetable, connectionString, synonyms, firstKey, e);
throw;
}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/System.Data_BID.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/System.Data_BID.cs
deleted file mode 100644
index e3a9e7f4ac..0000000000
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/Common/System.Data_BID.cs
+++ /dev/null
@@ -1,308 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-
-internal static partial class Bid
-{
- internal static void PoolerTrace(string fmtPrintfW, System.Int32 a1)
- {
- }
-
- internal static void PoolerTrace(string fmtPrintfW, System.Int32 a1, System.Int32 a2)
- {
- }
-
- internal static void PoolerTrace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int32 a3)
- {
- }
-
- internal static void PoolerTrace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4)
- {
- }
-
- internal static void PoolerTrace(
- string fmtPrintfW,
- System.Int32 a1,
- [BidArgumentType(typeof(String))] System.Exception a2)
- {
- }
-
- internal static void PoolerScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1)
- {
- hScp = NoData;
- }
-
- internal static void NotificationsScopeEnter(out IntPtr hScp, string fmtPrintfW, string fmtPrintfW2)
- {
- hScp = NoData;
- }
-
- internal static void NotificationsScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1)
- {
- hScp = NoData;
- }
-
- internal static void NotificationsScopeEnter(out IntPtr hScp, string fmtPrintfW, string fmtPrintfW2, string fmtPrintfW3)
- {
- hScp = NoData;
- }
-
- internal static void NotificationsScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, string fmtPrintfW2)
- {
- hScp = NoData;
- }
-
- internal static void NotificationsScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.Int32 a2)
- {
- hScp = NoData;
- }
-
- internal static void NotificationsScopeEnter(out IntPtr hScp, string fmtPrintfW, string fmtPrintfW2, string fmtPrintfW3, string fmtPrintfW4)
- {
- hScp = NoData;
- }
-
- internal static void NotificationsScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, string fmtPrintfW2, System.Int32 a2)
- {
- hScp = NoData;
- }
-
- internal static void NotificationsScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, string fmtPrintfW2, string fmtPrintfW3, System.Int32 a4)
- {
- hScp = NoData;
- }
-
- internal static void NotificationsTrace(string fmtPrintfW)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, string fmtPrintfW2)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, System.Int32 a1)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, System.Boolean a1)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, string fmtPrintfW2, System.Int32 a1)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, System.Int32 a1, string fmtPrintfW2)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, System.Int32 a1, System.Int32 a2)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, System.Int32 a1, System.Boolean a2)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, System.String a1, System.String a2)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, string fmtPrintfW2, string fmtPrintfW3, System.Int32 a1)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, System.Boolean a1, string fmtPrintfW2, string fmtPrintfW3, string fmtPrintfW4)
- {
- }
-
- internal static void NotificationsTrace(string fmtPrintfW, System.Int32 a1, string fmtPrintfW2, string fmtPrintfW3, string fmtPrintfW4)
- {
- }
-
- internal static void CorrelationTrace(string fmtPrintfW, System.Int32 a1)
- {
- }
-
- internal static void CorrelationTrace(string fmtPrintfW)
- {
- }
-
- internal static void CorrelationTrace(string fmtPrintfW, System.Int32 a1, System.Int32 a2)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.String a1, System.String a2)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.String a2, System.Boolean a3)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.String a3, System.String a4, System.Int32 a5)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int64 a3, System.UInt32 a4, System.Int32 a5, System.UInt32 a6, System.UInt32 a7)
- {
- }
-
- internal static void ScopeEnter(
- out IntPtr hScp,
- string fmtPrintfW,
- System.Int32 a1,
- [BidArgumentType(typeof(String))] System.Guid a2)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.String a2, System.Int32 a3)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.Boolean a2, System.Int32 a3)
- {
- hScp = NoData;
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.String a2)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.IntPtr a1)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.IntPtr a2, System.IntPtr a3)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.IntPtr a2)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.String a2, System.String a3)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.String a2, System.Int32 a3)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.String a2, System.String a3, System.Int32 a4)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int32 a3, System.String a4, System.String a5, System.Int32 a6)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int32 a3)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Boolean a2)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Boolean a3)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.Int32 a5, System.Int32 a6, System.Int32 a7)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.String a2, System.Int32 a3, System.Int32 a4, System.Boolean a5)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int64 a2)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int64 a3)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.String a2, System.String a3, System.String a4, System.Int32 a5, System.Int64 a6)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int64 a2, System.Int32 a3, System.Int32 a4)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int64 a3, System.Int32 a4)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int32 a3, System.Int32 a4, System.String a5, System.String a6, System.String a7, System.Int32 a8)
- {
- }
-
- internal static void Trace(string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.String a3, System.String a4)
- {
- }
-
-
- //
- // ScopeEnter overloads
- //
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.String a2)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.Boolean a2)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.String a3)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.String a2, System.Boolean a3)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Boolean a3)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int32 a3, System.String a4)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Int32 a3)
- {
- hScp = NoData;
- }
-
- internal static void ScopeEnter(out IntPtr hScp, string fmtPrintfW, System.Int32 a1, System.Int32 a2, System.Boolean a3, System.Int32 a4)
- {
- hScp = NoData;
- }
-} // Bid
-
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 2340a7c2e2..059d0acc6f 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/DataException.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/DataException.cs
@@ -7,10 +7,10 @@
using System.Data;
using System.Diagnostics;
using System.Globalization;
+using Microsoft.Data.SqlClient;
namespace Microsoft.Data
{
-
internal static class ExceptionBuilder
{
// The class defines the exceptions that are specific to the DataSet.
@@ -22,41 +22,35 @@ internal static class ExceptionBuilder
// The resource Data.txt will ensure proper string text based on the appropriate
// locale.
- [BidMethod] // this method accepts BID format as an argument, this attribute allows FXCopBid rule to validate calls to it
static private void TraceException(
- string trace,
- [BidArgumentType(typeof(String))] Exception e)
+ string trace, Exception e)
{
Debug.Assert(null != e, "TraceException: null Exception");
if (null != e)
{
- Bid.Trace(trace, e.Message);
- if (Bid.AdvancedOn)
+ SqlClientEventSource.Log.AdvanceTrace(trace, e.Message);
+ try
+ {
+ SqlClientEventSource.Log.AdvanceTrace(" Environment StackTrace = '{0}'", Environment.StackTrace);
+ }
+ catch (System.Security.SecurityException)
{
- try
- {
- Bid.Trace(", StackTrace='%ls'", Environment.StackTrace);
- }
- catch (System.Security.SecurityException)
- {
- // if you don't have permission - you don't get the stack trace
- }
+ // if you don't have permission - you don't get the stack trace
}
- Bid.Trace("\n");
}
}
static internal void TraceExceptionAsReturnValue(Exception e)
{
- TraceException(" Message='%ls'", e);
+ TraceException(" Message='{0}'", e);
}
static internal void TraceExceptionForCapture(Exception e)
{
- TraceException(" Message='%ls'", e);
+ TraceException(" Message = {0}", e);
}
static internal void TraceExceptionWithoutRethrow(Exception e)
{
- TraceException(" Message='%ls'", e);
+ TraceException(" Message = '{0}'", e);
}
//
@@ -218,7 +212,6 @@ static public Exception ArgumentContainsNull(string paramName)
return _Argument(paramName, StringsHelper.GetString(Strings.Data_ArgumentContainsNull, paramName));
}
-
//
// Collections
//
@@ -899,7 +892,6 @@ static public Exception InValidNestedRelation(string childTableName)
return _InvalidOperation(StringsHelper.GetString(Strings.DataRelation_InValidNestedRelation, childTableName));
}
-
static public Exception InvalidParentNamespaceinNestedRelation(string childTableName)
{
return _InvalidOperation(StringsHelper.GetString(Strings.DataRelation_InValidNamespaceInNestedRelation, childTableName));
@@ -1168,11 +1160,12 @@ static public Exception InvalidSchemaSerializationMode(Type enumType, string mod
static public Exception InvalidRemotingFormat(SerializationFormat mode)
{
#if DEBUG
- switch(mode) {
- case SerializationFormat.Xml:
- case SerializationFormat.Binary:
- Debug.Assert(false, "valid SerializationFormat " + mode.ToString());
- break;
+ switch (mode)
+ {
+ case SerializationFormat.Xml:
+ case SerializationFormat.Binary:
+ Debug.Assert(false, "valid SerializationFormat " + mode.ToString());
+ break;
}
#endif
return _InvalidEnumArgumentException(mode);
@@ -1296,7 +1289,6 @@ static public Exception StorageSetFailed()
return _Argument(StringsHelper.GetString(Strings.DataStorage_SetInvalidDataType));
}
-
//
// XML schema
//
@@ -1450,7 +1442,6 @@ static public Exception PolymorphismNotSupported(string typeName)
return _InvalidOperation(StringsHelper.GetString(Strings.Xml_PolymorphismNotSupported, typeName));
}
-
static public Exception DataTableInferenceNotSupported()
{
return _InvalidOperation(StringsHelper.GetString(Strings.Xml_DataTableInferenceNotSupported));
@@ -1528,7 +1519,6 @@ static public Exception EmptyDataTableReader(string tableName)
return _DeletedRowInaccessible(StringsHelper.GetString(Strings.DataTableReader_DataTableCleared, tableName));
}
-
//
static internal Exception InvalidDuplicateNamedSimpleTypeDelaration(string stName, string errorStr)
{
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DataReaderContainer.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DataReaderContainer.cs
index 7ad9077248..d80e3db2d1 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DataReaderContainer.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DataReaderContainer.cs
@@ -4,7 +4,6 @@
namespace Microsoft.Data.ProviderBase
{
-
using System;
using System.Data;
using System.Data.Common;
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbBuffer.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbBuffer.cs
index 4c85388f56..30a3bc7b99 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbBuffer.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbBuffer.cs
@@ -14,7 +14,6 @@ namespace Microsoft.Data.ProviderBase
// so that when debugging, we can tell the difference between one DbBuffer and another
internal abstract class DbBuffer : SafeHandle
{
-
internal const int LMEM_FIXED = 0x0000;
internal const int LMEM_MOVEABLE = 0x0002;
internal const int LMEM_ZEROINIT = 0x0040;
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs
index 3cc0501354..ad48b3fa30 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/ProviderBase/DbConnectionClosed.cs
@@ -13,7 +13,6 @@ namespace Microsoft.Data.ProviderBase
abstract internal class DbConnectionClosed : DbConnectionInternal
{
-
// Construct an "empty" connection
protected DbConnectionClosed(ConnectionState state, bool hidePassword, bool allowSetConnectionString) : base(state, hidePassword, allowSetConnectionString)
{
@@ -167,7 +166,6 @@ private DbConnectionClosedNeverOpened() : base(ConnectionState.Closed, false, tr
sealed internal class DbConnectionClosedPreviouslyOpened : DbConnectionClosed
{
// Closed Connection, Has Previously Been Opened
-
internal static readonly DbConnectionInternal SingletonInstance = new DbConnectionClosedPreviouslyOpened(); // singleton object
private DbConnectionClosedPreviouslyOpened() : base(ConnectionState.Closed, true, true)
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 53de68caf1..75df4299ec 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
@@ -4,7 +4,6 @@
namespace Microsoft.Data.ProviderBase
{
-
using System;
using System.Collections.Generic;
using System.Data;
@@ -13,6 +12,7 @@ namespace Microsoft.Data.ProviderBase
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.Common;
+ using Microsoft.Data.SqlClient;
internal abstract class DbConnectionFactory
{
@@ -65,8 +65,7 @@ internal int ObjectID
public void ClearAllPools()
{
- IntPtr hscp;
- Bid.ScopeEnter(out hscp, " ");
+ long scopeID = SqlClientEventSource.Log.ScopeEnterEvent("", "API");
try
{
Dictionary connectionPoolGroups = _connectionPoolGroups;
@@ -81,16 +80,14 @@ public void ClearAllPools()
}
finally
{
- Bid.ScopeLeave(ref hscp);
+ SqlClientEventSource.Log.ScopeLeaveEvent(scopeID);
}
}
public void ClearPool(DbConnection connection)
{
ADP.CheckArgumentNull(connection, "connection");
-
- IntPtr hscp;
- Bid.ScopeEnter(out hscp, " %d#", GetObjectId(connection));
+ long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", GetObjectId(connection));
try
{
DbConnectionPoolGroup poolGroup = GetConnectionPoolGroup(connection);
@@ -101,7 +98,7 @@ public void ClearPool(DbConnection connection)
}
finally
{
- Bid.ScopeLeave(ref hscp);
+ SqlClientEventSource.Log.ScopeLeaveEvent(scopeID);
}
}
@@ -109,9 +106,8 @@ public void ClearPool(DbConnectionPoolKey key)
{
Debug.Assert(key != null, "key cannot be null");
ADP.CheckArgumentNull(key.ConnectionString, "key.ConnectionString");
+ long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" connectionString", "API");
- IntPtr hscp;
- Bid.ScopeEnter(out hscp, " connectionString");
try
{
DbConnectionPoolGroup poolGroup;
@@ -123,7 +119,7 @@ public void ClearPool(DbConnectionPoolKey key)
}
finally
{
- Bid.ScopeLeave(ref hscp);
+ SqlClientEventSource.Log.ScopeLeaveEvent(scopeID);
}
}
@@ -155,7 +151,7 @@ internal DbConnectionInternal CreateNonPooledConnection(DbConnection owningConne
PerformanceCounters.HardConnectsPerSecond.Increment();
newConnection.MakeNonPooledObject(owningConnection, PerformanceCounters);
}
- Bid.Trace(" %d#, Non-pooled database connection created.\n", ObjectID);
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Non-pooled database connection created.", ObjectID);
return newConnection;
}
@@ -165,12 +161,13 @@ internal DbConnectionInternal CreatePooledConnection(DbConnectionPool pool, DbCo
DbConnectionPoolGroupProviderInfo poolGroupProviderInfo = pool.PoolGroup.ProviderInfo;
DbConnectionInternal newConnection = CreateConnection(options, poolKey, poolGroupProviderInfo, pool, owningObject, userOptions);
+
if (null != newConnection)
{
PerformanceCounters.HardConnectsPerSecond.Increment();
newConnection.MakePooledConnection(pool);
}
- Bid.Trace(" %d#, Pooled database connection created.\n", ObjectID);
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Pooled database connection created.", ObjectID);
return newConnection;
}
@@ -365,8 +362,9 @@ 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);
+
// If GetConnection failed while the pool is running, the pool timeout occurred.
- Bid.Trace(" %d#, GetConnection failed because a pool timeout occurred.\n", ObjectID);
throw ADP.PooledOpenTimeout();
}
else
@@ -383,8 +381,9 @@ 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);
+
// exhausted all retries or timed out - give up
- Bid.Trace(" %d#, GetConnection failed because a pool timeout occurred and all retries were exhausted.\n", ObjectID);
throw ADP.PooledOpenTimeout();
}
@@ -409,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))
{
- Bid.Trace(" %d#, DisabledPoolGroup=%d#\n", 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;
@@ -540,10 +539,7 @@ internal DbMetaDataFactory GetMetaDataFactory(DbConnectionPoolGroup connectionPo
private void PruneConnectionPoolGroups(object state)
{
// when debugging this method, expect multiple threads at the same time
- if (Bid.AdvancedOn)
- {
- Bid.Trace(" %d#\n", ObjectID);
- }
+ SqlClientEventSource.Log.AdvanceTrace(" {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
@@ -563,10 +559,7 @@ private void PruneConnectionPoolGroups(object state)
if (0 == pool.Count)
{
_poolsToRelease.Remove(pool);
- if (Bid.AdvancedOn)
- {
- Bid.Trace(" %d#, ReleasePool=%d#\n", ObjectID, pool.ObjectID);
- }
+ SqlClientEventSource.Log.AdvanceTrace(" {0}#, ReleasePool={1}#", ObjectID, pool.ObjectID);
PerformanceCounters.NumberOfInactiveConnectionPools.Decrement();
}
}
@@ -591,10 +584,7 @@ private void PruneConnectionPoolGroups(object state)
if (0 == poolsLeft)
{
_poolGroupsToRelease.Remove(poolGroup);
- if (Bid.AdvancedOn)
- {
- Bid.Trace(" %d#, ReleasePoolGroup=%d#\n", ObjectID, poolGroup.ObjectID);
- }
+ SqlClientEventSource.Log.AdvanceTrace(" {0}#, ReleasePoolGroup={1}#", ObjectID, poolGroup.ObjectID);
PerformanceCounters.NumberOfInactiveConnectionPoolGroups.Decrement();
}
}
@@ -660,7 +650,7 @@ internal void QueuePoolForRelease(DbConnectionPool pool, bool clearing)
internal void QueuePoolGroupForRelease(DbConnectionPoolGroup poolGroup)
{
Debug.Assert(null != poolGroup, "null poolGroup?");
- Bid.Trace(" %d#, poolGroup=%d#\n", 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 a346bedc76..446d22b560 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
@@ -14,6 +14,7 @@ namespace Microsoft.Data.ProviderBase
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Data.Common;
+ using Microsoft.Data.SqlClient;
using SysTx = System.Transactions;
internal abstract class DbConnectionInternal
@@ -52,7 +53,7 @@ internal abstract class DbConnectionInternal
private SysTx.Transaction _enlistedTransactionOriginal;
#if DEBUG
- private int _activateCount; // debug only counter to verify activate/deactivates are in sync.
+ private int _activateCount; // debug only counter to verify activate/deactivates are in sync.
#endif //DEBUG
protected DbConnectionInternal() : this(ConnectionState.Open, true, false)
@@ -162,11 +163,7 @@ protected internal SysTx.Transaction EnlistedTransaction
if (null != value)
{
- if (Bid.IsOn(DbConnectionPool.PoolerTracePoints))
- {
- int x = value.GetHashCode();
- Bid.PoolerTrace(" %d#, Transaction %d#, Enlisting.\n", ObjectID, x);
- }
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Enlisting.", ObjectID, value.GetHashCode());
TransactionOutcomeEnlist(value);
}
}
@@ -391,8 +388,7 @@ internal void ActivateConnection(SysTx.Transaction transaction)
{
// Internal method called from the connection pooler so we don't expose
// the Activate method publicly.
-
- Bid.PoolerTrace(" %d#, Activating\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Activating", ObjectID);
#if DEBUG
int activateCount = Interlocked.Increment(ref _activateCount);
Debug.Assert(1 == activateCount, "activated multiple times?");
@@ -463,8 +459,7 @@ internal virtual void CloseConnection(DbConnection owningObject, DbConnectionFac
////////////////////////////////////////////////////////////////
Debug.Assert(null != owningObject, "null owningObject");
Debug.Assert(null != connectionFactory, "null connectionFactory");
-
- Bid.PoolerTrace(" %d# Closing.\n", 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
@@ -569,8 +564,7 @@ internal void DeactivateConnection()
{
// Internal method called from the connection pooler so we don't expose
// the Deactivate method publicly.
-
- Bid.PoolerTrace(" %d#, Deactivating\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Deactivating", ObjectID);
#if DEBUG
int activateCount = Interlocked.Decrement(ref _activateCount);
Debug.Assert(0 == activateCount, "activated multiple times?");
@@ -604,8 +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.
-
- Bid.Trace(" %d#, Delegated Transaction Completed.\n", ObjectID);
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Delegated Transaction Completed.", ObjectID);
if (1 == _pooledCount)
{
@@ -668,7 +661,7 @@ public virtual void Dispose()
protected internal void DoNotPoolThisConnection()
{
_cannotBePooled = true;
- Bid.PoolerTrace(" %d#, Marking pooled object as non-poolable so it will be disposed\n", 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.
@@ -676,7 +669,7 @@ protected internal void DoNotPoolThisConnection()
protected internal void DoomThisConnection()
{
_connectionIsDoomed = true;
- Bid.PoolerTrace(" %d#, Dooming\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Dooming", ObjectID);
}
// Reset connection doomed status so it can be re-connected and pooled.
@@ -808,11 +801,10 @@ internal void PrePush(object expectedOwner)
{
throw ADP.InternalError(ADP.InternalErrorCode.PushingObjectSecondTime); // pushing object onto stack a second time
}
- if (Bid.IsOn(DbConnectionPool.PoolerTracePoints))
- {
- //DbConnection x = (expectedOwner as DbConnection);
- Bid.PoolerTrace(" %d#, Preparing to push into pool, owning connection %d#, pooledCount=%d\n", ObjectID, 0, _pooledCount);
- }
+
+ //DbConnection x = (expectedOwner as DbConnection);
+ 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%
}
@@ -841,11 +833,10 @@ internal void PostPop(object newOwner)
}
_owningObject.Target = newOwner;
_pooledCount--;
- if (Bid.IsOn(DbConnectionPool.PoolerTracePoints))
- {
- //DbConnection x = (newOwner as DbConnection);
- Bid.PoolerTrace(" %d#, Preparing to pop from pool, owning connection %d#, pooledCount=%d\n", ObjectID, 0, _pooledCount);
- }
+
+ //DbConnection x = (newOwner as DbConnection);
+ 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)
{
@@ -901,7 +892,7 @@ internal void DetachCurrentTransactionIfEnded()
// Detach transaction from connection.
internal void DetachTransaction(SysTx.Transaction transaction, bool isExplicitlyReleasing)
{
- Bid.Trace(" %d#, Transaction Completed. (pooledCount=%d)\n", ObjectID, _pooledCount);
+ SqlClientEventSource.Log.TraceEvent(" {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
@@ -942,11 +933,9 @@ internal void CleanupConnectionOnTransactionCompletion(SysTx.Transaction transac
void TransactionCompletedEvent(object sender, SysTx.TransactionEventArgs e)
{
SysTx.Transaction transaction = e.Transaction;
-
- Bid.Trace(" %d#, Transaction Completed. (pooledCount=%d)\n", ObjectID, _pooledCount);
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Transaction Completed. (pooledCount = {1})", ObjectID, _pooledCount);
CleanupTransactionOnCompletion(transaction);
-
CleanupConnectionOnTransactionCompletion(transaction);
}
@@ -961,7 +950,7 @@ private void TransactionOutcomeEnlist(SysTx.Transaction transaction)
internal void SetInStasis()
{
_isInStasis = true;
- Bid.PoolerTrace(" %d#, Non-Pooled Connection has Delegated Transaction, waiting to Dispose.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Non-Pooled Connection has Delegated Transaction, waiting to Dispose.", ObjectID);
PerformanceCounters.NumberOfStasisConnections.Increment();
}
@@ -969,12 +958,13 @@ private void TerminateStasis(bool returningToPool)
{
if (returningToPool)
{
- Bid.PoolerTrace(" %d#, Delegated Transaction has ended, connection is closed. Returning to general pool.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Delegated Transaction has ended, connection is closed. Returning to general pool.", ObjectID);
}
else
{
- Bid.PoolerTrace(" %d#, Delegated Transaction has ended, connection is closed/leaked. Disposing.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Delegated Transaction has ended, connection is closed/leaked. Disposing.", ObjectID);
}
+
PerformanceCounters.NumberOfStasisConnections.Decrement();
_isInStasis = false;
}
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 3d023597d3..33630971e2 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
@@ -19,6 +19,7 @@ namespace Microsoft.Data.ProviderBase
using System.Threading.Tasks;
using Microsoft.Data.Common;
using Microsoft.Data.SqlClient;
+
using SysTx = System.Transactions;
sealed internal class DbConnectionPool
@@ -30,8 +31,6 @@ private enum State
ShuttingDown,
}
- internal const Bid.ApiGroup PoolerTracePoints = Bid.ApiGroup.Pooling;
-
// This class is a way to stash our cloned Tx key for later disposal when it's no longer needed.
// We can't get at the key in the dictionary without enumerating entries, so we stash an extra
// copy as part of the value.
@@ -80,11 +79,9 @@ sealed private class TransactedConnectionPool
internal TransactedConnectionPool(DbConnectionPool pool)
{
Debug.Assert(null != pool, "null pool?");
-
_pool = pool;
_transactedCxns = new Dictionary();
-
- Bid.PoolerTrace(" %d#, Constructed for connection pool %d#\n", ObjectID, _pool.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Constructed for connection pool {1}#", ObjectID, _pool.ObjectID);
}
internal int ObjectID
@@ -143,7 +140,7 @@ internal DbConnectionInternal GetTransactedObject(SysTx.Transaction transaction)
if (null != transactedObject)
{
- Bid.PoolerTrace(" %d#, Transaction %d#, Connection %d#, Popped.\n", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Popped.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
}
return transactedObject;
}
@@ -170,8 +167,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt
lock (connections)
{
Debug.Assert(0 > connections.IndexOf(transactedObject), "adding to pool a second time?");
- Bid.PoolerTrace(" %d#, Transaction %d#, Connection %d#, Pushing.\n", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
connections.Add(transactedObject);
}
}
@@ -206,14 +202,13 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt
lock (connections)
{
Debug.Assert(0 > connections.IndexOf(transactedObject), "adding to pool a second time?");
- Bid.PoolerTrace(" %d#, Transaction %d#, Connection %d#, Pushing.\n", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Pushing.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
connections.Add(transactedObject);
}
}
else
{
- Bid.PoolerTrace(" %d#, Transaction %d#, Connection %d#, Adding List to transacted pool.\n", 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);
@@ -241,7 +236,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt
}
}
}
- Bid.PoolerTrace(" %d#, Transaction %d#, Connection %d#, Added.\n", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Transaction {1}#, Connection {2}#, Added.", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
}
Pool.PerformanceCounters.NumberOfFreeConnections.Increment();
@@ -250,8 +245,7 @@ internal void PutTransactedObject(SysTx.Transaction transaction, DbConnectionInt
internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionInternal transactedObject)
{
- Bid.PoolerTrace(" %d#, Transaction %d#, Connection %d#, Transaction Completed\n", 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;
@@ -285,7 +279,7 @@ internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionIntern
// safely remove the list from the transacted pool.
if (0 >= connections.Count)
{
- Bid.PoolerTrace(" %d#, Transaction %d#, Removing List from transacted pool.\n", 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
@@ -302,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." );
- Bid.PoolerTrace(" %d#, Transaction %d#, Connection %d#, Transacted pool not yet created prior to transaction completing. Connection may be leaked.\n", 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);
}
}
@@ -529,8 +523,7 @@ internal DbConnectionPool(
_poolCreateRequest = new WaitCallback(PoolCreateRequest); // used by CleanupCallback
_state = State.Running;
-
- Bid.PoolerTrace(" %d#, Constructed.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Constructed.", ObjectID);
//_cleanupTimer & QueuePoolCreateRequest is delayed until DbConnectionPoolGroup calls
// StartBackgroundCallbacks after pool is actually in the collection
@@ -678,8 +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.
-
- Bid.PoolerTrace(" %d#\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#", ObjectID);
// Destroy free objects that put us above MinPoolSize from old stack.
while (Count > MinPoolSize)
@@ -753,9 +745,7 @@ private void CleanupCallback(Object state)
break;
Debug.Assert(obj != null, "null connection is not expected");
-
- Bid.PoolerTrace(" %d#, ChangeStacks=%d#\n", 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");
@@ -770,8 +760,7 @@ private void CleanupCallback(Object state)
internal void Clear()
{
- Bid.PoolerTrace(" %d#, Clearing.\n", ObjectID);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Clearing.", ObjectID);
DbConnectionInternal obj;
// First, quickly doom everything.
@@ -807,8 +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();
-
- Bid.PoolerTrace(" %d#, Cleared.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Cleared.", ObjectID);
}
private Timer CreateCleanupTimer()
@@ -898,7 +886,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio
}
}
}
- Bid.PoolerTrace(" %d#, Connection %d#, Added to pool.\n", ObjectID, newObj.ObjectID);
+ 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;
@@ -959,8 +947,7 @@ private DbConnectionInternal CreateObject(DbConnection owningObject, DbConnectio
private void DeactivateObject(DbConnectionInternal obj)
{
- Bid.PoolerTrace(" %d#, Connection %d#, Deactivating.\n", 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;
@@ -1100,12 +1087,11 @@ internal void DestroyObject(DbConnectionInternal obj)
// again.
if (obj.IsTxRootWaitingForTxEnd)
{
- Bid.PoolerTrace(" %d#, Connection %d#, Has Delegated Transaction, waiting to Dispose.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Has Delegated Transaction, waiting to Dispose.", ObjectID, obj.ObjectID);
}
else
{
- Bid.PoolerTrace(" %d#, Connection %d#, Removing from pool.\n", ObjectID, obj.ObjectID);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Removing from pool.", ObjectID, obj.ObjectID);
bool removed = false;
lock (_objectList)
{
@@ -1116,20 +1102,18 @@ internal void DestroyObject(DbConnectionInternal obj)
if (removed)
{
- Bid.PoolerTrace(" %d#, Connection %d#, Removed from pool.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Removed from pool.", ObjectID, obj.ObjectID);
PerformanceCounters.NumberOfPooledConnections.Decrement();
}
obj.Dispose();
-
- Bid.PoolerTrace(" %d#, Connection %d#, Disposed.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Disposed.", ObjectID, obj.ObjectID);
PerformanceCounters.HardDisconnectsPerSecond.Increment();
}
}
private void ErrorCallback(Object state)
{
- Bid.PoolerTrace(" %d#, Resetting Error handling.\n", ObjectID);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Resetting Error handling.", ObjectID);
_errorOccurred = false;
_waitHandles.ErrorEvent.Reset();
@@ -1212,7 +1196,8 @@ void WaitForPendingOpen()
Microsoft.Data.SqlClient.TdsParser.ReliabilitySection tdsReliabilitySection = new Microsoft.Data.SqlClient.TdsParser.ReliabilitySection();
RuntimeHelpers.PrepareConstrainedRegions();
- try {
+ try
+ {
tdsReliabilitySection.Start();
#else
{
@@ -1224,7 +1209,8 @@ void WaitForPendingOpen()
timeout = !TryGetConnection(next.Owner, delay, allowCreate, onlyOneCheckConnection, next.UserOptions, out connection);
}
#if DEBUG
- finally {
+ finally
+ {
tdsReliabilitySection.Stop();
}
#endif //DEBUG
@@ -1301,7 +1287,7 @@ internal bool TryGetConnection(DbConnection owningObject, TaskCompletionSource %d#, DbConnectionInternal State != Running.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, DbConnectionInternal State != Running.", ObjectID);
connection = null;
return true;
}
@@ -1346,8 +1332,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
SysTx.Transaction transaction = null;
PerformanceCounters.SoftConnectsPerSecond.Increment();
-
- Bid.PoolerTrace(" %d#, Getting connection.\n", 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.
@@ -1400,20 +1385,20 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
switch (waitResult)
{
case WAIT_TIMEOUT:
- Bid.PoolerTrace(" %d#, Wait timed out.\n", 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.
- Bid.PoolerTrace(" %d#, Errors are set.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Errors are set.", ObjectID);
Interlocked.Decrement(ref _waitCount);
throw TryCloneCachedException();
case CREATION_HANDLE:
- Bid.PoolerTrace(" %d#, Creating new connection.\n", ObjectID);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Creating new connection.", ObjectID);
try
{
obj = UserCreateRequest(owningObject, userOptions);
@@ -1466,7 +1451,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
if ((obj != null) && (!obj.IsConnectionAlive()))
{
- Bid.PoolerTrace(" %d#, Connection %d#, found dead and removed.\n", 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
@@ -1477,7 +1462,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
RuntimeHelpers.PrepareConstrainedRegions();
try
{
- Bid.PoolerTrace(" %d#, Creating new connection.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Creating new connection.", ObjectID);
obj = UserCreateRequest(owningObject, userOptions);
}
finally
@@ -1488,7 +1473,7 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
else
{
// Timeout waiting for creation semaphore - return null
- Bid.PoolerTrace(" %d#, Wait timed out.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Wait timed out.", ObjectID);
connection = null;
return false;
}
@@ -1498,24 +1483,28 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
case WAIT_FAILED:
Debug.Assert(waitForMultipleObjectsExHR != 0, "WaitForMultipleObjectsEx failed but waitForMultipleObjectsExHR remained 0");
- Bid.PoolerTrace(" %d#, Wait failed.\n", 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):
- Bid.PoolerTrace(" %d#, Semaphore handle abandonded.\n", 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):
- Bid.PoolerTrace(" %d#, Error handle abandonded.\n", 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):
- Bid.PoolerTrace(" %d#, Creation handle abandoned.\n", ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Creation handle abandoned.", ObjectID);
Interlocked.Decrement(ref _waitCount);
throw new AbandonedMutexException(CREATION_HANDLE, _waitHandles.CreationSemaphore);
+
default:
- Bid.PoolerTrace(" %d#, WaitForMultipleObjects=%d\n", ObjectID, waitResult);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, WaitForMultipleObjects={1}", ObjectID, waitResult);
Interlocked.Decrement(ref _waitCount);
throw ADP.InternalError(ADP.InternalErrorCode.UnexpectedWaitAnyResult);
}
@@ -1580,8 +1569,7 @@ private void PrepareConnection(DbConnection owningObject, DbConnectionInternal o
internal DbConnectionInternal ReplaceConnection(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
{
PerformanceCounters.SoftConnectsPerSecond.Increment();
- Bid.PoolerTrace(" %d#, replacing connection.\n", ObjectID);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, replacing connection.", ObjectID);
DbConnectionInternal newConnection = UserCreateRequest(owningObject, userOptions, oldConnection);
if (newConnection != null)
@@ -1623,7 +1611,7 @@ private DbConnectionInternal GetFromGeneralPool()
if (null != obj)
{
- Bid.PoolerTrace(" %d#, Connection %d#, Popped from general pool.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Popped from general pool.", ObjectID, obj.ObjectID);
PerformanceCounters.NumberOfFreeConnections.Decrement();
}
return (obj);
@@ -1640,7 +1628,7 @@ private DbConnectionInternal GetFromTransactedPool(out SysTx.Transaction transac
if (null != obj)
{
- Bid.PoolerTrace(" %d#, Connection %d#, Popped from transacted pool.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Popped from transacted pool.", ObjectID, obj.ObjectID);
PerformanceCounters.NumberOfFreeConnections.Decrement();
if (obj.IsTransactionRoot)
@@ -1651,14 +1639,14 @@ private DbConnectionInternal GetFromTransactedPool(out SysTx.Transaction transac
}
catch
{
- Bid.PoolerTrace(" %d#, Connection %d#, found dead and removed.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, found dead and removed.", ObjectID, obj.ObjectID);
DestroyObject(obj);
throw;
}
}
else if (!obj.IsConnectionAlive())
{
- Bid.PoolerTrace(" %d#, Connection %d#, found dead and removed.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, found dead and removed.", ObjectID, obj.ObjectID);
DestroyObject(obj);
obj = null;
}
@@ -1673,11 +1661,7 @@ private void PoolCreateRequest(object state)
{
// called by pooler to ensure pool requests are currently being satisfied -
// creation mutex has not been obtained
-
- IntPtr hscp;
-
- Bid.PoolerScopeEnter(out hscp, " %d#\n", ObjectID);
-
+ long scopeID = SqlClientEventSource.Log.PoolerScopeEnterEvent(" {0}#", ObjectID);
try
{
if (State.Running == _state)
@@ -1762,7 +1746,7 @@ private void PoolCreateRequest(object state)
else
{
// trace waitResult and ignore the failure
- Bid.PoolerTrace(" %d#, PoolCreateRequest called WaitForSingleObject failed %d", ObjectID, waitResult);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, PoolCreateRequest called WaitForSingleObject failed {1}", ObjectID, waitResult);
}
}
catch (Exception e)
@@ -1776,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.
- Bid.PoolerTrace(" %d#, PoolCreateRequest called CreateConnection which threw an exception: %ls", ObjectID, e);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, PoolCreateRequest called CreateConnection which threw an exception: {1}", ObjectID, e);
}
finally
{
@@ -1796,7 +1780,7 @@ private void PoolCreateRequest(object state)
}
finally
{
- Bid.ScopeLeave(ref hscp);
+ SqlClientEventSource.Log.PoolerScopeLeaveEvent(scopeID);
}
}
@@ -1809,8 +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");
-
- Bid.PoolerTrace(" %d#, Connection %d#, Pushing to general pool.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Pushing to general pool.", ObjectID, obj.ObjectID);
_stackNew.Push(obj);
_waitHandles.PoolSemaphore.Release(1);
@@ -1859,8 +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.
-
- Bid.PoolerTrace(" %d#, Connection %d#, Transaction has ended.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Transaction has ended.", ObjectID, obj.ObjectID);
if (_state == State.Running && obj.CanBePooled)
{
@@ -1885,9 +1867,7 @@ private void QueuePoolCreateRequest()
private bool ReclaimEmancipatedObjects()
{
bool emancipatedObjectFound = false;
-
- Bid.PoolerTrace(" %d#\n", ObjectID);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#", ObjectID);
List reclaimedObjects = new List();
int count;
@@ -1939,8 +1919,7 @@ private bool ReclaimEmancipatedObjects()
for (int i = 0; i < count; ++i)
{
DbConnectionInternal obj = reclaimedObjects[i];
-
- Bid.PoolerTrace(" %d#, Connection %d#, Reclaiming.\n", ObjectID, obj.ObjectID);
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, Connection {1}#, Reclaiming.", ObjectID, obj.ObjectID);
PerformanceCounters.NumberOfReclaimedConnections.Increment();
emancipatedObjectFound = true;
@@ -1953,9 +1932,9 @@ private bool ReclaimEmancipatedObjects()
internal void Startup()
{
- Bid.PoolerTrace(" %d#, CleanupWait=%d\n", ObjectID, _cleanupWait);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#, CleanupWait={1}", ObjectID, _cleanupWait);
_cleanupTimer = CreateCleanupTimer();
+
if (NeedToReplenish)
{
QueuePoolCreateRequest();
@@ -1964,8 +1943,7 @@ internal void Startup()
internal void Shutdown()
{
- Bid.PoolerTrace(" %d#\n", ObjectID);
-
+ SqlClientEventSource.Log.PoolerTraceEvent(" {0}#", ObjectID);
_state = State.ShuttingDown;
// deactivate timer callbacks
@@ -1985,9 +1963,9 @@ internal void TransactionEnded(SysTx.Transaction transaction, DbConnectionIntern
{
Debug.Assert(null != transaction, "null transaction?");
Debug.Assert(null != transactedObject, "null transactedObject?");
- // Note: connection may still be associated with transaction due to Explicit Unbinding requirement.
- Bid.PoolerTrace(" %d#, Transaction %d#, Connection %d#, Transaction Completed\n", ObjectID, transaction.GetHashCode(), transactedObject.ObjectID);
+ // 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);
// 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 521b820d31..89f6b04ec3 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
@@ -7,6 +7,8 @@ namespace Microsoft.Data.ProviderBase
using System.Collections.Concurrent;
using System.Diagnostics;
using Microsoft.Data.Common;
+ using Microsoft.Data.SqlClient;
+
// set_ConnectionString calls DbConnectionFactory.GetConnectionPoolGroup
// when not found a new pool entry is created and potentially added
@@ -271,7 +273,7 @@ private bool MarkPoolGroupAsActive()
if (PoolGroupStateIdle == _state)
{
_state = PoolGroupStateActive;
- Bid.Trace(" %d#, Active\n", ObjectID);
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Active", ObjectID);
}
return (PoolGroupStateActive == _state);
}
@@ -333,14 +335,15 @@ internal bool Prune()
if (PoolGroupStateActive == _state)
{
_state = PoolGroupStateIdle;
- Bid.Trace(" %d#, Idle\n", ObjectID);
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Idle", ObjectID);
}
else if (PoolGroupStateIdle == _state)
{
_state = PoolGroupStateDisabled;
- Bid.Trace(" %d#, Disabled\n", ObjectID);
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Disabled", ObjectID);
}
}
+
return (PoolGroupStateDisabled == _state);
}
}
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 222a78ee17..c90c78e665 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
@@ -12,6 +12,7 @@ namespace Microsoft.Data.SqlClient
using System.Threading;
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
+
using SysTx = System.Transactions;
public sealed partial class SqlConnection : DbConnection
@@ -86,7 +87,7 @@ internal DbConnectionOptions ConnectionOptions
private string ConnectionString_Get()
{
- Bid.Trace(" %d#\n", ObjectID);
+ SqlClientEventSource.Log.TraceEvent(" {0}#", ObjectID);
bool hidePassword = InnerConnection.ShouldHidePassword;
DbConnectionOptions connectionOptions = UserConnectionOptions;
return ((null != connectionOptions) ? connectionOptions.UsersConnectionString(hidePassword) : "");
@@ -129,11 +130,9 @@ private void ConnectionString_Set(DbConnectionPoolKey key)
{
throw ADP.OpenConnectionPropertySet(ADP.ConnectionString, connectionInternal.State);
}
- if (Bid.TraceOn)
- {
- string cstr = ((null != connectionOptions) ? connectionOptions.UsersConnectionStringForTrace() : "");
- Bid.Trace(" %d#, '%ls'\n", ObjectID, cstr);
- }
+
+ string cstr = ((null != connectionOptions) ? connectionOptions.UsersConnectionStringForTrace() : "");
+ SqlClientEventSource.Log.TraceEvent(" {0}#, '{1}'", ObjectID, cstr);
}
internal DbConnectionInternal InnerConnection
@@ -179,15 +178,15 @@ internal void Abort(Exception e)
}
// NOTE: we put the tracing last, because the ToString() calls (and
- // the Bid.Trace, for that matter) have no reliability contract and
+ // the SqlClientEventSource.SqlClientEventSource.Log.Trace, for that matter) have no reliability contract and
// will end the reliable try...
if (e is OutOfMemoryException)
{
- Bid.Trace(" %d#, Aborting operation due to asynchronous exception: %ls\n", ObjectID, "OutOfMemory");
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Aborting operation due to asynchronous exception: {'OutOfMemory'}", ObjectID);
}
else
{
- Bid.Trace(" %d#, Aborting operation due to asynchronous exception: %ls\n", ObjectID, e.ToString());
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Aborting operation due to asynchronous exception: {1}", ObjectID, e.ToString());
}
}
@@ -200,8 +199,7 @@ internal void AddWeakReference(object value, int tag)
override protected DbCommand CreateDbCommand()
{
DbCommand command = null;
- IntPtr hscp;
- Bid.ScopeEnter(out hscp, " %d#\n", ObjectID);
+ long scopeID = SqlClientEventSource.Log.ScopeEnterEvent(" {0}#", ObjectID);
try
{
DbProviderFactory providerFactory = ConnectionFactory.ProviderFactory;
@@ -210,7 +208,7 @@ override protected DbCommand CreateDbCommand()
}
finally
{
- Bid.ScopeLeave(ref hscp);
+ SqlClientEventSource.Log.ScopeLeaveEvent(scopeID);
}
return command;
}
@@ -247,7 +245,7 @@ private void EnlistDistributedTransactionHelper(System.EnterpriseServices.ITrans
permissionSet.AddPermission(new System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode));
permissionSet.Demand();
- Bid.Trace(" %d#, Connection enlisting in a transaction.\n", ObjectID);
+ SqlClientEventSource.Log.TraceEvent(" {0}#, Connection enlisting in a transaction.", ObjectID);
SysTx.Transaction indigoTransaction = null;
if (null != transaction)
@@ -272,8 +270,7 @@ private void EnlistDistributedTransactionHelper(System.EnterpriseServices.ITrans
override public void EnlistTransaction(SysTx.Transaction transaction)
{
SqlConnection.ExecutePermission.Demand();
-
- Bid.Trace(" %d#, Connection enlisting in a transaction.\n", 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/RelationshipConverter.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/RelationshipConverter.cs
index ac6539a356..9718f0342c 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/RelationshipConverter.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/RelationshipConverter.cs
@@ -16,7 +16,6 @@ public RelationshipConverter()
{
}
-
///
/// Gets a value indicating whether this converter can
/// convert an object to the given destination type using the context.
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationTimeoutRetryHelper.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
index 1ecfc4d681..f0ed91dc24 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
@@ -65,7 +65,9 @@ public ActiveDirectoryAuthenticationTimeoutRetryState State
default:
throw new InvalidOperationException($"Unsupported state: {value}.");
}
- _sqlAuthLogger.LogInfo(_typeName, "SetState", $"State changed from {_state} to {value}.");
+ if (_sqlAuthLogger.IsLoggingEnabled)
+ _sqlAuthLogger.LogInfo(_typeName, "SetState", $"State changed from {_state} to {value}.");
+
_state = value;
}
}
@@ -78,17 +80,14 @@ public SqlFedAuthToken CachedToken
get
{
if (_sqlAuthLogger.IsLoggingEnabled)
- {
_sqlAuthLogger.LogInfo(_typeName, "GetCachedToken", $"Retrieved cached token {GetTokenHash(_token)}.");
- }
return _token;
}
set
{
if (_sqlAuthLogger.IsLoggingEnabled)
- {
_sqlAuthLogger.LogInfo(_typeName, "SetCachedToken", $"CachedToken changed from {GetTokenHash(_token)} to {GetTokenHash(value)}.");
- }
+
_token = value;
}
}
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/LocalDBAPI.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/LocalDBAPI.cs
index 68bfdfa52c..8a31f2f2df 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/LocalDBAPI.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/LocalDBAPI.cs
@@ -73,7 +73,7 @@ static IntPtr UserInstanceDLLHandle
SNINativeMethodWrapper.SNIQueryInfo(SNINativeMethodWrapper.QTypes.SNI_QUERY_LOCALDB_HMODULE, ref s_userInstanceDLLHandle);
if (s_userInstanceDLLHandle != IntPtr.Zero)
{
- Bid.Trace(" LocalDB - handle obtained");
+ SqlClientEventSource.Log.TraceEvent(" LocalDB - handle obtained");
}
else
{
@@ -117,7 +117,7 @@ static LocalDBCreateInstanceDelegate LocalDBCreateInstance
if (functionAddr == IntPtr.Zero)
{
int hResult = Marshal.GetLastWin32Error();
- Bid.Trace(" GetProcAddress for LocalDBCreateInstance error 0x{%X}", hResult);
+ SqlClientEventSource.Log.TraceEvent(" GetProcAddress for LocalDBCreateInstance error 0x{0}", hResult);
throw CreateLocalDBException(errorMessage: StringsHelper.GetString("LocalDB_MethodNotFound"));
}
s_localDBCreateInstance = (LocalDBCreateInstanceDelegate)Marshal.GetDelegateForFunctionPointer(functionAddr, typeof(LocalDBCreateInstanceDelegate));
@@ -159,7 +159,7 @@ static LocalDBFormatMessageDelegate LocalDBFormatMessage
{
// SNI checks for LocalDBFormatMessage during DLL loading, so it is practically impossibe to get this error.
int hResult = Marshal.GetLastWin32Error();
- Bid.Trace(" GetProcAddress for LocalDBFormatMessage error 0x{%X}", hResult);
+ SqlClientEventSource.Log.TraceEvent(" GetProcAddress for LocalDBFormatMessage error 0x{0}", hResult);
throw CreateLocalDBException(errorMessage: StringsHelper.GetString("LocalDB_MethodNotFound"));
}
s_localDBFormatMessage = (LocalDBFormatMessageDelegate)Marshal.GetDelegateForFunctionPointer(functionAddr, typeof(LocalDBFormatMessageDelegate));
@@ -314,7 +314,9 @@ internal static void CreateLocalDBInstance(string instance)
}
}
else
- Bid.Trace(" No system.data.localdb section found in configuration");
+ {
+ SqlClientEventSource.Log.TraceEvent(" No system.data.localdb section found in configuration");
+ }
s_configurableInstances = tempConfigurableInstances;
}
}
@@ -340,14 +342,15 @@ internal static void CreateLocalDBInstance(string instance)
// LocalDBCreateInstance is thread- and cross-process safe method, it is OK to call from two threads simultaneously
int hr = LocalDBCreateInstance(instanceInfo.version, instance, flags: 0);
- Bid.Trace(" Starting creation of instance %ls version %ls", instance, instanceInfo.version);
+ SqlClientEventSource.Log.TraceEvent(" Starting creation of instance {0} version {1}", instance, instanceInfo.version);
+
if (hr < 0)
+ {
throw CreateLocalDBException(errorMessage: StringsHelper.GetString("LocalDB_CreateFailed"), instance: instance, localDbError: hr);
- Bid.Trace(" Finished creation of instance %ls", instance);
- instanceInfo.created = true; // mark instance as created
+ }
+ SqlClientEventSource.Log.TraceEvent(" Finished creation of instance {0}", instance);
+ instanceInfo.created = true; // mark instance as created
} // CreateLocalDbInstance
-
}
-
}
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 5fd1cc87cd..dd3b6a807b 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
@@ -6,7 +6,6 @@
namespace Microsoft.Data.SqlClient.Server
{
-
internal class SmiEventSink_Default : SmiEventSink
{
@@ -268,19 +267,7 @@ internal override void MessagePosted(int number, byte state, byte errorClass, st
{
if (null == _parent)
{
- if (Bid.AdvancedOn)
- {
- Bid.Trace(" %d#, number=%d state=%d errorClass=%d server='%ls' message='%ls' procedure='%ls' linenumber=%d.\n",
- 0,
- number,
- state,
- errorClass,
- (null != server) ? server : "",
- (null != message) ? message : "",
- (null != procedure) ? procedure : "",
- lineNumber
- );
- }
+ 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);
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/SqlAuthenticationProviderManager.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs
index 39434bf0f7..32356f85ba 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.cs
@@ -106,7 +106,7 @@ public SqlAuthenticationProviderManager(SqlAuthenticationProviderConfigurationSe
_providers[authentication] = provider;
authenticationsWithAppSpecifiedProvider.Add(authentication);
- _sqlAuthLogger.LogInfo(_typeName, methodName, $"Added user-defined auth provider: {providerSettings.Type} for authentication {authentication}.");
+ _sqlAuthLogger.LogInfo(_typeName, methodName, string.Format("Added user-defined auth provider: {0} for authentication {1}.", providerSettings?.Type, authentication));
}
}
else
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 ca46138662..fff3bf78eb 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
@@ -593,10 +593,8 @@ private string CreateInitialQuery()
private Task CreateAndExecuteInitialQueryAsync(out BulkCopySimpleResultSet result)
{
string TDSCommand = CreateInitialQuery();
-
- Bid.Trace(" Initial Query: '%ls' \n", TDSCommand);
- Bid.CorrelationTrace(" ObjectID%d#, ActivityID %ls\n", ObjectID);
-
+ SqlClientEventSource.Log.TraceEvent(" Initial Query: '{0}'", TDSCommand);
+ 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)
@@ -886,8 +884,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
//
private Task SubmitUpdateBulkCommand(string TDSCommand)
{
- Bid.CorrelationTrace(" ObjectID%d#, ActivityID %ls\n", ObjectID);
-
+ 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)
@@ -2517,7 +2514,7 @@ private void CheckAndRaiseNotification()
// it's also the user's chance to cause an exception ...
_stateObj.BcpLock = true;
abortOperation = FireRowsCopiedEvent(_rowsCopied);
- Bid.Trace(" \n");
+ SqlClientEventSource.Log.TraceEvent("", "INFO");
// just in case some pathological person closes the target connection ...
if (ConnectionState.Open != _connection.State)
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
new file mode 100644
index 0000000000..5e90796ade
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlClientEventSource.cs
@@ -0,0 +1,614 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Text;
+using System.Diagnostics.Tracing;
+using System.Threading;
+
+namespace Microsoft.Data.SqlClient
+{
+ [EventSource(Name = "Microsoft.Data.SqlClient.EventSource")]
+ internal class SqlClientEventSource : EventSource
+ {
+ // Defines the singleton instance for the Resources ETW provider
+ internal static readonly SqlClientEventSource Log = new SqlClientEventSource();
+
+ private static long s_nextScopeId = 0;
+ private static long s_nextNotificationScopeId = 0;
+ private static long s_nextPoolerScopeId = 0;
+
+ ///
+ /// Defines EventId for BeginExecute (Reader, Scalar, NonQuery, XmlReader).
+ ///
+ private const int BeginExecuteEventId = 1;
+
+ ///
+ /// Defines EventId for EndExecute (Reader, Scalar, NonQuery, XmlReader).
+ ///
+ private const int EndExecuteEventId = 2;
+ 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;
+ 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)
+ ///
+ /// 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;
+
+ internal const EventKeywords Trace = (EventKeywords)1;
+
+ internal const EventKeywords TraceBin = (EventKeywords)2;
+
+ internal const EventKeywords Scope = (EventKeywords)4;
+
+ 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;
+
+ internal const EventKeywords StateDump = (EventKeywords)1024;
+ }
+ #endregion
+
+ public static class Tasks // this name is important for EventSource
+ {
+ /// Task that tracks sql command execute.
+ public const EventTask ExecuteCommand = (EventTask)1;
+ }
+
+ #region Enable/Disable Events
+ [NonEvent]
+ internal bool IsTraceEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Trace);
+
+ [NonEvent]
+ internal bool IsTraceBinEnabled() => Log.IsEnabled(EventLevel.Informational, Keywords.TraceBin);
+
+ [NonEvent]
+ internal bool IsScopeEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Scope);
+
+ [NonEvent]
+ internal bool IsPoolerScopeEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.PoolerScope);
+
+ [NonEvent]
+ internal bool IsCorrelationEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Correlation);
+
+ [NonEvent]
+ internal bool IsNotificationScopeEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.NotificationScope);
+
+ [NonEvent]
+ internal bool IsPoolingEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Pooling);
+
+ [NonEvent]
+ internal bool IsNotificationTraceEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.NotificationTrace);
+
+ [NonEvent]
+ internal bool IsPoolerTraceEnabled() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.PoolerTrace);
+
+ [NonEvent]
+ internal bool IsAdvanceTraceOn() => SqlClientEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Advanced);
+
+ [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.
+ [NonEvent]
+ internal void TraceEvent(string message, T0 args0)
+ {
+ if (Log.IsTraceEnabled())
+ {
+ TraceEvent(string.Format(message, args0));
+ }
+ }
+
+ [NonEvent]
+ internal void TraceEvent(string message)
+ {
+ if (Log.IsTraceEnabled())
+ {
+ Trace(message);
+ }
+ }
+
+ [NonEvent]
+ internal void TraceEvent(string message, T0 args0, T1 args1)
+ {
+ if (Log.IsTraceEnabled())
+ {
+ Trace(string.Format(message, args0, args1));
+ }
+ }
+
+ [NonEvent]
+ internal void TraceEvent(string message, T0 args0, T1 args1, T2 args2)
+ {
+ if (Log.IsTraceEnabled())
+ {
+ Trace(string.Format(message, args0, args1, args2));
+ }
+ }
+
+ [NonEvent]
+ internal void TraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3)
+ {
+ if (Log.IsTraceEnabled())
+ {
+ Trace(string.Format(message, args0, args1, args2, args3));
+ }
+ }
+
+ [NonEvent]
+ internal void TraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5)
+ {
+ if (Log.IsTraceEnabled())
+ {
+ Trace(string.Format(message, args0, args1, args2, args3, args4, args5));
+ }
+ }
+
+ [NonEvent]
+ internal void AdvanceTrace(string message)
+ {
+ if (Log.IsAdvanceTraceOn())
+ {
+ Trace(message);
+ }
+ }
+
+ [NonEvent]
+ internal void AdvanceTrace(string message, T0 args0)
+ {
+ if (Log.IsAdvanceTraceOn())
+ {
+ Trace(string.Format(message, args0));
+ }
+ }
+
+ [NonEvent]
+ internal void AdvanceTrace(string message, T0 args0, T1 args1)
+ {
+ if (Log.IsAdvanceTraceOn())
+ {
+ Trace(string.Format(message, args0, args1));
+ }
+ }
+
+ [NonEvent]
+ internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2)
+ {
+ if (Log.IsAdvanceTraceOn())
+ {
+ Trace(string.Format(message, args0, args1, args2));
+ }
+ }
+
+ [NonEvent]
+ internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3)
+ {
+ if (Log.IsAdvanceTraceOn())
+ {
+ Trace(string.Format(message, args0, args1, args2, args3));
+ }
+ }
+
+ [NonEvent]
+ internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5)
+ {
+ if (Log.IsAdvanceTraceOn())
+ {
+ Trace(string.Format(message, args0, args1, args2, args3, args4, args5));
+ }
+ }
+
+ [NonEvent]
+ internal void AdvanceTrace(string message, T0 args0, T1 args1, T2 args2, T3 args3, T4 args4, T5 args5, T6 args6, T7 args7)
+ {
+ if (Log.IsAdvanceTraceOn())
+ {
+ Trace(string.Format(message, args0, args1, args2, args3, args4, args5, args6, args7));
+ }
+ }
+
+ [NonEvent]
+ internal void AdvanceTraceBin(string message, T0 args0, T1 args1)
+ {
+ if (Log.IsAdvanceTraceOn())
+ {
+ TraceBin(string.Format(message, args0, args1));
+ }
+ }
+
+ [NonEvent]
+ internal long ScopeEnterEvent(string message, T0 args0)
+ {
+ if (Log.IsScopeEnabled())
+ {
+ return ScopeEnter(string.Format(message, args0));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long AdvanceScopeEnter(string message, T0 args0)
+ {
+ if (Log.IsAdvanceTraceOn())
+ {
+ return ScopeEnter(string.Format(message, args0));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long ScopeEnterEvent(string message)
+ {
+ if (Log.IsScopeEnabled())
+ {
+ return ScopeEnter(message);
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long ScopeEnterEvent(string message, T0 args0, T1 args1)
+ {
+ if (Log.IsScopeEnabled())
+ {
+ return ScopeEnter(string.Format(message, args0, args1));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2)
+ {
+ if (Log.IsScopeEnabled())
+ {
+ return ScopeEnter(string.Format(message, args0, args1, args2));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long ScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3)
+ {
+ if (Log.IsScopeEnabled())
+ {
+ return ScopeEnter(string.Format(message, args0, args1, args2, args3));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long PoolerScopeEnterEvent(string message, T0 args0)
+ {
+ if (Log.IsPoolerScopeEnabled())
+ {
+ return PoolerScopeEnter(string.Format(message, args0));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long NotificationsScopeEnterEvent(string message, T0 args0)
+ {
+ if (Log.IsNotificationScopeEnabled())
+ {
+ return NotificationsScopeEnter(string.Format(message, args0));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long NotificationsScopeEnterEvent(string message, T0 args0, T1 args1)
+ {
+ if (Log.IsNotificationScopeEnabled())
+ {
+ return NotificationsScopeEnter(string.Format(message, args0, args1));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long NotificationsScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2)
+ {
+ if (Log.IsNotificationScopeEnabled())
+ {
+ return NotificationsScopeEnter(string.Format(message, args0, args1, args2));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal long NotificationsScopeEnterEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3)
+ {
+ if (Log.IsNotificationScopeEnabled())
+ {
+ return NotificationsScopeEnter(string.Format(message, args0, args1, args2, args3));
+ }
+ return 0;
+ }
+
+ [NonEvent]
+ internal void PoolerTraceEvent(string message, T0 args0)
+ {
+ if (Log.IsPoolerTraceEnabled())
+ {
+ PoolerTrace(string.Format(message, args0));
+ }
+ }
+
+ [NonEvent]
+ internal void PoolerTraceEvent(string message, T0 args0, T1 args1)
+ {
+ if (Log.IsPoolerTraceEnabled())
+ {
+ PoolerTrace(string.Format(message, args0, args1));
+ }
+ }
+
+ [NonEvent]
+ internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2)
+ {
+ if (Log.IsPoolerTraceEnabled())
+ {
+ PoolerTrace(string.Format(message, args0, args1, args2));
+ }
+ }
+
+ [NonEvent]
+ internal void PoolerTraceEvent(string message, T0 args0, T1 args1, T2 args2, T3 args3)
+ {
+ if (Log.IsPoolerTraceEnabled())
+ {
+ PoolerTrace(string.Format(message, args0, args1, args2, args3));
+ }
+ }
+
+ [NonEvent]
+ internal void CorrelationTraceEvent