From 2c30cf2c0d2317d472acd95289e16319968c8405 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 10:24:04 -0700 Subject: [PATCH 1/9] Fix configSection collision with System.Data.SqlClient type. --- .../SqlAuthenticationProviderManager.NetCoreApp.cs | 6 +++++- .../Data/SqlClient/SqlAuthenticationProviderManager.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index 3d6f135df1..58664d0f83 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -20,7 +20,11 @@ static SqlAuthenticationProviderManager() try { - configurationSection = (SqlAuthenticationProviderConfigurationSection)ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); + var section = ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); + if (((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) + { + configurationSection = (SqlAuthenticationProviderConfigurationSection)section; + } } catch (ConfigurationErrorsException e) { 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 de50e441b8..9df7100e78 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 @@ -28,7 +28,11 @@ static SqlAuthenticationProviderManager() SqlAuthenticationProviderConfigurationSection configurationSection = null; try { - configurationSection = (SqlAuthenticationProviderConfigurationSection)ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); + var section = ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); + if (((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) + { + configurationSection = (SqlAuthenticationProviderConfigurationSection)section; + } } catch (ConfigurationErrorsException e) { From 3699715f9509da94cbe5f13c56e5c9a94fcb48ca Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 10:42:47 -0700 Subject: [PATCH 2/9] Update AssemblyVersion for 2.0-servicing branch --- tools/props/Versions.props | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/props/Versions.props b/tools/props/Versions.props index 817a1dbc1a..a7d1d28d1b 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -2,7 +2,10 @@ 1.0.0.0 - $(AssemblyFileVersion) + + + + 2.0.20168.4 1.0.0-beta.18578.2 2.0.0-dev $(NugetPackageVersion) From ccc964ffb28f3b780e930701ef5ee61009bc4c48 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 10:51:59 -0700 Subject: [PATCH 3/9] Null checks --- .../SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs | 2 +- .../Data/SqlClient/SqlAuthenticationProviderManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index 58664d0f83..d656a00e6d 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -21,7 +21,7 @@ static SqlAuthenticationProviderManager() try { var section = ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); - if (((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) + if (section != null && ((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) { configurationSection = (SqlAuthenticationProviderConfigurationSection)section; } 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 9df7100e78..9eb3ad8a2f 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 @@ -29,7 +29,7 @@ static SqlAuthenticationProviderManager() try { var section = ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); - if (((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) + if (section != null && ((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) { configurationSection = (SqlAuthenticationProviderConfigurationSection)section; } From 68cf979131b4e69488ab7c090dc4f259d45597a7 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 11:43:29 -0700 Subject: [PATCH 4/9] Minor edit --- tools/props/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/props/Versions.props b/tools/props/Versions.props index a7d1d28d1b..086c8adb91 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -4,7 +4,7 @@ 1.0.0.0 - + 2.0.20168.4 1.0.0-beta.18578.2 2.0.0-dev From 62152e4648e153b12fea9e30e3322b76bcc4d49f Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 11:56:50 -0700 Subject: [PATCH 5/9] Minor edit --- .../SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs | 2 +- .../Data/SqlClient/SqlAuthenticationProviderManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index d656a00e6d..580b3da65d 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -21,7 +21,7 @@ static SqlAuthenticationProviderManager() try { var section = ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); - if (section != null && ((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) + if (null != section && ((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) { configurationSection = (SqlAuthenticationProviderConfigurationSection)section; } 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 9eb3ad8a2f..cc3e98ce41 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 @@ -29,7 +29,7 @@ static SqlAuthenticationProviderManager() try { var section = ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); - if (section != null && ((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) + if (null != section && ((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) { configurationSection = (SqlAuthenticationProviderConfigurationSection)section; } From 3fc3ded2f489076b9b4e024f23df0be7dbecb8df Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 18:02:59 -0700 Subject: [PATCH 6/9] Update to adding new section --- ...uthenticationProviderManager.NetCoreApp.cs | 38 ++++++++++++++++--- .../SqlAuthenticationProviderManager.cs | 37 +++++++++++++++--- 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index 580b3da65d..724fd283c7 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -20,16 +20,18 @@ static SqlAuthenticationProviderManager() try { - var section = ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); - if (null != section && ((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) + // New configuration section for Microsoft.Data.SqlClient accepted to avoid conflicts with older one. + configurationSection = FetchConfigurationSection(SqlClientAuthenticationProviderConfigurationSection.Name); + if (null == configurationSection) { - configurationSection = (SqlAuthenticationProviderConfigurationSection)section; + // If section is not yet found, try with old Configuration Section name for backwards compatibility + configurationSection = FetchConfigurationSection(SqlAuthenticationProviderConfigurationSection.Name); } } catch (ConfigurationErrorsException e) { // Don't throw an error for invalid config files - SqlClientEventSource.Log.TraceEvent("Unable to load custom SqlAuthenticationProviders. ConfigurationManager failed to load due to configuration errors: {0}", e); + SqlClientEventSource.Log.TraceEvent("Unable to load custom SqlAuthenticationProviders or SqlClientAuthenticationProviders. ConfigurationManager failed to load due to configuration errors: {0}", e); } Instance = new SqlAuthenticationProviderManager(configurationSection); @@ -52,7 +54,7 @@ public SqlAuthenticationProviderManager(SqlAuthenticationProviderConfigurationSe if (configSection == null) { - _sqlAuthLogger.LogInfo(_typeName, methodName, "No SqlAuthProviders configuration section found."); + _sqlAuthLogger.LogInfo(_typeName, methodName, "Neither SqlClientAuthenticationProviders nor SqlAuthenticationProviders configuration section found."); return; } @@ -108,6 +110,24 @@ public SqlAuthenticationProviderManager(SqlAuthenticationProviderConfigurationSe } } + private static T FetchConfigurationSection(string name) + { + Type t = typeof(T); + object section = ConfigurationManager.GetSection(name); + if (null != section) + { + if (((ConfigurationSection)section).GetType() == t) + { + return (T)section; + } + else + { + SqlClientEventSource.Log.TraceEvent("Found a custom {0} configuration but it is not of type {0}.", t.Name); + } + } + return default; + } + private static SqlAuthenticationMethod AuthenticationEnumFromString(string authentication) { switch (authentication.ToLowerInvariant()) @@ -144,5 +164,13 @@ internal class SqlAuthenticationProviderConfigurationSection : ConfigurationSect [ConfigurationProperty("initializerType")] public string InitializerType => base["initializerType"] as string; } + + /// + /// The configuration section definition for reading app.config. + /// + internal class SqlClientAuthenticationProviderConfigurationSection : SqlAuthenticationProviderConfigurationSection + { + public new const string Name = "SqlClientAuthenticationProviders"; + } } } 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 cc3e98ce41..1a03628dc6 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 @@ -28,16 +28,18 @@ static SqlAuthenticationProviderManager() SqlAuthenticationProviderConfigurationSection configurationSection = null; try { - var section = ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); - if (null != section && ((ConfigurationSection)section).GetType().FullName.Contains("Microsoft.Data.SqlClient.SqlAuthenticationProviderConfigurationSection")) + // New configuration section for Microsoft.Data.SqlClient accepted to avoid conflicts with older one. + configurationSection = FetchConfigurationSection(SqlClientAuthenticationProviderConfigurationSection.Name); + if (null == configurationSection) { - configurationSection = (SqlAuthenticationProviderConfigurationSection)section; + // If section is not yet found, try with old Configuration Section name for backwards compatibility + configurationSection = FetchConfigurationSection(SqlAuthenticationProviderConfigurationSection.Name); } } catch (ConfigurationErrorsException e) { // Don't throw an error for invalid config files - SqlClientEventSource.Log.TraceEvent("Unable to load custom SqlAuthenticationProviders. ConfigurationManager failed to load due to configuration errors: {0}", e); + SqlClientEventSource.Log.TraceEvent("Unable to load custom SqlAuthenticationProviders or SqlClientAuthenticationProvider. ConfigurationManager failed to load due to configuration errors: {0}", e); } Instance = new SqlAuthenticationProviderManager(configurationSection); Instance.SetProvider(SqlAuthenticationMethod.ActiveDirectoryIntegrated, activeDirectoryAuthProvider); @@ -66,7 +68,7 @@ public SqlAuthenticationProviderManager(SqlAuthenticationProviderConfigurationSe if (configSection == null) { - _sqlAuthLogger.LogInfo(_typeName, methodName, "No SqlAuthProviders configuration section found."); + _sqlAuthLogger.LogInfo(_typeName, methodName, "Neither SqlClientAuthenticationProvider nor SqlAuthenticationProviders configuration section found."); return; } @@ -168,6 +170,24 @@ public bool SetProvider(SqlAuthenticationMethod authenticationMethod, SqlAuthent return true; } + private static T FetchConfigurationSection(string name) + { + Type t = typeof(T); + object section = ConfigurationManager.GetSection(name); + if (null != section) + { + if (((ConfigurationSection)section).GetType() == t) + { + return (T)section; + } + else + { + SqlClientEventSource.Log.TraceEvent("Found a custom {0} configuration but it is not of type {0}.", t.Name); + } + } + return default; + } + private static SqlAuthenticationMethod AuthenticationEnumFromString(string authentication) { switch (authentication.ToLowerInvariant()) @@ -213,6 +233,13 @@ internal class SqlAuthenticationProviderConfigurationSection : ConfigurationSect public string InitializerType => base["initializerType"] as string; } + /// + /// The configuration section definition for reading app.config. + /// + internal class SqlClientAuthenticationProviderConfigurationSection : SqlAuthenticationProviderConfigurationSection + { + public new const string Name = "SqlClientAuthenticationProviders"; + } /// public abstract class SqlAuthenticationInitializer From 957671342267807d0b41dfda20fd56751b7fffcc Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 18:04:39 -0700 Subject: [PATCH 7/9] spell --- .../Data/SqlClient/SqlAuthenticationProviderManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 1a03628dc6..fa97f1ba7f 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 @@ -39,7 +39,7 @@ static SqlAuthenticationProviderManager() catch (ConfigurationErrorsException e) { // Don't throw an error for invalid config files - SqlClientEventSource.Log.TraceEvent("Unable to load custom SqlAuthenticationProviders or SqlClientAuthenticationProvider. ConfigurationManager failed to load due to configuration errors: {0}", e); + SqlClientEventSource.Log.TraceEvent("Unable to load custom SqlAuthenticationProviders or SqlClientAuthenticationProviders. ConfigurationManager failed to load due to configuration errors: {0}", e); } Instance = new SqlAuthenticationProviderManager(configurationSection); Instance.SetProvider(SqlAuthenticationMethod.ActiveDirectoryIntegrated, activeDirectoryAuthProvider); @@ -68,7 +68,7 @@ public SqlAuthenticationProviderManager(SqlAuthenticationProviderConfigurationSe if (configSection == null) { - _sqlAuthLogger.LogInfo(_typeName, methodName, "Neither SqlClientAuthenticationProvider nor SqlAuthenticationProviders configuration section found."); + _sqlAuthLogger.LogInfo(_typeName, methodName, "Neither SqlClientAuthenticationProviders nor SqlAuthenticationProviders configuration section found."); return; } From 5431660a63eb9a5c9c343a5d91679f1015723fdc Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 18:23:49 -0700 Subject: [PATCH 8/9] touch-ups --- .../SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs | 2 +- .../Data/SqlClient/SqlAuthenticationProviderManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index 724fd283c7..0f0f30b032 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -122,7 +122,7 @@ private static T FetchConfigurationSection(string name) } else { - SqlClientEventSource.Log.TraceEvent("Found a custom {0} configuration but it is not of type {0}.", t.Name); + SqlClientEventSource.Log.TraceEvent("Found a custom {0} configuration but it is not of type {1}.", name, t.FullName); } } return default; 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 fa97f1ba7f..e419744c7d 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 @@ -182,7 +182,7 @@ private static T FetchConfigurationSection(string name) } else { - SqlClientEventSource.Log.TraceEvent("Found a custom {0} configuration but it is not of type {0}.", t.Name); + SqlClientEventSource.Log.TraceEvent("Found a custom {0} configuration but it is not of type {1}.", name, t.FullName); } } return default; From bf784824d0dd53d359eaea58cd25855b4466cd02 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 21 Aug 2020 11:21:20 -0700 Subject: [PATCH 9/9] Apply review feedback --- .../SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs | 2 +- .../Data/SqlClient/SqlAuthenticationProviderManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs index 0f0f30b032..e343a7ec39 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs @@ -116,7 +116,7 @@ private static T FetchConfigurationSection(string name) object section = ConfigurationManager.GetSection(name); if (null != section) { - if (((ConfigurationSection)section).GetType() == t) + if (section is ConfigurationSection configSection && configSection.GetType() == t) { return (T)section; } 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 e419744c7d..869381e0bd 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 @@ -176,7 +176,7 @@ private static T FetchConfigurationSection(string name) object section = ConfigurationManager.GetSection(name); if (null != section) { - if (((ConfigurationSection)section).GetType() == t) + if (section is ConfigurationSection configSection && configSection.GetType() == t) { return (T)section; }