From 5a8cb777e1e3393d30ff5c8b4564b5d11a0872c5 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 9 Oct 2020 13:45:14 -0700 Subject: [PATCH 1/9] Always Encrypted Refs --- .../Microsoft.Data.SqlClient.NetCoreApp.cs | 139 ------------------ .../netcore/ref/Microsoft.Data.SqlClient.cs | 115 +++++++++++++++ .../ref/Microsoft.Data.SqlClient.csproj | 3 + .../src/Microsoft.Data.SqlClient.csproj | 18 +-- 4 files changed, 127 insertions(+), 148 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs index d509a52ee6..1fb5b0345d 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.NetCoreApp.cs @@ -51,145 +51,6 @@ public sealed partial class SqlConnectionStringBuilder : System.Data.Common.DbCo [System.ComponentModel.DisplayNameAttribute("Pool Blocking Period")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] public PoolBlockingPeriod PoolBlockingPeriod { get { throw null; } set { } } - /// - [System.ComponentModel.DisplayNameAttribute("Column Encryption Setting")] - [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] - public Microsoft.Data.SqlClient.SqlConnectionColumnEncryptionSetting ColumnEncryptionSetting { get { throw null; } set { } } - /// - [System.ComponentModel.DisplayNameAttribute("Enclave Attestation Url")] - [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] - public string EnclaveAttestationUrl { get { throw null; } set { } } - /// - [System.ComponentModel.DisplayNameAttribute("Attestation Protocol")] - [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] - public Microsoft.Data.SqlClient.SqlConnectionAttestationProtocol AttestationProtocol {get { throw null; } set { } } - } - /// - public sealed partial class SqlParameter : System.Data.Common.DbParameter, System.ICloneable, System.Data.IDataParameter, System.Data.IDbDataParameter - { - /// - public bool ForceColumnEncryption { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } } - } - /// - public enum SqlCommandColumnEncryptionSetting - { - /// - Disabled = 3, - /// - Enabled = 1, - /// - ResultSetOnly = 2, - /// - UseConnectionSetting = 0, - } - public sealed partial class SqlCommand : System.Data.Common.DbCommand, System.ICloneable - { - /// - public SqlCommand(string cmdText, Microsoft.Data.SqlClient.SqlConnection connection, Microsoft.Data.SqlClient.SqlTransaction transaction, Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting columnEncryptionSetting) { } - /// - [System.ComponentModel.BrowsableAttribute(false)] - [System.ComponentModel.DesignerSerializationVisibilityAttribute(0)] - public Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting ColumnEncryptionSetting { get { throw null; } } - } - public sealed partial class SqlConnection : System.Data.Common.DbConnection, System.ICloneable - { - /// - public static System.TimeSpan ColumnEncryptionKeyCacheTtl { get { throw null; } set { } } - /// - public static bool ColumnEncryptionQueryMetadataCacheEnabled { get { throw null; } set { } } - /// - public static System.Collections.Generic.IDictionary> ColumnEncryptionTrustedMasterKeyPaths { get { throw null; } } - /// - public static void RegisterColumnEncryptionKeyStoreProviders(System.Collections.Generic.IDictionary customProviders) { } - } - /// - public enum SqlConnectionColumnEncryptionSetting - { - /// - Disabled = 0, - /// - Enabled = 1, - } - - /// - public enum SqlConnectionAttestationProtocol - { - /// - NotSpecified = 0, - - /// - AAS = 1, - -#if ENCLAVE_SIMULATOR - /// - SIM = 2, -#endif - - /// - HGS = 3 - } - - /// - public partial class SqlColumnEncryptionCertificateStoreProvider : Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider - { - /// - public const string ProviderName = "MSSQL_CERTIFICATE_STORE"; - /// - public SqlColumnEncryptionCertificateStoreProvider() { } - /// - public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey) { throw null; } - /// - public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey) { throw null; } - /// - public override byte[] SignColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations) { throw null; } - /// - public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; } - } - /// - public partial class SqlColumnEncryptionCngProvider : Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider - { - /// - public const string ProviderName = "MSSQL_CNG_STORE"; - /// - public SqlColumnEncryptionCngProvider() { } - /// - public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey) { throw null; } - /// - public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey) { throw null; } - /// - public override byte[] SignColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations) { throw null; } - /// - public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; } - } - /// - public partial class SqlColumnEncryptionCspProvider : Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider - { - /// - public const string ProviderName = "MSSQL_CSP_PROVIDER"; - /// - public SqlColumnEncryptionCspProvider() { } - /// - public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey) { throw null; } - /// - public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey) { throw null; } - /// - public override byte[] SignColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations) { throw null; } - /// - public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; } - } - /// - public abstract partial class SqlColumnEncryptionKeyStoreProvider - { - /// - protected SqlColumnEncryptionKeyStoreProvider() { } - /// - public abstract byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey); - /// - public abstract byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey); - /// - public virtual byte[] SignColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations) { throw null; } - /// - public virtual bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; } } } diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs index 66ad7c3679..ff3225d7d7 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs @@ -375,6 +375,83 @@ public static partial class SqlClientMetaDataCollectionNames /// public static readonly string ColumnSetColumns; } +#if !NETSTANDARD20 + /// + public enum SqlConnectionAttestationProtocol + { + /// + NotSpecified = 0, + + /// + AAS = 1, + +#if ENCLAVE_SIMULATOR + /// + SIM = 2, +#endif + + /// + HGS = 3 + } +#endif + /// + public partial class SqlColumnEncryptionCertificateStoreProvider : Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider + { + /// + public const string ProviderName = "MSSQL_CERTIFICATE_STORE"; + /// + public SqlColumnEncryptionCertificateStoreProvider() { } + /// + public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey) { throw null; } + /// + public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey) { throw null; } + /// + public override byte[] SignColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations) { throw null; } + /// + public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; } + } + /// + public partial class SqlColumnEncryptionCngProvider : Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider + { + /// + public const string ProviderName = "MSSQL_CNG_STORE"; + /// + public SqlColumnEncryptionCngProvider() { } + /// + public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey) { throw null; } + /// + public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey) { throw null; } + /// + public override byte[] SignColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations) { throw null; } + /// + public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; } + } + /// + public abstract partial class SqlColumnEncryptionKeyStoreProvider + { + /// + protected SqlColumnEncryptionKeyStoreProvider() { } + /// + public abstract byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey); + /// + public abstract byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey); + /// + public virtual byte[] SignColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations) { throw null; } + /// + public virtual bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; } + } + /// + public enum SqlCommandColumnEncryptionSetting + { + /// + Disabled = 3, + /// + Enabled = 1, + /// + ResultSetOnly = 2, + /// + UseConnectionSetting = 0, + } /// [System.ComponentModel.DefaultEventAttribute("RecordsAffected")] [System.ComponentModel.DesignerAttribute("Microsoft.VSDesigner.Data.VS.SqlCommandDesigner, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] @@ -389,6 +466,12 @@ public SqlCommand(string cmdText) { } public SqlCommand(string cmdText, Microsoft.Data.SqlClient.SqlConnection connection) { } /// public SqlCommand(string cmdText, Microsoft.Data.SqlClient.SqlConnection connection, Microsoft.Data.SqlClient.SqlTransaction transaction) { } + /// + public SqlCommand(string cmdText, Microsoft.Data.SqlClient.SqlConnection connection, Microsoft.Data.SqlClient.SqlTransaction transaction, Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting columnEncryptionSetting) { } + /// + [System.ComponentModel.BrowsableAttribute(false)] + [System.ComponentModel.DesignerSerializationVisibilityAttribute(0)] + public Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting ColumnEncryptionSetting { get { throw null; } } /// [System.ComponentModel.DefaultValueAttribute("")] [System.ComponentModel.EditorAttribute("Microsoft.VSDesigner.Data.SQL.Design.SqlCommandTextEditor, Microsoft.VSDesigner, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] @@ -576,6 +659,14 @@ public SqlConnection() { } public SqlConnection(string connectionString) { } /// public SqlConnection(string connectionString, Microsoft.Data.SqlClient.SqlCredential credential) { } + /// + public static System.TimeSpan ColumnEncryptionKeyCacheTtl { get { throw null; } set { } } + /// + public static bool ColumnEncryptionQueryMetadataCacheEnabled { get { throw null; } set { } } + /// + public static System.Collections.Generic.IDictionary> ColumnEncryptionTrustedMasterKeyPaths { get { throw null; } } + /// + public static void RegisterColumnEncryptionKeyStoreProviders(System.Collections.Generic.IDictionary customProviders) { } /// [System.ComponentModel.BrowsableAttribute(false)] [System.ComponentModel.DesignerSerializationVisibilityAttribute(0)] @@ -688,6 +779,14 @@ public void ResetStatistics() { } /// public System.Collections.Generic.IDictionary RetrieveInternalInfo() { throw null; } } + /// + public enum SqlConnectionColumnEncryptionSetting + { + /// + Disabled = 0, + /// + Enabled = 1, + } /// public enum SqlConnectionOverrides { @@ -721,6 +820,10 @@ public SqlConnectionStringBuilder(string connectionString) { } [System.ComponentModel.DisplayNameAttribute("Authentication")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] public Microsoft.Data.SqlClient.SqlAuthenticationMethod Authentication { get { throw null; } set { } } + /// + [System.ComponentModel.DisplayNameAttribute("Column Encryption Setting")] + [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] + public Microsoft.Data.SqlClient.SqlConnectionColumnEncryptionSetting ColumnEncryptionSetting { get { throw null; } set { } } /// [System.ComponentModel.DisplayNameAttribute("Command Timeout")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] @@ -745,6 +848,16 @@ public SqlConnectionStringBuilder(string connectionString) { } [System.ComponentModel.DisplayNameAttribute("Data Source")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] public string DataSource { get { throw null; } set { } } +#if !NETSTANDARD20 + /// + [System.ComponentModel.DisplayNameAttribute("Attestation Protocol")] + [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] + public Microsoft.Data.SqlClient.SqlConnectionAttestationProtocol AttestationProtocol { get { throw null; } set { } } + /// + [System.ComponentModel.DisplayNameAttribute("Enclave Attestation Url")] + [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] + public string EnclaveAttestationUrl { get { throw null; } set { } } +#endif /// [System.ComponentModel.DisplayNameAttribute("Encrypt")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] @@ -1279,6 +1392,8 @@ public SqlParameter(string parameterName, object value) { } /// [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] public override System.Data.ParameterDirection Direction { get { throw null; } set { } } + /// + public bool ForceColumnEncryption { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } } /// [System.ComponentModel.DefaultValueAttribute(false)] public override bool IsNullable { get { throw null; } set { } } diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj index 0902edd7c1..fe00449d8e 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj @@ -12,6 +12,9 @@ netstandard AnyCPU;x64;x86 + + $(DefineConstants);NETSTANDARD20 + 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 931b0160e4..f717a72a6a 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -234,15 +234,6 @@ Microsoft\Data\SqlClient\Server\InvalidUdtException.cs - - Microsoft\Data\SqlClient\AlwaysEncryptedAttestationException.cs - - - Microsoft\Data\SqlClient\EnclaveProviderBase.cs - - - Microsoft\Data\SqlClient\EnclaveSessionCache.cs - Microsoft\Data\SqlClient\SignatureVerificationCache.cs @@ -260,6 +251,15 @@ + + Microsoft\Data\SqlClient\AlwaysEncryptedAttestationException.cs + + + Microsoft\Data\SqlClient\EnclaveProviderBase.cs + + + Microsoft\Data\SqlClient\EnclaveSessionCache.cs + From 4ff603f0dd27efa6522b96c65b4a2f53f4b0b062 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Tue, 13 Oct 2020 11:48:55 -0700 Subject: [PATCH 2/9] Correct documentation --- .../netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs | 2 +- .../netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs index ae7db9afeb..1b9001c8ee 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs @@ -2532,7 +2532,7 @@ private void SetCachedCommandExecuteReaderAsyncContext(ExecuteReaderAsyncCallCon } } - /// + /// public override Task ExecuteScalarAsync(CancellationToken cancellationToken) { _parentOperationStarted = true; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs index dfe71c8351..35c260c05b 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlCommand.cs @@ -3022,7 +3022,7 @@ protected override Task ExecuteDbDataReaderAsync(CommandBehavior b return returnedTask; } - /// + /// public override Task ExecuteScalarAsync(CancellationToken cancellationToken) { return ExecuteReaderAsync(cancellationToken).ContinueWith((executeTask) => From 1fac03a0a6fd6b8f142e154747f6590c0eee19a6 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 16 Oct 2020 11:04:26 -0700 Subject: [PATCH 3/9] Fix for Refs --- .../netcore/ref/Microsoft.Data.SqlClient.cs | 4 ++-- .../netcore/ref/Microsoft.Data.SqlClient.csproj | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs index ff3225d7d7..9a9ae9ee79 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs @@ -375,7 +375,7 @@ public static partial class SqlClientMetaDataCollectionNames /// public static readonly string ColumnSetColumns; } -#if !NETSTANDARD20 +#if NETCORE || NETSTANDARD21_AND_ABOVE /// public enum SqlConnectionAttestationProtocol { @@ -848,7 +848,7 @@ public SqlConnectionStringBuilder(string connectionString) { } [System.ComponentModel.DisplayNameAttribute("Data Source")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] public string DataSource { get { throw null; } set { } } -#if !NETSTANDARD20 +#if NETCORE || NETSTANDARD21_AND_ABOVE /// [System.ComponentModel.DisplayNameAttribute("Attestation Protocol")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj index fe00449d8e..81399b6022 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj @@ -12,8 +12,11 @@ netstandard AnyCPU;x64;x86 - - $(DefineConstants);NETSTANDARD20 + + $(DefineConstants);NETSTANDARD21_AND_ABOVE + + + $(DefineConstants);NETCORE From 9ad767250bca94f688da12af70989b14f991bf1c Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 16 Oct 2020 11:21:01 -0700 Subject: [PATCH 4/9] Updated constants for consistency --- .../netcore/ref/Microsoft.Data.SqlClient.cs | 4 +-- .../ref/Microsoft.Data.SqlClient.csproj | 4 +-- .../src/Microsoft.Data.SqlClient.csproj | 8 ++--- .../Data/Common/DbConnectionStringCommon.cs | 4 +-- .../Data/SqlClient/SNI/SNITcpHandle.cs | 2 +- .../Data/SqlClient/SqlConnectionString.cs | 14 ++++----- .../SqlClient/SqlConnectionStringBuilder.cs | 14 ++++----- .../src/Microsoft/Data/SqlClient/TdsParser.cs | 2 +- .../Data/SqlClient/TdsValueSetter.cs | 8 ++--- .../netfx/src/Microsoft.Data.SqlClient.csproj | 2 +- .../ActiveDirectoryAuthenticationProvider.cs | 30 +++++++++---------- .../SqlClient/SqlClientEventSource.Windows.cs | 2 +- .../Microsoft.Data.SqlClient.Tests.csproj | 1 + .../SqlConnectionStringBuilderTest.cs | 2 +- ....Data.SqlClient.ManualTesting.Tests.csproj | 4 +-- .../ExceptionTest/ConnectionExceptionTest.cs | 2 +- .../SQL/UdtTest/SqlServerTypesTest.cs | 2 +- .../DiscovererHelpers.cs | 3 +- 18 files changed, 55 insertions(+), 53 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs index 9a9ae9ee79..be1a98de78 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs @@ -375,7 +375,7 @@ public static partial class SqlClientMetaDataCollectionNames /// public static readonly string ColumnSetColumns; } -#if NETCORE || NETSTANDARD21_AND_ABOVE +#if NETCOREAPP || NETSTANDARD21_AND_ABOVE /// public enum SqlConnectionAttestationProtocol { @@ -848,7 +848,7 @@ public SqlConnectionStringBuilder(string connectionString) { } [System.ComponentModel.DisplayNameAttribute("Data Source")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] public string DataSource { get { throw null; } set { } } -#if NETCORE || NETSTANDARD21_AND_ABOVE +#if NETCOREAPP || NETSTANDARD21_AND_ABOVE /// [System.ComponentModel.DisplayNameAttribute("Attestation Protocol")] [System.ComponentModel.RefreshPropertiesAttribute(System.ComponentModel.RefreshProperties.All)] diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj index 81399b6022..9a6db6b167 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.csproj @@ -12,11 +12,11 @@ netstandard AnyCPU;x64;x86 - + $(DefineConstants);NETSTANDARD21_AND_ABOVE - $(DefineConstants);NETCORE + $(DefineConstants);NETCOREAPP 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 f717a72a6a..2eaa0c9b08 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj @@ -20,13 +20,13 @@ Core $(BaseProduct) - $(DefineConstants);netcoreapp; + $(DefineConstants);NETCOREAPP; - $(DefineConstants);netstandard; + $(DefineConstants);NETSTANDARD; - - $(DefineConstants);NETCORE3 + + $(DefineConstants);NETCOREAPP31_AND_ABOVE portable diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs index ee9544b4ce..eb23fcdfef 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs @@ -780,7 +780,7 @@ internal static partial class DbConnectionStringKeywords internal const string MaxPoolSize = "Max Pool Size"; internal const string Pooling = "Pooling"; internal const string MinPoolSize = "Min Pool Size"; -#if netcoreapp +#if NETCOREAPP internal const string PoolBlockingPeriod = "Pool Blocking Period"; #endif } @@ -839,7 +839,7 @@ internal static class DbConnectionStringSynonyms internal const string NET = "net"; internal const string NETWORK = "network"; -#if netcoreapp +#if NETCOREAPP //internal const string PoolBlockingPeriod = POOLBLOCKINGPERIOD; internal const string POOLBLOCKINGPERIOD = "PoolBlockingPeriod"; #endif 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 9099427e7f..b072a4fa01 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 @@ -815,7 +815,7 @@ public override void KillConnection() internal static void SetKeepAliveValues(ref Socket socket) { -#if NETCORE3 +#if NETCOREAPP31_AND_ABOVE socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveInterval, 1); socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.TcpKeepAliveTime, 30); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.cs index 7e58eaf4a2..aa9023139c 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionString.cs @@ -63,7 +63,7 @@ internal static class KEY internal const string Application_Name = "application name"; internal const string AsynchronousProcessing = "asynchronous processing"; internal const string AttachDBFilename = "attachdbfilename"; -#if netcoreapp +#if NETCOREAPP internal const string PoolBlockingPeriod = "pool blocking period"; #endif internal const string ColumnEncryptionSetting = "column encryption setting"; @@ -141,7 +141,7 @@ private static class SYNONYM // network library internal const string NET = "net"; internal const string NETWORK = "network"; -#if netcoreapp +#if NETCOREAPP // pool blocking period internal const string POOLBLOCKINGPERIOD = "poolblockingperiod"; #endif @@ -159,7 +159,7 @@ private static class SYNONYM // make sure to update SynonymCount value below when adding or removing synonyms } -#if netcoreapp +#if NETCOREAPP internal const int SynonymCount = 25; #else internal const int SynonymCount = 24; @@ -258,7 +258,7 @@ internal SqlConnectionString(string connectionString) : base(connectionString, G } _integratedSecurity = ConvertValueToIntegratedSecurity(); -#if netcoreapp +#if NETCOREAPP _poolBlockingPeriod = ConvertValueToPoolBlockingPeriod(); #endif _encrypt = ConvertValueToBoolean(KEY.Encrypt, DEFAULT.Encrypt); @@ -511,7 +511,7 @@ internal SqlConnectionString(SqlConnectionString connectionOptions, string dataS _commandTimeout = connectionOptions._commandTimeout; _connectTimeout = connectionOptions._connectTimeout; _loadBalanceTimeout = connectionOptions._loadBalanceTimeout; -#if netcoreapp +#if NETCOREAPP _poolBlockingPeriod = connectionOptions._poolBlockingPeriod; #endif _maxPoolSize = connectionOptions._maxPoolSize; @@ -650,7 +650,7 @@ internal static Dictionary GetParseSynonyms() { KEY.Application_Name, KEY.Application_Name }, { KEY.AsynchronousProcessing, KEY.AsynchronousProcessing }, { KEY.AttachDBFilename, KEY.AttachDBFilename }, -#if netcoreapp +#if NETCOREAPP { KEY.PoolBlockingPeriod, KEY.PoolBlockingPeriod}, #endif { KEY.Command_Timeout, KEY.Command_Timeout }, @@ -703,7 +703,7 @@ internal static Dictionary GetParseSynonyms() { SYNONYM.MULTIPLEACTIVERESULTSETS, KEY.MARS }, { SYNONYM.MULTISUBNETFAILOVER, KEY.MultiSubnetFailover }, { SYNONYM.NETWORK_ADDRESS, KEY.Data_Source }, -#if netcoreapp +#if NETCOREAPP { SYNONYM.POOLBLOCKINGPERIOD, KEY.PoolBlockingPeriod}, #endif { SYNONYM.SERVER, KEY.Data_Source }, diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs index 2c4d110254..0a7a06659a 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnectionStringBuilder.cs @@ -33,7 +33,7 @@ private enum Keywords Pooling, MinPoolSize, MaxPoolSize, -#if netcoreapp +#if NETCOREAPP PoolBlockingPeriod, #endif MultipleActiveResultSets, @@ -114,7 +114,7 @@ private static string[] CreateValidKeywords() validKeywords[(int)Keywords.ApplicationIntent] = DbConnectionStringKeywords.ApplicationIntent; validKeywords[(int)Keywords.ApplicationName] = DbConnectionStringKeywords.ApplicationName; validKeywords[(int)Keywords.AttachDBFilename] = DbConnectionStringKeywords.AttachDBFilename; -#if netcoreapp +#if NETCOREAPP validKeywords[(int)Keywords.PoolBlockingPeriod] = DbConnectionStringKeywords.PoolBlockingPeriod; #endif validKeywords[(int)Keywords.CommandTimeout] = DbConnectionStringKeywords.CommandTimeout; @@ -158,7 +158,7 @@ private static Dictionary CreateKeywordsDictionary() hash.Add(DbConnectionStringKeywords.ApplicationIntent, Keywords.ApplicationIntent); hash.Add(DbConnectionStringKeywords.ApplicationName, Keywords.ApplicationName); hash.Add(DbConnectionStringKeywords.AttachDBFilename, Keywords.AttachDBFilename); -#if netcoreapp +#if NETCOREAPP hash.Add(DbConnectionStringKeywords.PoolBlockingPeriod, Keywords.PoolBlockingPeriod); #endif hash.Add(DbConnectionStringKeywords.CommandTimeout, Keywords.CommandTimeout); @@ -208,7 +208,7 @@ private static Dictionary CreateKeywordsDictionary() hash.Add(DbConnectionStringSynonyms.MULTIPLEACTIVERESULTSETS, Keywords.MultipleActiveResultSets); hash.Add(DbConnectionStringSynonyms.MULTISUBNETFAILOVER, Keywords.MultiSubnetFailover); hash.Add(DbConnectionStringSynonyms.NETWORKADDRESS, Keywords.DataSource); -#if netcoreapp +#if NETCOREAPP hash.Add(DbConnectionStringSynonyms.POOLBLOCKINGPERIOD, Keywords.PoolBlockingPeriod); #endif hash.Add(DbConnectionStringSynonyms.SERVER, Keywords.DataSource); @@ -326,7 +326,7 @@ public override object this[string keyword] case Keywords.AttestationProtocol: AttestationProtocol = ConvertToAttestationProtocol(keyword, value); break; -#if netcoreapp +#if NETCOREAPP case Keywords.PoolBlockingPeriod: PoolBlockingPeriod = ConvertToPoolBlockingPeriod(keyword, value); break; #endif case Keywords.Encrypt: @@ -914,7 +914,7 @@ private object GetAt(Keywords index) return ApplicationName; case Keywords.AttachDBFilename: return AttachDBFilename; -#if netcoreapp +#if NETCOREAPP case Keywords.PoolBlockingPeriod: return PoolBlockingPeriod; #endif case Keywords.CommandTimeout: @@ -1029,7 +1029,7 @@ private void Reset(Keywords index) case Keywords.Authentication: _authentication = DbConnectionStringDefaults.Authentication; break; -#if netcoreapp +#if NETCOREAPP case Keywords.PoolBlockingPeriod: _poolBlockingPeriod = DbConnectionStringDefaults.PoolBlockingPeriod; break; diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs index 70cecd2e3f..c4c27098ca 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs @@ -1658,7 +1658,7 @@ internal void WriteInt(int v, TdsParserStateObject stateObj) internal static void WriteInt(Span buffer, int value) { -#if netcoreapp +#if NETCOREAPP BitConverter.TryWriteBytes(buffer, value); #else buffer[0] = (byte)(value & 0xff); diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsValueSetter.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsValueSetter.cs index 7ab4ad5403..08e0aefaec 100644 --- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsValueSetter.cs +++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsValueSetter.cs @@ -561,7 +561,7 @@ internal void SetDateTime(DateTime value) _stateObj.Parser.WriteInt(dt.time, _stateObj); } - // Clean the variant metadata to prevent sharing it with next row. + // Clean the variant metadata to prevent sharing it with next row. // As a reminder, SetVariantType raises an assert if _variantType is not clean _variantType = null; } @@ -601,7 +601,7 @@ internal void SetGuid(Guid value) Debug.Assert( SmiXetterAccessMap.IsSetterAccessValid(_metaData, SmiXetterTypeCode.XetGuid)); -#if netcoreapp +#if NETCOREAPP Span bytes = stackalloc byte[16]; value.TryWriteBytes(bytes); @@ -620,7 +620,7 @@ internal void SetGuid(Guid value) _stateObj.WriteByte((byte)_metaData.MaxLength); } -#if netcoreapp +#if NETCOREAPP _stateObj.WriteByteSpan(bytes); #else _stateObj.WriteByteArray(bytes, bytes.Length, 0); @@ -660,7 +660,7 @@ internal void SetDateTimeOffset(DateTimeOffset value) byte length; if (SqlDbType.Variant == _metaData.SqlDbType) { - // VSTFDevDiv #885208 - DateTimeOffset throws ArgumentException for when passing DateTimeOffset value to a sql_variant TVP + // VSTFDevDiv #885208 - DateTimeOffset throws ArgumentException for when passing DateTimeOffset value to a sql_variant TVP // using a SqlDataRecord or SqlDataReader SmiMetaData dateTimeOffsetMetaData = SmiMetaData.DefaultDateTimeOffset; scale = MetaType.MetaDateTimeOffset.Scale; diff --git a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj index 7b3a6a1181..b12183ebdd 100644 --- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj +++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj @@ -20,7 +20,7 @@ True - $(DefineConstants);netfx; + $(DefineConstants);NETFRAMEWORK; diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs index 801b4df97a..507d34b103 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs @@ -66,14 +66,14 @@ public override void BeforeUnload(SqlAuthenticationMethod authentication) _logger.LogInfo(_type, "BeforeUnload", $"being unloaded from SqlAuthProviders for {authentication}."); } -#if netstandard +#if NETSTANDARD private Func parentActivityOrWindowFunc = null; /// public void SetParentActivityOrWindowFunc(Func parentActivityOrWindowFunc) => this.parentActivityOrWindowFunc = parentActivityOrWindowFunc; #endif -#if netfx +#if NETFRAMEWORK private Func _iWin32WindowFunc = null; /// @@ -101,16 +101,16 @@ public override Task AcquireTokenAsync(SqlAuthentication return new SqlAuthenticationToken(result.AccessToken, result.ExpiresOn); } - /* + /* * Today, MSAL.NET uses another redirect URI by default in desktop applications that run on Windows * (urn:ietf:wg:oauth:2.0:oob). In the future, we'll want to change this default, so we recommend * that you use https://login.microsoftonline.com/common/oauth2/nativeclient. - * + * * https://docs.microsoft.com/en-us/azure/active-directory/develop/scenario-desktop-app-registration#redirect-uris */ string redirectURI = "https://login.microsoftonline.com/common/oauth2/nativeclient"; -#if netcoreapp +#if NETCOREAPP if (parameters.AuthenticationMethod != SqlAuthenticationMethod.ActiveDirectoryDeviceCodeFlow) { redirectURI = "http://localhost"; @@ -118,7 +118,7 @@ public override Task AcquireTokenAsync(SqlAuthentication #endif IPublicClientApplication app; -#if netstandard +#if NETSTANDARD if (parentActivityOrWindowFunc != null) { app = PublicClientApplicationBuilder.Create(_applicationClientId) @@ -130,7 +130,7 @@ public override Task AcquireTokenAsync(SqlAuthentication .Build(); } #endif -#if netfx +#if NETFRAMEWORK if (_iWin32WindowFunc != null) { app = PublicClientApplicationBuilder.Create(_applicationClientId) @@ -142,7 +142,7 @@ public override Task AcquireTokenAsync(SqlAuthentication .Build(); } #endif -#if !netcoreapp +#if !NETCOREAPP else #endif { @@ -229,14 +229,14 @@ private async Task AcquireTokenInteractiveDeviceFlowAsync( SqlAuthenticationMethod authenticationMethod) { CancellationTokenSource cts = new CancellationTokenSource(); -#if netcoreapp +#if NETCOREAPP /* * On .NET Core, MSAL will start the system browser as a separate process. MSAL does not have control over this browser, * but once the user finishes authentication, the web page is redirected in such a way that MSAL can intercept the Uri. * MSAL cannot detect if the user navigates away or simply closes the browser. Apps using this technique are encouraged * to define a timeout (via CancellationToken). We recommend a timeout of at least a few minutes, to take into account * cases where the user is prompted to change password or perform 2FA. - * + * * https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/System-Browser-on-.Net-Core#system-browser-experience */ cts.CancelAfter(180000); @@ -257,7 +257,7 @@ private async Task AcquireTokenInteractiveDeviceFlowAsync( { /* * We will use the MSAL Embedded or System web browser which changes by Default in MSAL according to this table: - * + * * Framework Embedded System Default * ------------------------------------------- * .NET Classic Yes Yes^ Embedded @@ -267,9 +267,9 @@ private async Task AcquireTokenInteractiveDeviceFlowAsync( * Xamarin.Android Yes Yes System * Xamarin.iOS Yes Yes System * Xamarin.Mac Yes No Embedded - * + * * ^ Requires "http://localhost" redirect URI - * + * * https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/MSAL.NET-uses-web-browser#at-a-glance */ return await app.AcquireTokenInteractive(scopes) @@ -296,11 +296,11 @@ private async Task AcquireTokenInteractiveDeviceFlowAsync( private Task DefaultDeviceFlowCallback(DeviceCodeResult result) { - // This will print the message on the console which tells the user where to go sign-in using + // This will print the message on the console which tells the user where to go sign-in using // a separate browser and the code to enter once they sign in. // The AcquireTokenWithDeviceCode() method will poll the server after firing this // device code callback to look for the successful login of the user via that browser. - // This background polling (whose interval and timeout data is also provided as fields in the + // This background polling (whose interval and timeout data is also provided as fields in the // deviceCodeCallback class) will occur until: // * The user has successfully logged in via browser and entered the proper code // * The timeout specified by the server for the lifetime of this code (typically ~15 minutes) has been reached diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientEventSource.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientEventSource.Windows.cs index f9af6024e4..2249bd747f 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientEventSource.Windows.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientEventSource.Windows.cs @@ -35,7 +35,7 @@ protected override void OnEventCommand(EventCommandEventArgs e) // If registration fails, all write and unregister commands will be a no-op. // If managed networking is enabled, don't call native wrapper methods -#if netcoreapp +#if NETCOREAPP if (AppContext.TryGetSwitch("Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows", out bool isEnabled) && isEnabled) { return; diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj index b6b55561ea..03ab925f07 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj @@ -6,6 +6,7 @@ netfx Debug;Release;net46-Release;net46-Debug;netcoreapp2.1-Debug;netcoreapp2.1-Release;netcoreapp3.1-Debug;netcoreapp3.1-Release AnyCPU;x86;x64 + $(DefineConstants);NETCOREAPP $(ObjFolder)$(Configuration).$(Platform).$(AssemblyName) $(BinFolder)$(Configuration).$(Platform).$(AssemblyName) diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs index dc85dab6dd..3d0588ece9 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs @@ -67,7 +67,7 @@ public class SqlConnectionStringBuilderTest [InlineData("PersistSecurityInfo = true")] [InlineData("Pooling = no")] [InlineData("Pooling = false")] -#if netcoreapp +#if NETCOREAPP // PoolBlockingPeriod is not supported in .NET Standard [InlineData("PoolBlockingPeriod = Auto")] [InlineData("PoolBlockingperiod = NeverBlock")] diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj index 877791abe3..2bbe50f606 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj @@ -8,8 +8,8 @@ Microsoft.Data.SqlClient.ManualTesting.Tests.ruleset Debug;Release;net46-Release;net46-Debug;netcoreapp2.1-Debug;netcoreapp2.1-Release;netcoreapp3.1-Debug;netcoreapp3.1-Release AnyCPU;x86;x64 - $(DefineConstants);netcoreapp - $(DefineConstants);netfx + $(DefineConstants);NETCOREAPP + $(DefineConstants);NETFRAMEWORK $(ObjFolder)$(Configuration).$(Platform).$(AssemblyName) $(BinFolder)$(Configuration).$(Platform).$(AssemblyName) diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs index 48a9be0b22..726aeafe47 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs @@ -180,7 +180,7 @@ private TException VerifyConnectionFailure(Action connectAction, str TException ex = Assert.Throws(connectAction); // Some exception messages are different between Framework and Core -#if netfx +#if NETFRAMEWORK Assert.Contains(expectedExceptionMessage, ex.Message); #endif Assert.True(exVerifier(ex), "FAILED Exception verifier failed on the exception."); diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs index 1d90c31261..3015d11c70 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/UdtTest/SqlServerTypesTest.cs @@ -268,7 +268,7 @@ private static void TestUdtSqlDataReaderGetStream(CommandBehavior behavior) } } } -#if netcoreapp +#if NETCOREAPP // Synapse: Parse error at line: 1, column: 41: Incorrect syntax near 'hierarchyid'. [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureSynapse))] public static void TestUdtSchemaMetadata() diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DiscovererHelpers.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DiscovererHelpers.cs index b8b92d9423..5dab843fab 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DiscovererHelpers.cs +++ b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.DotNet.XUnitExtensions/DiscovererHelpers.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.InteropServices; using Xunit; namespace Microsoft.DotNet.XUnitExtensions @@ -10,7 +11,7 @@ namespace Microsoft.DotNet.XUnitExtensions internal static class DiscovererHelpers { internal static bool TestPlatformApplies(TestPlatforms platforms) => -#if netcoreapp +#if NETCOREAPP (platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) || (platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) || (platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) || From 9c1b736f52758177edb4beade8b56b4b01bc0dbd Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 16 Oct 2020 12:17:05 -0700 Subject: [PATCH 5/9] Fix Constant --- .../tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj index 03ab925f07..5e49e2b01b 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj @@ -6,7 +6,7 @@ netfx Debug;Release;net46-Release;net46-Debug;netcoreapp2.1-Debug;netcoreapp2.1-Release;netcoreapp3.1-Debug;netcoreapp3.1-Release AnyCPU;x86;x64 - $(DefineConstants);NETCOREAPP + $(DefineConstants);NETCOREAPP $(ObjFolder)$(Configuration).$(Platform).$(AssemblyName) $(BinFolder)$(Configuration).$(Platform).$(AssemblyName) From f400b943d04e9ce69adbf9c8ee3997a978e465a4 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 16 Oct 2020 12:28:29 -0700 Subject: [PATCH 6/9] Fixes --- .../netcore/ref/Microsoft.Data.SqlClient.cs | 16 ++++++++++++++++ ...oft.Data.SqlClient.ManualTesting.Tests.csproj | 1 + 2 files changed, 17 insertions(+) diff --git a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs index be1a98de78..88603b59ab 100644 --- a/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs +++ b/src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs @@ -426,6 +426,22 @@ public SqlColumnEncryptionCngProvider() { } /// public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; } } + /// + public partial class SqlColumnEncryptionCspProvider : Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider + { + /// + public const string ProviderName = "MSSQL_CSP_PROVIDER"; + /// + public SqlColumnEncryptionCspProvider() { } + /// + public override byte[] DecryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] encryptedColumnEncryptionKey) { throw null; } + /// + public override byte[] EncryptColumnEncryptionKey(string masterKeyPath, string encryptionAlgorithm, byte[] columnEncryptionKey) { throw null; } + /// + public override byte[] SignColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations) { throw null; } + /// + public override bool VerifyColumnMasterKeyMetadata(string masterKeyPath, bool allowEnclaveComputations, byte[] signature) { throw null; } + } /// public abstract partial class SqlColumnEncryptionKeyStoreProvider { diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj index 2bbe50f606..fdefa81200 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj @@ -274,6 +274,7 @@ + From 6cd4e8cfeef75be1520efa0954189e1cf88918dd Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 16 Oct 2020 13:15:06 -0700 Subject: [PATCH 7/9] Enable tests for .NET Standard --- .../FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj | 6 ++---- .../Microsoft.Data.SqlClient.ManualTesting.Tests.csproj | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj index 5e49e2b01b..a96c30fff4 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj @@ -10,14 +10,12 @@ $(ObjFolder)$(Configuration).$(Platform).$(AssemblyName) $(BinFolder)$(Configuration).$(Platform).$(AssemblyName) - + - - @@ -86,7 +84,7 @@ - + diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj index fdefa81200..2a5bf658c5 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj @@ -13,7 +13,7 @@ $(ObjFolder)$(Configuration).$(Platform).$(AssemblyName) $(BinFolder)$(Configuration).$(Platform).$(AssemblyName) - + @@ -24,8 +24,6 @@ - - From b8f8ea915c93c7ceb69af3e085d0eb456b326f36 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Fri, 16 Oct 2020 16:14:42 -0700 Subject: [PATCH 8/9] Fix Pool Blocking test for .NET Standard --- .../Microsoft.Data.SqlClient.Tests.csproj | 5 ++++- ...ConnectionStringBuilderPoolBlockingTest.cs | 21 +++++++++++++++++++ .../SqlConnectionStringBuilderTest.cs | 9 ++------ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderPoolBlockingTest.cs diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj index a96c30fff4..fc7ac315b4 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj @@ -6,10 +6,13 @@ netfx Debug;Release;net46-Release;net46-Debug;netcoreapp2.1-Debug;netcoreapp2.1-Release;netcoreapp3.1-Debug;netcoreapp3.1-Release AnyCPU;x86;x64 - $(DefineConstants);NETCOREAPP + $(DefineConstants);NETCOREAPP $(ObjFolder)$(Configuration).$(Platform).$(AssemblyName) $(BinFolder)$(Configuration).$(Platform).$(AssemblyName) + + + diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderPoolBlockingTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderPoolBlockingTest.cs new file mode 100644 index 0000000000..d2922ba23d --- /dev/null +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderPoolBlockingTest.cs @@ -0,0 +1,21 @@ +// 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. + +using Xunit; + +namespace Microsoft.Data.SqlClient.Tests +{ + public partial class SqlConnectionStringBuilderTest + { + + [Theory] + // PoolBlockingPeriod is not supported in .NET Standard + [InlineData("PoolBlockingPeriod = Auto")] + [InlineData("PoolBlockingperiod = NeverBlock")] + public void ConnectionStringTestsNetStandard(string connectionString) + { + ExecuteConnectionStringTests(connectionString); + } + } +} diff --git a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs index 3d0588ece9..9796b297c2 100644 --- a/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlConnectionStringBuilderTest.cs @@ -7,7 +7,7 @@ namespace Microsoft.Data.SqlClient.Tests { - public class SqlConnectionStringBuilderTest + public partial class SqlConnectionStringBuilderTest { [Theory] @@ -67,11 +67,6 @@ public class SqlConnectionStringBuilderTest [InlineData("PersistSecurityInfo = true")] [InlineData("Pooling = no")] [InlineData("Pooling = false")] -#if NETCOREAPP - // PoolBlockingPeriod is not supported in .NET Standard - [InlineData("PoolBlockingPeriod = Auto")] - [InlineData("PoolBlockingperiod = NeverBlock")] -#endif [InlineData("Replication = true")] [InlineData("Transaction Binding = Explicit Unbind")] [InlineData("Trust Server Certificate = true")] @@ -145,7 +140,7 @@ public void ConnectionStringBuilder_AttachDbFileName_DataDirectory(string value, Assert.Equal(expected, builder.ConnectionString); } - private void ExecuteConnectionStringTests(string connectionString) + internal void ExecuteConnectionStringTests(string connectionString) { SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectionString); string retrievedString = builder.ConnectionString; From 5b53924d498701d99a2c3b2f9ad1a9da210bb485 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Mon, 19 Oct 2020 13:15:32 -0700 Subject: [PATCH 9/9] Adjust EventSource for .NET Standard support --- .../Microsoft/Data/SqlClient/SqlClientEventSource.Windows.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientEventSource.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientEventSource.Windows.cs index 2249bd747f..caa30908c6 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientEventSource.Windows.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlClientEventSource.Windows.cs @@ -35,7 +35,7 @@ protected override void OnEventCommand(EventCommandEventArgs e) // If registration fails, all write and unregister commands will be a no-op. // If managed networking is enabled, don't call native wrapper methods -#if NETCOREAPP +#if NETCOREAPP || NETSTANDARD if (AppContext.TryGetSwitch("Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows", out bool isEnabled) && isEnabled) { return;