Update Microsoft.Data.SqlClient to v5.0.1 (#1708)

This commit is contained in:
Cheena Malhotra
2022-10-24 20:10:04 -07:00
committed by GitHub
parent 3be806ddce
commit c0f8482e26
30 changed files with 416 additions and 313 deletions

View File

@@ -91,14 +91,6 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "asynchronousProcessing",
DisplayName = "Asynchronous processing enabled",
Description = "When true, enables usage of the Asynchronous functionality in the .Net Framework Data Provider",
ValueType = ConnectionOption.ValueTypeBoolean,
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "connectTimeout",
DisplayName = "Connect timeout",

View File

@@ -31,8 +31,9 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.OperationalInsights" />
<PackageReference Include="Microsoft.SqlServer.DACFx" />
<PackageReference Include="Microsoft.SqlServer.DacFx" />
<PackageReference Include="Microsoft.SqlServer.Management.SmoMetadataProvider" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" />
<PackageReference Include="System.Text.Encoding.CodePages" />
<PackageReference Include="Microsoft.Azure.Kusto.Data" />
<PackageReference Include="System.Net.Http" />

View File

@@ -86,7 +86,7 @@ namespace Microsoft.SqlTools.Utility
enumValue = Enum.Parse(t, value);
return true;
}
catch(Exception)
catch (Exception)
{
enumValue = default(T);
return false;

View File

@@ -155,12 +155,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
}
}
if (fullFileName == null)
{
fullFileName = Path.GetFullPath(fileName);
}
return fullFileName;
return fullFileName ?? Path.GetFullPath(fileName);
}
catch (ArgumentException)
{

View File

@@ -128,15 +128,7 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser.ExecutionEngineCode
internal Dictionary<string, string> Variables
{
get
{
if (cmdVariables == null)
{
cmdVariables = new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase);
}
return cmdVariables;
}
get => cmdVariables ??= new Dictionary<string, string>(StringComparer.CurrentCultureIgnoreCase);
}
#endregion
}

View File

@@ -608,18 +608,10 @@ namespace Microsoft.SqlTools.ServiceLayer.BatchParser
}
internal void RaiseError(ErrorCode errorCode, string message = null)
{
RaiseError(errorCode, LookaheadToken, message);
}
=> RaiseError(errorCode, LookaheadToken, message);
internal static void RaiseError(ErrorCode errorCode, Token token, string message = null)
{
if (message == null)
{
message = string.Format(CultureInfo.CurrentCulture, SR.BatchParser_IncorrectSyntax, token.Text);
}
throw new BatchParserException(errorCode, token, message);
}
=> throw new BatchParserException(errorCode, token, message ?? string.Format(CultureInfo.CurrentCulture, SR.BatchParser_IncorrectSyntax, token.Text));
internal string ResolveVariables(Token inputToken, int offset, List<VariableReference> variableRefs)
{

View File

@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Targeting netstandard2.0 so that other things such as PS cmdlets can use this which need to support a wider range of machines -->
<TargetFramework>netstandard2.0</TargetFramework>
<!-- Targeting both net6.0 and net472 so that other things such as PS cmdlets can use this which need to support a wider range of machines -->
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<Nullable>disable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>

View File

@@ -276,10 +276,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
Debug.Assert(conn.State == ConnectionState.Open, "connection passed to ExecuteNonQuery should be open.");
cmd = conn.CreateCommand();
if (initializeCommand == null)
{
initializeCommand = SetCommandTimeout;
}
initializeCommand ??= SetCommandTimeout;
initializeCommand(cmd);
cmd.CommandText = commandText;
@@ -331,10 +329,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
Debug.Assert(conn.State == ConnectionState.Open, "connection passed to ExecuteScalar should be open.");
cmd = conn.CreateCommand();
if (initializeCommand == null)
{
initializeCommand = SetCommandTimeout;
}
initializeCommand ??= SetCommandTimeout;
initializeCommand(cmd);
cmd.CommandText = commandText;
@@ -384,11 +380,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
{
cmd = conn.CreateCommand();
if (initializeCommand == null)
{
initializeCommand = SetCommandTimeout;
}
initializeCommand ??= SetCommandTimeout;
initializeCommand(cmd);
cmd.CommandText = commandText;

View File

@@ -478,10 +478,7 @@ SET NUMERIC_ROUNDABORT OFF;";
{
// Verify whether or not the connection is valid and is open. This code may be retried therefore
// it is important to ensure that a connection is re-established should it have previously failed.
if (command.Connection == null)
{
command.Connection = this;
}
command.Connection ??= this;
if (command.Connection.State != ConnectionState.Open)
{

View File

@@ -91,14 +91,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "asynchronousProcessing",
DisplayName = "Asynchronous processing enabled",
Description = "When true, enables usage of the Asynchronous functionality in the .Net Framework Data Provider",
ValueType = ConnectionOption.ValueTypeBoolean,
GroupName = "Initialization"
},
new ConnectionOption
{
Name = "connectTimeout",
DisplayName = "Connect timeout",
@@ -152,10 +144,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
{
Name = "encrypt",
DisplayName = "Encrypt",
Description =
"When true, SQL Server uses SSL encryption for all data sent between the client and server if the servers has a certificate installed",
Description = "When set, SQL Server uses provided setting for SSL encryption for all data sent between the client and server.",
ValueType = ConnectionOption.ValueTypeCategory,
GroupName = "Security",
ValueType = ConnectionOption.ValueTypeBoolean
CategoryValues = new CategoryValue[] {
new CategoryValue { DisplayName = "Optional", Name = "Optional" },
new CategoryValue { DisplayName = "Mandatory", Name = "Mandatory" },
new CategoryValue { DisplayName = "Strict", Name = "Strict" }
}
},
new ConnectionOption
{
@@ -174,6 +170,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
ValueType = ConnectionOption.ValueTypeBoolean
},
new ConnectionOption
{
Name = "hostNameInCertificate",
DisplayName = "HostNameInCertificate",
Description = "Specifies host name in certificate to be used for certificate validation, when encryption is enabled.",
GroupName = "Security",
ValueType = ConnectionOption.ValueTypeString,
},
new ConnectionOption
{
Name = "attachedDBFileName",
DisplayName = "Attached DB file name",

View File

@@ -410,7 +410,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
if (response?.ErrorNumber == 40613)
{
counter++;
if(counter != MaxServerlessReconnectTries) {
if (counter != MaxServerlessReconnectTries)
{
Logger.Information($"Database for connection {connectionInfo.OwnerUri} is paused, retrying connection. Attempt #{counter}");
}
}
@@ -1299,14 +1300,26 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
connectionBuilder.EnclaveAttestationUrl = connectionDetails.EnclaveAttestationUrl;
}
if (connectionDetails.Encrypt.HasValue)
if (!string.IsNullOrEmpty(connectionDetails.Encrypt))
{
connectionBuilder.Encrypt = connectionDetails.Encrypt.Value;
connectionBuilder.Encrypt = connectionDetails.Encrypt.ToLowerInvariant() switch
{
"optional" or "false" or "no" => SqlConnectionEncryptOption.Optional,
"mandatory" or "true" or "yes" => SqlConnectionEncryptOption.Mandatory,
"strict" => SqlConnectionEncryptOption.Strict,
_ => throw new ArgumentException(SR.ConnectionServiceConnStringInvalidEncryptOption(connectionDetails.Encrypt))
};
}
if (connectionDetails.TrustServerCertificate.HasValue)
{
connectionBuilder.TrustServerCertificate = connectionDetails.TrustServerCertificate.Value;
}
if (!string.IsNullOrEmpty(connectionDetails.HostNameInCertificate))
{
connectionBuilder.HostNameInCertificate = connectionDetails.HostNameInCertificate;
}
if (connectionDetails.PersistSecurityInfo.HasValue)
{
connectionBuilder.PersistSecurityInfo = connectionDetails.PersistSecurityInfo.Value;
@@ -1471,8 +1484,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection
ColumnEncryptionSetting = builder.ColumnEncryptionSetting.ToString(),
EnclaveAttestationProtocol = builder.AttestationProtocol == SqlConnectionAttestationProtocol.NotSpecified ? null : builder.AttestationProtocol.ToString(),
EnclaveAttestationUrl = builder.EnclaveAttestationUrl,
Encrypt = builder.Encrypt,
Encrypt = builder.Encrypt.ToString(),
FailoverPartner = builder.FailoverPartner,
HostNameInCertificate = builder.HostNameInCertificate,
LoadBalanceTimeout = builder.LoadBalanceTimeout,
MaxPoolSize = builder.MaxPoolSize,
MinPoolSize = builder.MinPoolSize,

View File

@@ -147,13 +147,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
}
/// <summary>
/// Gets or sets a Boolean value that indicates whether SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed.
/// Gets or sets a <see cref="string"/> value that indicates encryption mode that SQL Server should use to perform SSL encryption for all the data sent between the client and server. Supported values are: Optional, Mandatory, Strict.
/// </summary>
public bool? Encrypt
public string Encrypt
{
get
{
return GetOptionValue<bool?>("encrypt");
return GetOptionValue<string>("encrypt");
}
set
@@ -178,6 +178,22 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
}
}
/// <summary>
/// Gets or sets a value that indicates the host name in the certificate to be used for certificate validation when encryption is enabled.
/// </summary>
public string HostNameInCertificate
{
get
{
return GetOptionValue<string>("hostNameInCertificate");
}
set
{
SetOptionValue("hostNameInCertificate", value);
}
}
/// <summary>
/// Gets or sets a Boolean value that indicates if security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state.
/// </summary>

View File

@@ -27,6 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.Contracts
EnclaveAttestationUrl = details.EnclaveAttestationUrl,
Encrypt = details.Encrypt,
TrustServerCertificate = details.TrustServerCertificate,
HostNameInCertificate = details.HostNameInCertificate,
PersistSecurityInfo = details.PersistSecurityInfo,
ConnectTimeout = details.ConnectTimeout,
ConnectRetryCount = details.ConnectRetryCount,

View File

@@ -9641,6 +9641,11 @@ namespace Microsoft.SqlTools.ServiceLayer
return Keys.GetString(Keys.ConnectionServiceConnStringInvalidColumnEncryptionSetting, columnEncryptionSetting);
}
public static string ConnectionServiceConnStringInvalidEncryptOption(string encrypt)
{
return Keys.GetString(Keys.ConnectionServiceConnStringInvalidEncryptOption, encrypt);
}
public static string ConnectionServiceConnStringInvalidEnclaveAttestationProtocol(string enclaveAttestationProtocol)
{
return Keys.GetString(Keys.ConnectionServiceConnStringInvalidEnclaveAttestationProtocol, enclaveAttestationProtocol);
@@ -10062,6 +10067,9 @@ namespace Microsoft.SqlTools.ServiceLayer
public const string ConnectionServiceConnStringInvalidColumnEncryptionSetting = "ConnectionServiceConnStringInvalidColumnEncryptionSetting";
public const string ConnectionServiceConnStringInvalidEncryptOption = "ConnectionServiceConnStringInvalidEncryptOption";
public const string ConnectionServiceConnStringInvalidEnclaveAttestationProtocol = "ConnectionServiceConnStringInvalidEnclaveAttestationProtocol";

View File

@@ -144,6 +144,11 @@
<value>Invalid value &apos;{0}&apos; for ComlumEncryption. Valid values are &apos;Enabled&apos; and &apos;Disabled&apos;.</value>
<comment>.
Parameters: 0 - columnEncryptionSetting (string) </comment>
</data>
<data name="ConnectionServiceConnStringInvalidEncryptOption" xml:space="preserve">
<value>Invalid value &apos;{0}&apos; for Encrypt. Valid values are &apos;Optional&apos;, &apos;Mandatory&apos;, &apos;Strict&apos;, &apos;True&apos;, &apos;False&apos;, &apos;Yes&apos; and &apos;No&apos;.</value>
<comment>.
Parameters: 0 - encrypt (string) </comment>
</data>
<data name="ConnectionServiceConnStringInvalidEnclaveAttestationProtocol" xml:space="preserve">
<value>Invalid value &apos;{0}&apos; for EnclaveAttestationProtocol. Valid values are &apos;AAS&apos; and &apos;HGS&apos;.</value>

View File

@@ -35,6 +35,8 @@ ConnectionServiceConnStringInvalidAuthType(string authType) = Invalid value '{0}
ConnectionServiceConnStringInvalidColumnEncryptionSetting(string columnEncryptionSetting) = Invalid value '{0}' for ComlumEncryption. Valid values are 'Enabled' and 'Disabled'.
ConnectionServiceConnStringInvalidEncryptOption(string encrypt) = Invalid value '{0}' for Encrypt. Valid values are 'Optional', 'Mandatory', 'Strict', 'True', 'False', 'Yes' and 'No'.
ConnectionServiceConnStringInvalidEnclaveAttestationProtocol(string enclaveAttestationProtocol) = Invalid value '{0}' for EnclaveAttestationProtocol. Valid values are 'AAS' and 'HGS'.
ConnectionServiceConnStringInvalidAlwaysEncryptedOptionCombination = The Attestation Protocol and Enclave Attestation URL requires Always Encrypted to be set to Enabled.

View File

@@ -2034,6 +2034,12 @@
<target state="new">Invalid value '{0}' for ComlumEncryption. Valid values are 'Enabled' and 'Disabled'.</target>
<note>.
Parameters: 0 - columnEncryptionSetting (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidEncryptOption">
<source>Invalid value '{0}' for Encrypt. Valid values are 'Optional', 'Mandatory', 'Strict', 'True', 'False', 'Yes' and 'No'.</source>
<target state="new">Invalid value '{0}' for Encrypt. Valid values are 'Optional', 'Mandatory', 'Strict', 'True', 'False', 'Yes' and 'No'.</target>
<note>.
Parameters: 0 - encrypt (string) </note>
</trans-unit>
<trans-unit id="ConnectionServiceConnStringInvalidEnclaveAttestationProtocol">
<source>Invalid value '{0}' for EnclaveAttestationProtocol. Valid values are 'AAS' and 'HGS'.</source>

View File

@@ -49,11 +49,12 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" />
<PackageReference Include="Microsoft.SqlServer.DACFx" />
<PackageReference Include="Microsoft.SqlServer.DacFx" />
<PackageReference Include="Microsoft.Data.SqlClient" />
<PackageReference Include="Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider" />
<PackageReference Include="System.Text.Encoding.CodePages" />
<PackageReference Include="Microsoft.SqlServer.Assessment" />
<PackageReference Include="Microsoft.SqlServer.Management.SmoMetadataProvider" />
<PackageReference Include="Microsoft.SqlServer.SqlManagementObjects" />
<PackageReference Include="Microsoft.SqlServer.Management.SqlParser" />
<PackageReference Include="System.Text.Encoding.CodePages" />
<PackageReference Include="Microsoft.SqlServer.TransactSql.ScriptDom.NRT">