diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
index bc755d3486..759858f7e6 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -18,6 +18,8 @@
$(OutputPath)\$(TargetFramework)\Microsoft.Data.SqlClient.xml
true
Core $(BaseProduct)
+ true
+ $(NoWarn);IL2026;IL2057;IL2067;IL2070;IL2072;IL2075;IL2077;IL2080;IL2093;IL2111
portable
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicManager.NetCoreApp.cs
index bf007b6910..c7af3c9534 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicManager.NetCoreApp.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicManager.NetCoreApp.cs
@@ -23,7 +23,7 @@ internal sealed partial class SqlConfigurableRetryLogicLoader
/// Resolved type if it could resolve the type; otherwise, the `SqlConfigurableRetryFactory` type.
private static Type LoadType(string fullyQualifiedName)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(LoadType);
SqlClientEventSource.Log.TryTraceEvent(" Entry point.", TypeName, methodName);
var result = Type.GetType(fullyQualifiedName, AssemblyResolver, TypeResolver);
@@ -48,7 +48,7 @@ private static Type LoadType(string fullyQualifiedName)
///
private static string MakeFullPath(string directory, string assemblyName, string extension = ".dll")
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(MakeFullPath);
SqlClientEventSource.Log.TryTraceEvent(" Looking for '{2}' assembly in '{3}' directory."
, TypeName, methodName, assemblyName, directory);
string fullPath = Path.Combine(directory, assemblyName);
@@ -60,7 +60,7 @@ private static string MakeFullPath(string directory, string assemblyName, string
private static Assembly AssemblyResolver(AssemblyName arg)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(AssemblyResolver);
string fullPath = MakeFullPath(Environment.CurrentDirectory, arg.Name);
SqlClientEventSource.Log.TryTraceEvent(" Looking for '{2}' assembly by '{3}' full path."
@@ -76,7 +76,7 @@ private static Assembly AssemblyResolver(AssemblyName arg)
///
private static Assembly Default_Resolving(AssemblyLoadContext arg1, AssemblyName arg2)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(Default_Resolving);
string target = MakeFullPath(Environment.CurrentDirectory, arg2.Name);
SqlClientEventSource.Log.TryTraceEvent(" Looking for '{2}' assembly that is requested by '{3}' ALC from '{4}' path."
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
index 103af2ed2d..de09edc3f0 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/SNITcpHandle.cs
@@ -447,7 +447,7 @@ private static Socket Connect(string serverName, int port, TimeSpan timeout, boo
catch (Exception e)
{
SqlClientEventSource.Log.TrySNITraceEvent(nameof(SNITCPHandle), EventType.ERR, "THIS EXCEPTION IS BEING SWALLOWED: {0}", args0: e?.Message);
- SqlClientEventSource.Log.TryAdvancedTraceEvent($"{nameof(SNITCPHandle)}.{System.Reflection.MethodBase.GetCurrentMethod().Name}{EventType.ERR}THIS EXCEPTION IS BEING SWALLOWED: {e}");
+ SqlClientEventSource.Log.TryAdvancedTraceEvent($"{nameof(SNITCPHandle)}.{nameof(Connect)}{EventType.ERR}THIS EXCEPTION IS BEING SWALLOWED: {e}");
}
}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAppContextSwitchManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAppContextSwitchManager.NetCoreApp.cs
index 928e543e7d..92a4e60487 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAppContextSwitchManager.NetCoreApp.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAppContextSwitchManager.NetCoreApp.cs
@@ -4,7 +4,6 @@
using System;
using System.Configuration;
-using System.Reflection;
namespace Microsoft.Data.SqlClient
{
@@ -20,7 +19,7 @@ internal sealed class SqlAppContextSwitchManager
///
internal static void ApplyContextSwitches(IAppContextSwitchOverridesSection appContextSwitches)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(ApplyContextSwitches);
SqlClientEventSource.Log.TryTraceEvent(" Entry point.", TypeName, methodName);
if (appContextSwitches != null)
{
@@ -32,7 +31,7 @@ internal static void ApplyContextSwitches(IAppContextSwitchOverridesSection appC
private static bool ApplySwitchValues(string[] switches)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(ApplySwitchValues);
SqlClientEventSource.Log.TryTraceEvent(" Entry point.", TypeName, methodName);
if (switches == null || switches.Length == 0 || switches.Length % 2 == 1)
diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicManager.LoadType.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicManager.LoadType.cs
index 5e9241c379..922006b47f 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicManager.LoadType.cs
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicManager.LoadType.cs
@@ -19,7 +19,7 @@ internal sealed partial class SqlConfigurableRetryLogicLoader
/// Resolved type if it could resolve the type; otherwise, the `SqlConfigurableRetryFactory` type.
private static Type LoadType(string fullyQualifiedName)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(LoadType);
var result = Type.GetType(fullyQualifiedName);
SqlClientEventSource.Log.TryTraceEvent(" The '{2}' type is resolved."
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
index 1791ad5d52..ca96328361 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
@@ -10,7 +10,6 @@ namespace Microsoft.Data.SqlClient
{
internal static partial class LocalAppContextSwitches
{
- private const string TypeName = nameof(LocalAppContextSwitches);
internal const string MakeReadAsyncBlockingString = @"Switch.Microsoft.Data.SqlClient.MakeReadAsyncBlocking";
internal const string LegacyRowVersionNullString = @"Switch.Microsoft.Data.SqlClient.LegacyRowVersionNullBehavior";
internal const string SuppressInsecureTLSWarningString = @"Switch.Microsoft.Data.SqlClient.SuppressInsecureTLSWarning";
@@ -30,7 +29,7 @@ static LocalAppContextSwitches()
catch (Exception e)
{
// Don't throw an exception for an invalid config file
- SqlClientEventSource.Log.TryTraceEvent(": {2}", TypeName, MethodBase.GetCurrentMethod().Name, e);
+ SqlClientEventSource.Log.TryTraceEvent(": {1}", nameof(LocalAppContextSwitches), e);
}
}
#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/AppConfigManager.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/AppConfigManager.cs
index 58b933e6f9..29cd2273b8 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/AppConfigManager.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/AppConfigManager.cs
@@ -4,7 +4,6 @@
using System;
using System.Configuration;
-using System.Reflection;
namespace Microsoft.Data.SqlClient
{
@@ -21,7 +20,7 @@ internal sealed class AppConfigManager
/// The specified `T` object or default value of `T` if the section doesn't exist.
public static T FetchConfigurationSection(string name)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(FetchConfigurationSection);
object section = null;
try
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/Common/SqlRetryLogic.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/Common/SqlRetryLogic.cs
index 01e4e69378..389cbd161f 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/Common/SqlRetryLogic.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/Common/SqlRetryLogic.cs
@@ -68,12 +68,12 @@ public override bool TryNextInterval(out TimeSpan intervalTime)
RetryIntervalEnumerator.MoveNext();
intervalTime = RetryIntervalEnumerator.Current;
SqlClientEventSource.Log.TryTraceEvent(" Next gap time will be '{2}' before the next retry number {3}",
- TypeName, MethodBase.GetCurrentMethod().Name, intervalTime, Current);
+ TypeName, nameof(TryNextInterval), intervalTime, Current);
}
else
{
SqlClientEventSource.Log.TryTraceEvent(" Current retry ({2}) has reached the maximum attempts (total attempts excluding the first run = {3}).",
- TypeName, MethodBase.GetCurrentMethod().Name, Current, NumberOfTries - 1);
+ TypeName, nameof(TryNextInterval), Current, NumberOfTries - 1);
}
return result;
}
@@ -89,7 +89,7 @@ public override bool RetryCondition(object sender)
&& (PreCondition == null || PreCondition.Invoke(command.CommandText)); // if it contains an invalid command to retry
SqlClientEventSource.Log.TryTraceEvent(" (retry condition = '{2}') Avoids retry if it runs in a transaction or is skipped in the command's statement checking.",
- TypeName, MethodBase.GetCurrentMethod().Name, result);
+ TypeName, nameof(RetryCondition), result);
}
return result;
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/Common/SqlRetryLogicProvider.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/Common/SqlRetryLogicProvider.cs
index 758e6fe2be..d9d44235b5 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/Common/SqlRetryLogicProvider.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/Common/SqlRetryLogicProvider.cs
@@ -6,7 +6,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
@@ -192,7 +191,7 @@ private Exception CreateException(IList exceptions, SqlRetryLogicBase
if (!manualCancellation)
{
SqlClientEventSource.Log.TryTraceEvent(" Exiting retry scope (exceeded the max allowed attempts = {2}).",
- TypeName, MethodBase.GetCurrentMethod().Name, retryLogic.NumberOfTries);
+ TypeName, nameof(CreateException), retryLogic.NumberOfTries);
}
_retryLogicPool.Add(retryLogic);
return result;
@@ -200,7 +199,7 @@ private Exception CreateException(IList exceptions, SqlRetryLogicBase
private void ApplyRetryingEvent(object sender, SqlRetryLogicBase retryLogic, TimeSpan intervalTime, List exceptions, Exception lastException)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(ApplyRetryingEvent);
if (Retrying != null)
{
var retryEventArgs = new SqlRetryingEventArgs(retryLogic.Current, intervalTime, exceptions);
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryFactory.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryFactory.cs
index 16bae39008..0e87c10aa6 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryFactory.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryFactory.cs
@@ -6,7 +6,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
-using System.Reflection;
namespace Microsoft.Data.SqlClient
{
@@ -123,7 +122,7 @@ private static bool TransientErrorsCondition(Exception e, IEnumerable retri
}
if (retriable)
{
- SqlClientEventSource.Log.TryTraceEvent(" Found a transient error: number = <{2}>, message = <{3}>", nameof(SqlConfigurableRetryFactory), MethodBase.GetCurrentMethod().Name, item.Number, item.Message);
+ SqlClientEventSource.Log.TryTraceEvent(" Found a transient error: number = <{2}>, message = <{3}>", nameof(SqlConfigurableRetryFactory), nameof(TransientErrorsCondition), item.Number, item.Message);
result = true;
break;
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicLoader.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicLoader.cs
index 838dd9f9da..dfc96c566a 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicLoader.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Reliability/SqlConfigurableRetryLogicLoader.cs
@@ -55,7 +55,7 @@ public SqlConfigurableRetryLogicLoader(ISqlConfigurableRetryConnectionSection co
private static SqlRetryLogicBaseProvider CreateRetryLogicProvider(string sectionName, ISqlConfigurableRetryConnectionSection configSection)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(CreateRetryLogicProvider);
SqlClientEventSource.Log.TryTraceEvent(" Entry point.", TypeName, methodName);
try
@@ -102,7 +102,7 @@ private static SqlRetryLogicBaseProvider CreateRetryLogicProvider(string section
private static SqlRetryLogicBaseProvider ResolveRetryLogicProvider(string configurableRetryType, string retryMethod, SqlRetryLogicOption option)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(ResolveRetryLogicProvider);
SqlClientEventSource.Log.TryTraceEvent(" Entry point.", TypeName, methodName);
if (string.IsNullOrEmpty(retryMethod))
@@ -156,7 +156,7 @@ private static SqlRetryLogicBaseProvider ResolveRetryLogicProvider(string config
private static object CreateInstance(Type type, string retryMethodName, SqlRetryLogicOption option)
{
- string methodName = MethodBase.GetCurrentMethod().Name;
+ string methodName = nameof(CreateInstance);
SqlClientEventSource.Log.TryTraceEvent(" Entry point.", TypeName, methodName);
if (type == typeof(SqlConfigurableRetryFactory) || type == null)
@@ -257,7 +257,7 @@ private static object[] PrepareParamValues(ParameterInfo[] parameterInfos, SqlRe
}
}
SqlClientEventSource.Log.TryTraceEvent(" Parameters are prepared to invoke the `{2}.{3}()` method."
- , TypeName, MethodBase.GetCurrentMethod().Name, typeof(SqlConfigurableRetryFactory).FullName, retryMethod);
+ , TypeName, nameof(PrepareParamValues), typeof(SqlConfigurableRetryFactory).FullName, retryMethod);
return funcParams;
}