From 4b8c08185fe331a32abf49e4a566e3404b54974a Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 09:52:40 -0700 Subject: [PATCH 1/7] Update config Section name --- .../SqlClient/SqlAuthenticationProviderManager.NetCoreApp.cs | 4 ++-- .../Data/SqlClient/SqlAuthenticationProviderManager.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 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 eb3e03b1e2..7e925136b9 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 @@ -25,7 +25,7 @@ static SqlAuthenticationProviderManager() 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 SqlClientAuthenticationProviders. ConfigurationManager failed to load due to configuration errors: {0}", e); } Instance = new SqlAuthenticationProviderManager(configurationSection); @@ -129,7 +129,7 @@ private static SqlAuthenticationMethod AuthenticationEnumFromString(string authe /// internal class SqlAuthenticationProviderConfigurationSection : ConfigurationSection { - public const string Name = "SqlAuthenticationProviders"; + public const string Name = "SqlClientAuthenticationProviders"; /// /// User-defined auth providers. 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 144a782acb..9f5b4f8a35 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 @@ -32,7 +32,7 @@ static SqlAuthenticationProviderManager() 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 SqlClientAuthenticationProviders. ConfigurationManager failed to load due to configuration errors: {0}", e); } Instance = new SqlAuthenticationProviderManager(configurationSection); Instance.SetProvider(SqlAuthenticationMethod.ActiveDirectoryIntegrated, activeDirectoryAuthProvider); @@ -196,7 +196,7 @@ private static string GetProviderType(SqlAuthenticationProvider provider) /// internal class SqlAuthenticationProviderConfigurationSection : ConfigurationSection { - public const string Name = "SqlAuthenticationProviders"; + public const string Name = "SqlClientAuthenticationProviders"; /// /// User-defined auth providers. From 44b9a9ae6a45f6b3f16f12cb993ecf8e151b1636 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 12:24:22 -0700 Subject: [PATCH 2/7] Update version info --- roadmap.md | 2 +- tools/props/Versions.props | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/roadmap.md b/roadmap.md index a9c8f5308d..206c8dd334 100644 --- a/roadmap.md +++ b/roadmap.md @@ -14,7 +14,7 @@ The Microsoft.Data.SqlClient roadmap communicates project priorities for evolvin | Microsoft.Data.SqlClient v1.0 (servicing) | As needed (see also [1.0 releases](https://github.com/dotnet/sqlclient/blob/master/release-notes/1.0)) | Closed | | Microsoft.Data.SqlClient v1.1 (servicing) | As needed (see also [1.1 releases](https://github.com/dotnet/sqlclient/blob/master/release-notes/1.1)) | Closed | | Microsoft.Data.SqlClient v2.0 (servicing) | As needed (see also [2.0 releases](https://github.com/dotnet/sqlclient/blob/master/release-notes/2.0)) | Closed | -| Microsoft.Data.SqlClient v2.1 | GA (General Availability) estimated for November 2020 | [SqlClient 2.1.0](https://github.com/dotnet/SqlClient/projects/6) | +| Microsoft.Data.SqlClient v3.0 | GA (General Availability) estimated for November 2020 | [SqlClient 3.0.0](https://github.com/dotnet/SqlClient/projects/6) | > Note: Dates are calendar year (as opposed to fiscal year). diff --git a/tools/props/Versions.props b/tools/props/Versions.props index 16c550dfd6..346ba43ddd 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -2,12 +2,12 @@ 1.0.0.0 - + - - 2.0.20168.4 + + 3.0.0.0 1.0.0-beta.18578.2 - 2.1.0-dev + 3.0.0-dev $(NugetPackageVersion) From 6be125ae1ce7a30fdd5403b3a3b3c054e75ec405 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 18:15:26 -0700 Subject: [PATCH 3/7] Update for backwards compatibility --- ...uthenticationProviderManager.NetCoreApp.cs | 40 +++++++++++++++++-- .../SqlAuthenticationProviderManager.cs | 38 ++++++++++++++++-- 2 files changed, 70 insertions(+), 8 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 7e925136b9..945f72350c 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,12 +20,18 @@ static SqlAuthenticationProviderManager() try { - configurationSection = (SqlAuthenticationProviderConfigurationSection)ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); + // New configuration section "SqlClientAuthenticationProviders" for Microsoft.Data.SqlClient accepted to avoid conflicts with older one. + configurationSection = FetchConfigurationSection(SqlClientAuthenticationProviderConfigurationSection.Name); + if (null == configurationSection) + { + // If configuration 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 SqlClientAuthenticationProviders. 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); @@ -49,7 +55,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; } @@ -105,6 +111,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}.", name); + } + } + return default; + } + private static SqlAuthenticationMethod AuthenticationEnumFromString(string authentication) { switch (authentication.ToLowerInvariant()) @@ -129,7 +153,7 @@ private static SqlAuthenticationMethod AuthenticationEnumFromString(string authe /// internal class SqlAuthenticationProviderConfigurationSection : ConfigurationSection { - public const string Name = "SqlClientAuthenticationProviders"; + public const string Name = "SqlAuthenticationProviders"; /// /// User-defined auth providers. @@ -143,5 +167,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 9f5b4f8a35..2559fc939e 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 @@ -27,12 +27,18 @@ static SqlAuthenticationProviderManager() SqlAuthenticationProviderConfigurationSection configurationSection = null; try { - configurationSection = (SqlAuthenticationProviderConfigurationSection)ConfigurationManager.GetSection(SqlAuthenticationProviderConfigurationSection.Name); + // New configuration section "SqlClientAuthenticationProviders" for Microsoft.Data.SqlClient accepted to avoid conflicts with older one. + configurationSection = FetchConfigurationSection(SqlClientAuthenticationProviderConfigurationSection.Name); + if (null == configurationSection) + { + // If configuration 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 SqlClientAuthenticationProviders. 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); @@ -62,7 +68,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; } @@ -164,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}.", name); + } + } + return default; + } + private static SqlAuthenticationMethod AuthenticationEnumFromString(string authentication) { switch (authentication.ToLowerInvariant()) @@ -211,11 +235,17 @@ 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 { - /// public abstract void Initialize(); } From cb48d9a3fa48cbd448760285fd5dc6eb42986282 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 18:16:39 -0700 Subject: [PATCH 4/7] Revert version changes --- roadmap.md | 2 +- tools/props/Versions.props | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/roadmap.md b/roadmap.md index 206c8dd334..a9c8f5308d 100644 --- a/roadmap.md +++ b/roadmap.md @@ -14,7 +14,7 @@ The Microsoft.Data.SqlClient roadmap communicates project priorities for evolvin | Microsoft.Data.SqlClient v1.0 (servicing) | As needed (see also [1.0 releases](https://github.com/dotnet/sqlclient/blob/master/release-notes/1.0)) | Closed | | Microsoft.Data.SqlClient v1.1 (servicing) | As needed (see also [1.1 releases](https://github.com/dotnet/sqlclient/blob/master/release-notes/1.1)) | Closed | | Microsoft.Data.SqlClient v2.0 (servicing) | As needed (see also [2.0 releases](https://github.com/dotnet/sqlclient/blob/master/release-notes/2.0)) | Closed | -| Microsoft.Data.SqlClient v3.0 | GA (General Availability) estimated for November 2020 | [SqlClient 3.0.0](https://github.com/dotnet/SqlClient/projects/6) | +| Microsoft.Data.SqlClient v2.1 | GA (General Availability) estimated for November 2020 | [SqlClient 2.1.0](https://github.com/dotnet/SqlClient/projects/6) | > Note: Dates are calendar year (as opposed to fiscal year). diff --git a/tools/props/Versions.props b/tools/props/Versions.props index 346ba43ddd..16c550dfd6 100644 --- a/tools/props/Versions.props +++ b/tools/props/Versions.props @@ -2,12 +2,12 @@ 1.0.0.0 - + - - 3.0.0.0 + + 2.0.20168.4 1.0.0-beta.18578.2 - 3.0.0-dev + 2.1.0-dev $(NugetPackageVersion) From a6ee0e7cb9530245cbb32197372e0878bc1cfc05 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 20 Aug 2020 18:24:54 -0700 Subject: [PATCH 5/7] 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 945f72350c..fb7320ee87 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 @@ -123,7 +123,7 @@ private static T FetchConfigurationSection(string name) } else { - SqlClientEventSource.Log.TraceEvent("Found a custom {0} configuration but it is not of type {0}.", 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 2559fc939e..32d9585d4b 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}.", name); + SqlClientEventSource.Log.TraceEvent("Found a custom {0} configuration but it is not of type {1}.", name, t.FullName); } } return default; From f2668cb2509d675769aee4eccf1a312101e9e4a4 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 21 Aug 2020 09:45:34 -0700 Subject: [PATCH 6/7] Revert original name change --- .../Data/SqlClient/SqlAuthenticationProviderManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 32d9585d4b..afa7ff0f75 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 @@ -220,7 +220,7 @@ private static string GetProviderType(SqlAuthenticationProvider provider) /// internal class SqlAuthenticationProviderConfigurationSection : ConfigurationSection { - public const string Name = "SqlClientAuthenticationProviders"; + public const string Name = "SqlAuthenticationProviders"; /// /// User-defined auth providers. From 39ddd7ddad3e07fe23274a5fdab4df165eb922bf Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 21 Aug 2020 11:20:10 -0700 Subject: [PATCH 7/7] 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 fb7320ee87..52be62e901 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 @@ -117,7 +117,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 afa7ff0f75..af9a603898 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; }