From 42850a9f7c55c4e72f89c9ebf98696b8e7e3ee5a Mon Sep 17 00:00:00 2001 From: jJRahnama Date: Fri, 9 Jul 2021 13:07:25 -0700 Subject: [PATCH] Temp StringsHelper --- src/Directory.Build.props | 1 - .../src/Microsoft.Data.SqlClient.csproj | 4 +- .../netcore/src/Resources/StringHelper.cs | 62 +++++++++++++++++++ .../scripts/GenerateResourceStringsSource.ps1 | 52 ---------------- .../GenerateResourceStringsSource.targets | 11 ---- 5 files changed, 64 insertions(+), 66 deletions(-) create mode 100644 src/Microsoft.Data.SqlClient/netcore/src/Resources/StringHelper.cs delete mode 100644 src/Microsoft.Data.SqlClient/netcore/tools/scripts/GenerateResourceStringsSource.ps1 delete mode 100644 src/Microsoft.Data.SqlClient/netcore/tools/targets/GenerateResourceStringsSource.targets diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 983cafb5dd..6acb394869 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -42,7 +42,6 @@ $(Artifacts)tools\ $(ProjectDir)Microsoft.Data.SqlClient\ $(ManagedSourceCode)netcore\ - $(ManagedSourceCode)netcore\src\Resources\ $(ManagedSourceCode)netfx\ $(ManagedSourceCode)netfx\src\Resources\ $(ManagedSourceCode)add-ons\ 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 ed97cadf92..c609409702 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -326,7 +326,7 @@ Microsoft\Data\SqlClient\SqlUtil.cs - + Resources\ResCategoryAttribute.cs @@ -831,6 +831,7 @@ + True True @@ -878,5 +879,4 @@ - diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Resources/StringHelper.cs b/src/Microsoft.Data.SqlClient/netcore/src/Resources/StringHelper.cs new file mode 100644 index 0000000000..83b5796f55 --- /dev/null +++ b/src/Microsoft.Data.SqlClient/netcore/src/Resources/StringHelper.cs @@ -0,0 +1,62 @@ +// 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. + + +// This class is added to provide ResCategory and ResDescription constants temporarily +// In netfx the powershell script GenerateResourceStringsSource is generating them on build time, but there were some problem with +// Unix builds running the scripts. +// We can investigate MetadataTypeAttribute to be add the annotations to SqlClientConnectionStringBuilder.Windows and omit them in non-windows classes +namespace System +{ + internal partial class StringsHelper + { + internal class ResourceNames + { + internal const string DataCategory_Advanced = @"Advanced"; + internal const string DataCategory_ConnectionResilency = @"Connection Resiliency"; + internal const string DataCategory_Context = @"Context"; + internal const string DataCategory_Initialization = @"Initialization"; + internal const string DataCategory_Pooling = @"Pooling"; + internal const string DataCategory_Replication = @"Replication"; + internal const string DataCategory_Security = @"Security"; + internal const string DataCategory_Source = @"Source"; + internal const string DbCommand_CommandTimeout = @"Time to wait for command to execute."; + internal const string DbConnectionString_ApplicationIntent = @"Declares the application workload type when connecting to a server."; + internal const string DbConnectionString_ApplicationName = @"The name of the application."; + internal const string DbConnectionString_AttachDBFilename = @"The name of the primary file, including the full path name, of an attachable database."; + internal const string DbConnectionString_Authentication = @"Specifies the method of authenticating with SQL Server."; + internal const string DbConnectionString_ConnectRetryCount = @"Number of attempts to restore connection."; + internal const string DbConnectionString_ConnectRetryInterval = @"Delay between attempts to restore connection."; + internal const string DbConnectionString_ConnectTimeout = @"The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error."; + internal const string DbConnectionString_CurrentLanguage = @"The SQL Server Language record name."; + internal const string DbConnectionString_DataSource = @"Indicates the name of the data source to connect to."; + internal const string DbConnectionString_Encrypt = @"When true, SQL Server uses SSL encryption for all data sent between the client and server if the server has a certificate installed."; + internal const string DbConnectionString_Enlist = @"Sessions in a Component Services (or MTS, if you are using Microsoft Windows NT) environment should automatically be enlisted in a global transaction where required."; + internal const string DbConnectionString_FailoverPartner = @"The name or network address of the instance of SQL Server that acts as a failover partner."; + internal const string DbConnectionString_InitialCatalog = @"The name of the initial catalog or database in the data source."; + internal const string DbConnectionString_IntegratedSecurity = @"Whether the connection is to be a secure connection or not."; + internal const string DbConnectionString_LoadBalanceTimeout = @"The minimum amount of time (in seconds) for this connection to live in the pool before being destroyed."; + internal const string DbConnectionString_MaxPoolSize = @"The maximum number of connections allowed in the pool."; + internal const string DbConnectionString_MinPoolSize = @"The minimum number of connections allowed in the pool."; + internal const string DbConnectionString_MultipleActiveResultSets = @"When true, multiple result sets can be returned and read from one connection."; + internal const string DbConnectionString_MultiSubnetFailover = @"If your application is connecting to a high-availability, disaster recovery (AlwaysOn) availability group (AG) on different subnets, MultiSubnetFailover=Yes configures SqlConnection to provide faster detection of and connection to the (currently) active server."; + internal const string DbConnectionString_PacketSize = @"Size in bytes of the network packets used to communicate with an instance of SQL Server."; + internal const string DbConnectionString_Password = @"Indicates the password to be used when connecting to the data source."; + internal const string DbConnectionString_PersistSecurityInfo = @"When false, 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."; + internal const string DbConnectionString_PoolBlockingPeriod = @"Defines the blocking period behavior for a connection pool."; + internal const string DbConnectionString_Pooling = @"When true, the connection object is drawn from the appropriate pool, or if necessary, is created and added to the appropriate pool."; + internal const string DbConnectionString_Replication = @"Used by SQL Server in Replication."; + internal const string DbConnectionString_TrustServerCertificate = @"When true (and encrypt=true), SQL Server uses SSL encryption for all data sent between the client and server without validating the server certificate."; + internal const string DbConnectionString_TypeSystemVersion = @"Indicates which server type system the provider will expose through the DataReader."; + internal const string DbConnectionString_UserID = @"Indicates the user ID to be used when connecting to the data source."; + internal const string DbConnectionString_UserInstance = @"Indicates whether the connection will be re-directed to connect to an instance of SQL Server running under the user's account."; + internal const string DbConnectionString_WorkstationID = @"The name of the workstation connecting to SQL Server."; + internal const string DbConnectionString_TransactionBinding = @"Indicates binding behavior of connection to a System.Transactions Transaction when enlisted."; + internal const string TCE_DbConnectionString_ColumnEncryptionSetting = @"Default column encryption setting for all the commands on the connection."; + internal const string TCE_DbConnectionString_EnclaveAttestationUrl = @"Specifies an endpoint of an enclave attestation service, which will be used to verify whether the enclave, configured in the SQL Server instance for computations on database columns encrypted using Always Encrypted, is valid and secure."; + internal const string TCE_DbConnectionString_AttestationProtocol = @"Specifies an attestation protocol for its corresponding enclave attestation service."; + internal const string TCE_DbConnectionString_IPAddressPreference = @"Specifies an IP address preference when connecting to SQL instances."; + } + } +} diff --git a/src/Microsoft.Data.SqlClient/netcore/tools/scripts/GenerateResourceStringsSource.ps1 b/src/Microsoft.Data.SqlClient/netcore/tools/scripts/GenerateResourceStringsSource.ps1 deleted file mode 100644 index c4ffbb6deb..0000000000 --- a/src/Microsoft.Data.SqlClient/netcore/tools/scripts/GenerateResourceStringsSource.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -# Script: GenerateResourceStringsSource.ps1 -# Author: Keerat Singh -# Date: 25-Jan-2019 -# Comments: This Reads the resources from the resx file and converts them -# into strongly typed const strings -# - -param( - [Parameter(Mandatory=$true)] - [string]$ResxFileDir, - [Parameter(Mandatory=$true)] - [string]$ResxFileName, - [Parameter(Mandatory=$true)] - [string]$OutputPath, - [string]$GeneratedSourceFileName - ) - -# Read the resx file -$XmlFilePath = "${ResxFileDir}${ResxFileName}.resx" -[xml]$XmlDocument = Get-Content -Path "$XmlFilePath" - -# Initial content for the Source File. -$GeneratedSourceFileContent= " -//------------------------------------------------------------------------------ -// This code was auto-generated by msbuild target. -// Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. -//------------------------------------------------------------------------------ - -using System; -using System.Globalization; -using System.Resources; -using System.Threading; - -namespace System -{ - internal partial class StringsHelper : $ResxFileName - { - internal class ResourceNames - {`n" -ForEach($node in $XmlDocument.root.data) -{ - $ResourceName = $node.name - # Escape the Double Quotes in the resource string value. - $ResourceValue = $node.value -replace '"','""' - # Convert Resource Name and Value to internal const string - $GeneratedSourceFileContent= $GeneratedSourceFileContent + " internal const string $ResourceName = @`"$ResourceValue`";`n" -} - -$GeneratedSourceFileContent= $GeneratedSourceFileContent + " }`n}`n}" - -# Output to File -$GeneratedSourceFileContent | Out-File "${OutputPath}${GeneratedSourceFileName}" diff --git a/src/Microsoft.Data.SqlClient/netcore/tools/targets/GenerateResourceStringsSource.targets b/src/Microsoft.Data.SqlClient/netcore/tools/targets/GenerateResourceStringsSource.targets deleted file mode 100644 index de27d71cfa..0000000000 --- a/src/Microsoft.Data.SqlClient/netcore/tools/targets/GenerateResourceStringsSource.targets +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - -