diff --git a/build.proj b/build.proj
index 79635218ff..330a76be56 100644
--- a/build.proj
+++ b/build.proj
@@ -153,6 +153,13 @@
+
+
+
+
+
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 6332d1d8c4..73c0cb3c9c 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -4,8 +4,6 @@
net8.0;net9.0Microsoft.Data.SqlClient is not supported on this platform.$(OS)
- true
- truefalsenetcoreapp
@@ -40,17 +38,129 @@
-
+
+
+
+ $(DefineConstants),_UNIX
+ $(DefineConstants),_WINDOWS
+
+
+
-
+
Interop\Common\Sni\SniErrors.cs
+
+ Interop\Windows\Handles\SafeLibraryHandle.netcore.cs
+
+
+ Interop\Windows\Kernel32\FileTypes.cs
+
+
+ Interop\Windows\Kernel32\IoControlCodeAccess.cs
+
+
+ Interop\Windows\Kernel32\IoControlTransferType.cs
+
+
+ Interop\Windows\Kernel32\Kernel32.cs
+
+
+ Interop\Windows\NtDll\CreateDisposition.cs
+
+
+ Interop\Windows\NtDll\CreateOptions.cs
+
+
+ Interop\Windows\NtDll\DesiredAccess.cs
+
+
+ Interop\Windows\NtDll\FileFullEaInformation.cs
+
+
+ Interop\Windows\NtDll\ImpersonationLevel.cs
+
+
+ Interop\Windows\NtDll\IoStatusBlock.cs
+
+
+ Interop\Windows\NtDll\NtDll.cs
+
+
+ Interop\Windows\NtDll\ObjectAttributeFlags.cs
+
+
+ Interop\Windows\NtDll\ObjectAttributes.cs
+
+
+ Interop\Windows\NtDll\SecurityQualityOfService.cs
+
+
+ Interop\Windows\Sni\AuthProviderInfo.cs
+
+
+ Interop\Windows\Sni\ConsumerInfo.cs
+
+
+ Interop\Windows\Sni\ConsumerNumber.cs
+
+
+ Interop\Windows\Sni\Delegates.cs
+
+
+ Interop\Windows\Sni\IoType.cs
+
+
+ Interop\Windows\Sni\ISniNativeMethods.cs
+
+
+ Interop\Windows\Sni\Prefix.cs
+
+
+ Interop\Windows\Sni\Provider.cs
+
+
+ Interop\Windows\Sni\QueryType.cs
+
+
+ Interop\Windows\Sni\SniClientConsumerInfo.cs
+
+
+ Interop\Windows\Sni\SniConsumerInfo.cs
+
+
+ Interop\Windows\Sni\SniDnsCacheInfo.cs
+
+
+ Interop\Windows\Sni\SniError.cs
+
+
+ Interop\Windows\Sni\SniNativeMethods.netcore.cs
+
+
+ Interop\Windows\Sni\SniNativeWrapper.cs
+
+
+ Interop\Windows\Sni\SniSslProtocols.cs
+
+
+ Interop\Windows\Sni\TransparentNetworkResolutionMode.cs
+
+
+ Interop\Windows\SystemErrors.cs
+
+
+ Interop\Windows\UnicodeString.cs
+
Microsoft\Data\Common\ActivityCorrelator.cs
Microsoft\Data\Common\AdapterUtil.cs
+
+ Microsoft\Data\Common\AdapterUtil.netcore.cs
+
Microsoft\Data\Common\BitConverterCompatible.cs
@@ -93,68 +203,11 @@
Microsoft\Data\OperationAbortedException.cs
-
- Microsoft\Data\ProviderBase\DbConnectionInternal.cs
-
-
+
Microsoft\Data\ProviderBase\DbConnectionClosed.cs
-
- Microsoft\Data\SqlClient\AlwaysEncrypted\ColumnMasterKeyMetadata.cs
-
-
- Microsoft\Data\SqlClient\AlwaysEncrypted\EncryptedColumnEncryptionKeyParameters.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\ChannelDbConnectionPool.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\ConnectionPoolSlots.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContext.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContextKey.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolGroup.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolGroupProviderInfo.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolKey.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolOptions.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolProviderInfo.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolState.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\IDbConnectionPool.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolGroupProviderInfo.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolKey.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolProviderInfo.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\TransactedConnectionPool.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\WaitHandleDbConnectionPool.cs
+
+ Microsoft\Data\ProviderBase\DbConnectionInternal.cs
Microsoft\Data\ProviderBase\DbMetaDataFactory.cs
@@ -168,12 +221,21 @@
Microsoft\Data\ProviderBase\TimeoutTimer.cs
+
+ Microsoft\Data\SqlClient\AlwaysEncrypted\ColumnMasterKeyMetadata.cs
+
+
+ Microsoft\Data\SqlClient\AlwaysEncrypted\EncryptedColumnEncryptionKeyParameters.cs
+
Microsoft\Data\Sql\SqlDataSourceEnumerator.cs
Microsoft\Data\Sql\SqlDataSourceEnumeratorManagedHelper.netcore.cs
+
+ Microsoft\Data\Sql\SqlDataSourceEnumeratorNativeHelper.cs
+
Microsoft\Data\Sql\SqlDataSourceEnumeratorUtil.cs
@@ -219,6 +281,57 @@
Microsoft\Data\SqlClient\Connection\SessionStateRecord.cs
+
+ Microsoft\Data\SqlClient\ConnectionPool\ChannelDbConnectionPool.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\ConnectionPoolSlots.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContext.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolAuthenticationContextKey.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolGroup.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolGroupProviderInfo.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolKey.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolOptions.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolProviderInfo.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolState.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\IDbConnectionPool.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolGroupProviderInfo.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolKey.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolProviderInfo.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\TransactedConnectionPool.cs
+
+
+ Microsoft\Data\SqlClient\ConnectionPool\WaitHandleDbConnectionPool.cs
+
Microsoft\Data\SqlClient\DataClassification\SensitivityClassification.cs
@@ -297,12 +410,27 @@
Microsoft\Data\SqlClient\EnclaveSessionCache.cs
+
+ Microsoft\Data\SqlClient\ISqlVector.cs
+
Microsoft\Data\SqlClient\LocalAppContextSwitches.cs
+
+ Microsoft\Data\SqlClient\LocalDb\LocalDbApi.unix.cs
+
+
+ Microsoft\Data\SqlClient\LocalDb\LocalDbApi.windows.cs
+
Microsoft\Data\SqlClient\ManagedSni\ConcurrentQueueSemaphore.netcore.cs
+
+ Microsoft\Data\SqlClient\ManagedSni\LocalDB.netcore.unix.cs
+
+
+ Microsoft\Data\SqlClient\ManagedSni\LocalDB.netcore.windows.cs
+
Microsoft\Data\SqlClient\ManagedSni\ResolvedServerSpn.cs
@@ -360,9 +488,6 @@
Microsoft\Data\SqlClient\ManagedSni\SslOverTdsStream.netcore.cs
-
- Microsoft\Data\SqlClient\ManagedSni\SslOverTdsStream.NetCoreApp.cs
-
Microsoft\Data\SqlClient\ManagedSni\SsrpClient.netcore.cs
@@ -375,6 +500,12 @@
Microsoft\Data\SqlClient\Packet.cs
+
+ Microsoft\Data\SqlClient\PacketHandle.netcore.unix.cs
+
+
+ Microsoft\Data\SqlClient\PacketHandle.windows.cs
+
Microsoft\Data\SqlClient\ParameterPeekAheadValue.cs
@@ -393,32 +524,38 @@
Microsoft\Data\SqlClient\Reliability\ISqlConfigurableRetryConnectionSection.cs
+
+ Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryFactory.cs
+
+
+ Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryLogicLoader.cs
+
+
+ Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryLogicManager.cs
+
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryingEventArgs.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryingEventArgs.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryIntervalBaseEnumerator.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryIntervalBaseEnumerator.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogic.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryLogic.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogicBase.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryLogicBase.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogicBaseProvider.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryLogicBaseProvider.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogicProvider.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryFactory.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryLogicLoader.cs
-
-
- Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryLogicManager.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryLogicProvider.cs
Microsoft\Data\SqlClient\Reliability\SqlRetryIntervalEnumerators.cs
@@ -483,8 +620,11 @@
Microsoft\Data\SqlClient\Server\ValueUtilsSmi.cs
-
- Microsoft\Data\SqlClient\ISqlVector.cs
+
+ Microsoft\Data\SqlClient\SessionHandle.netcore.unix.cs
+
+
+ Microsoft\Data\SqlClient\SessionHandle.windows.cs
Microsoft\Data\SqlClient\SignatureVerificationCache.cs
@@ -522,8 +662,8 @@
Microsoft\Data\SqlClient\SqlBatchCommand.cs
-
- Microsoft\Data\SqlClient\SqlBatchCommand.Net8OrGreater.cs
+
+ Microsoft\Data\SqlClient\SqlBatchCommand.netcore.cs
Microsoft\Data\SqlClient\SqlBatchCommandCollection.cs
@@ -585,12 +725,21 @@
Microsoft\Data\SqlClient\SqlColumnEncryptionCertificateStoreProvider.cs
+
+ Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.netcore.unix.cs
+
+
+ Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.windows.cs
+
+
+ Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.netcore.unix.cs
+
+
+ Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.windows.cs
+
Microsoft\Data\SqlClient\SqlColumnEncryptionEnclaveProvider.cs
-
- Microsoft\Data\SqlClient\SqlCommandBuilder.cs
-
Microsoft\Data\SqlClient\SqlColumnEncryptionKeyStoreProvider.cs
@@ -615,6 +764,9 @@
Microsoft\Data\SqlClient\SqlCommand.Xml.cs
+
+ Microsoft\Data\SqlClient\SqlCommandBuilder.cs
+
Microsoft\Data\SqlClient\SqlCommandSet.cs
@@ -774,15 +926,18 @@
Microsoft\Data\SqlClient\SqlUtil.cs
+
+ Microsoft\Data\SqlClient\SSPI\NativeSspiContextProvider.windows.cs
+
Microsoft\Data\SqlClient\SSPI\NegotiateSspiContextProvider.cs
-
- Microsoft\Data\SqlClient\SSPI\SspiContextProvider.cs
-
Microsoft\Data\SqlClient\SSPI\SspiAuthenticationParameters.cs
+
+ Microsoft\Data\SqlClient\SSPI\SspiContextProvider.cs
+
Microsoft\Data\SqlClient\Utilities\ObjectPool.cs
@@ -801,15 +956,27 @@
Microsoft\Data\SqlClient\TdsParserHelperClasses.cs
+
+ Microsoft\Data\SqlClient\TdsParserSafeHandles.windows.cs
+
Microsoft\Data\SqlClient\TdsParserStateObject.cs
Microsoft\Data\SqlClient\TdsParserStateObject.Multiplexer.cs
+
+ Microsoft\Data\SqlClient\TdsParserStateObjectFactory.unix.cs
+
+
+ Microsoft\Data\SqlClient\TdsParserStateObjectFactory.windows.cs
+
Microsoft\Data\SqlClient\TdsParserStateObjectManaged.netcore.cs
+
+ Microsoft\Data\SqlClient\TdsParserStateObjectNative.windows.cs
+
Microsoft\Data\SqlClient\TdsParserStaticMethods.cs
@@ -823,7 +990,13 @@
Microsoft\Data\SqlClient\TdsValueSetter.cs
- Microsoft\Data\SqlClient\TransactionRequest.cs
+ Microsoft\Data\SqlClient\TransactionRequest.cs
+
+
+ Microsoft\Data\SqlClient\UserAgent\UserAgentInfo.cs
+
+
+ Microsoft\Data\SqlClient\UserAgent\UserAgentInfoDto.cs
Microsoft\Data\SqlClient\VirtualSecureModeEnclaveProvider.cs
@@ -834,247 +1007,53 @@
Microsoft\Data\SqlDbTypeExtensions.cs
+
+ Microsoft\Data\SqlTypes\SqlFileStream.netcore.unix.cs
+
+
+ Microsoft\Data\SqlTypes\SqlFileStream.windows.cs
+
+
+ Microsoft\Data\SqlTypes\SqlJson.cs
+
Microsoft\Data\SQLTypes\SQLResource.cs
Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs
-
- Microsoft\Data\SqlTypes\SqlJson.cs
-
Microsoft\Data\SqlTypes\SqlVector.cs
-
- Microsoft\Data\SqlClient\UserAgent\UserAgentInfo.cs
-
-
- Microsoft\Data\SqlClient\UserAgent\UserAgentInfoDto.cs
-
Resources\ResCategoryAttribute.cs
Resources\ResDescriptionAttribute.cs
-
- System\Diagnostics\CodeAnalysis.cs
+
+ Resources\StringsHelper.cs
TypeForwards.netcore.cs
-
-
-
- Interop\Windows\Handles\SafeLibraryHandle.netcore.cs
-
-
- Interop\Windows\SystemErrors.cs
-
-
- Interop\Windows\Kernel32\FileTypes.cs
-
-
- Interop\Windows\Kernel32\IoControlCodeAccess.cs
-
-
- Interop\Windows\Kernel32\IoControlTransferType.cs
-
-
- Interop\Windows\Kernel32\Kernel32.cs
-
-
- Interop\Windows\NtDll\CreateDisposition.cs
-
-
- Interop\Windows\NtDll\CreateOptions.cs
-
-
- Interop\Windows\NtDll\DesiredAccess.cs
-
-
- Interop\Windows\NtDll\FileFullEaInformation.cs
-
-
- Interop\Windows\NtDll\ImpersonationLevel.cs
-
-
- Interop\Windows\NtDll\IoStatusBlock.cs
-
-
- Interop\Windows\NtDll\NtDll.cs
-
-
- Interop\Windows\NtDll\ObjectAttributeFlags.cs
-
-
- Interop\Windows\NtDll\ObjectAttributes.cs
-
-
- Interop\Windows\NtDll\SecurityQualityOfService.cs
-
-
- Interop\Windows\Sni\AuthProviderInfo.cs
-
-
- Interop\Windows\Sni\ConsumerInfo.cs
-
-
- Interop\Windows\Sni\ConsumerNumber.cs
-
-
- Interop\Windows\Sni\Delegates.cs
-
-
- Interop\Windows\Sni\IoType.cs
-
-
- Interop\Windows\Sni\ISniNativeMethods.cs
-
-
- Interop\Windows\Sni\Prefix.cs
-
-
- Interop\Windows\Sni\Provider.cs
-
-
- Interop\Windows\Sni\QueryType.cs
-
-
- Interop\Windows\Sni\SniClientConsumerInfo.cs
-
-
- Interop\Windows\Sni\SniConsumerInfo.cs
-
-
- Interop\Windows\Sni\SniDnsCacheInfo.cs
-
-
- Interop\Windows\Sni\SniError.cs
-
-
- Interop\Windows\Sni\SniNativeMethods.netcore.cs
-
-
- Interop\Windows\Sni\SniNativeWrapper.cs
-
-
- Interop\Windows\Sni\SniSslProtocols.cs
-
-
- Interop\Windows\Sni\TransparentNetworkResolutionMode.cs
-
-
- Interop\Windows\UnicodeString.cs
-
-
- Microsoft\Data\Common\AdapterUtil.Windows.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumeratorNativeHelper.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumerator.Windows.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.Windows.cs
-
-
- Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs
-
-
- Microsoft\Data\SqlClient\ManagedSni\LocalDB.netcore.Windows.cs
-
-
- Microsoft\Data\SqlClient\PacketHandle.Windows.cs
-
-
- Microsoft\Data\SqlClient\SessionHandle.Windows.cs
-
-
- Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.Windows.cs
-
-
- Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.Windows.cs
-
-
- Microsoft\Data\SqlClient\SSPI\NativeSspiContextProvider.cs
-
-
- Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs
-
-
- Microsoft\Data\SqlClient\TdsParserStateObjectFactory.Windows.cs
-
-
- Microsoft\Data\SqlClient\TdsParserStateObjectNative.Windows.cs
-
-
- Microsoft\Data\SqlTypes\SqlFileStream.Windows.cs
-
-
-
- ILLink.Substitutions.xml
- Resources\ILLink.Substitutions.Windows.xml
+
+
+
+
+
+ Resources\ILLink.Substitutions.xml
-
-
-
-
-
- Microsoft\Data\Common\AdapterUtil.Unix.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumerator.netcore.Unix.cs
-
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.Unix.cs
-
-
- Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Unix.cs
-
-
- Microsoft\Data\SqlClient\ManagedSni\LocalDB.netcore.Unix.cs
-
-
- Microsoft\Data\SqlClient\PacketHandle.netcore.Unix.cs
-
-
- Microsoft\Data\SqlClient\SessionHandle.netcore.Unix.cs
-
-
- Microsoft\Data\SqlClinet\SqlColumnEncryptionCngProvider.netcore.Unix.cs
-
-
- Microsoft\Data\SqlClinet\SqlColumnEncryptionCspProvider.netcore.Unix.cs
-
-
- Microsoft\Data\SqlClient\TdsParserStateObjectFactory.Unix.cs
-
-
- Microsoft\Data\SqlTypes\SqlFileStream.netcore.Unix.cs
-
-
- ILLink.Substitutions.xml
- Resources\ILLink.Substitutions.Unix.xml
+
+ Resources\Microsoft.Data.SqlCLient.SqlMetaData.xml
+ Microsoft.Data.SqlClient.SqlMetaData.xml
-
-
-
-
- Resources\StringsHelper.cs
-
-
- Resources\Strings.Designer.cs
- True
- True
- Strings.resx
-
+
Resources\Strings.resx
Microsoft.Data.SqlClient.Resources.Strings.resources
@@ -1082,17 +1061,23 @@
Strings.Designer.csSystem
-
+
+
+
Resources\%(RecursiveDir)%(Filename)%(Extension)
- Microsoft.Data.SqlClient.Resources.%(Filename).resources
-
-
- Microsoft.Data.SqlClient.SqlMetaData.xml
- Resources\Microsoft.Data.SqlClient.SqlMetaData.xml
+ Microsoft.Data.SqlCLient.Resources.%(Filename).resources
+
+
+
+ Resources\Strings.Designer.cs
+ True
+ True
+ Strings.resx
+
-
+
@@ -1106,6 +1091,7 @@
+
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 fc00117bd7..f8041d0d61 100644
--- a/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj
@@ -1,10 +1,11 @@
- {407890AC-9876-4FEF-A6F1-F36A876BAADE}
-
+ Microsoft.Data.SqlClientnet462
+ $(OS)
+ {407890AC-9876-4FEF-A6F1-F36A876BAADE}
+ true
- Microsoft.Data.SqlClientAnyCPU$(BinFolder)$(Configuration).$(OutputPlatform)\$(ObjFolder)$(Configuration).$(OutputPlatform)\
@@ -81,9 +82,6 @@
PdbonlyTrue
-
- $(DefineConstants);NETFRAMEWORK;
-
@@ -95,10 +93,17 @@
-
+
+
+
+
+ $(DefineConstants),_WINDOWS
+
+
+
- Interop\Common\SniErrors.cs
+ Interop\Common\Sni\SniErrors.cs
Interop\Windows\Kernel32\FileTypes.cs
@@ -109,103 +114,103 @@
Interop\Windows\Kernel32\IoControlTransferType.cs
-
+
Interop\Windows\Kernel32\Kernel32.cs
-
+
Interop\Windows\Kernel32\Kernel32Safe.netfx.cs
-
+
Interop\Windows\NtDll\CreateDisposition.cs
-
+
Interop\Windows\NtDll\CreateOptions.cs
-
+
Interop\Windows\NtDll\DesiredAccess.cs
-
+
Interop\Windows\NtDll\FileFullEaInformation.cs
-
- Interop\Windows\NtDll\ImpersonaltionLevel.cs
+
+ Interop\Windows\NtDll\ImpersonationLevel.cs
Interop\Windows\NtDll\IoStatusBlock.cs
-
+
Interop\Windows\NtDll\NtDll.cs
-
- Interop\Windows\NtDll\ObjectAttributes.cs
+
+ Interop\Windows\NtDll\ObjectAttributeFlags.cs
-
- Interop\Windows\NtDll\ObjecAttributes.cs
+
+ Interop\Windows\NtDll\ObjectAttributes.cs
-
+
Interop\Windows\NtDll\SecurityQualityOfService.cs
-
+
Interop\Windows\Sni\AuthProviderInfo.cs
-
+
Interop\Windows\Sni\ConsumerInfo.cs
-
+
Interop\Windows\Sni\ConsumerNumber.cs
-
+
Interop\Windows\Sni\Delegates.cs
-
+
Interop\Windows\Sni\IoType.cs
-
+
Interop\Windows\Sni\ISniNativeMethods.cs
-
+
Interop\Windows\Sni\Prefix.cs
-
+
Interop\Windows\Sni\Provider.cs
-
+
Interop\Windows\Sni\QueryType.cs
-
+
Interop\Windows\Sni\SniClientConsumerInfo.cs
-
+
Interop\Windows\Sni\SniConsumerInfo.cs
-
+
Interop\Windows\Sni\SniDnsCacheInfo.cs
-
+
Interop\Windows\Sni\SniError.cs
-
+
Interop\Windows\Sni\SniNativeMethodsArm64.netfx.cs
-
+
Interop\Windows\Sni\SniNativeMethodsNotSupported.netfx.cs
-
+
Interop\Windows\Sni\SniNativeMethodsX64.netfx.cs
-
+
Interop\Windows\Sni\SniNativeMethodsX86.netfx.cs
-
+
Interop\Windows\Sni\SniNativeWrapper.cs
-
- Interop\Windows\Sni\SqlDependencyProcessDispatcherStorage.netfx.cs
-
-
+
Interop\Windows\Sni\SniSslProtocols.cs
-
+
+ Interop\Windows\Sni\SqlDependencyProcessDispatcherStorage.netfx.cs
+
+
Interop\Windows\Sni\TransparentNetworkResolutionMode.cs
@@ -220,8 +225,8 @@
Microsoft\Data\Common\AdapterUtil.cs
-
- Microsoft\Data\Common\AdapterUtil.Windows.cs
+
+ Microsoft\Data\Common\AdapterUtil.netfx.cs
Microsoft\Data\Common\BitConverterCompatible.cs
@@ -235,6 +240,9 @@
Microsoft\Data\Common\ConnectionString\DbConnectionOptions.Debug.cs
+
+ Microsoft\Data\Common\ConnectionString\DbConnectionString.netfx.cs
+
Microsoft\Data\Common\ConnectionString\DbConnectionStringDefaults.cs
@@ -244,9 +252,6 @@
Microsoft\Data\Common\ConnectionString\DbConnectionStringSynonyms.cs
-
- Microsoft\Data\Common\ConnectionString\DbConnectionString.netfx.cs
-
Microsoft\Data\Common\ConnectionString\DbConnectionStringUtilities.cs
@@ -256,6 +261,9 @@
Microsoft\Data\Common\ConnectionString\PoolBlockingUtilities.cs
+
+ Microsoft\Data\SqlClient\ISqlVector.cs
+
Microsoft\Data\Common\MultipartIdentifier.cs
@@ -268,18 +276,81 @@
Microsoft\Data\OperationAbortedException.cs
-
+
Microsoft\Data\ProviderBase\DbConnectionClosed.cs
Microsoft\Data\ProviderBase\DbConnectionInternal.cs
+
+ Microsoft\Data\ProviderBase\DbMetaDataFactory.cs
+
+
+ Microsoft\Data\ProviderBase\DbReferenceCollection.cs
+
+
+ Microsoft\Data\ProviderBase\FieldNameLookup.cs
+
+
+ Microsoft\Data\ProviderBase\TimeoutTimer.cs
+
+
+ Microsoft\Data\Sql\SqlDataSourceEnumerator.cs
+
+
+ Microsoft\Data\Sql\SqlDataSourceEnumeratorNativeHelper.windows.cs
+
+
+ Microsoft\Data\Sql\SqlDataSourceEnumeratorUtil.cs
+
+
+ Microsoft\Data\Sql\SqlNotificationRequest.cs
+
+
+ Microsoft\Data\SqlClient\AAsyncCallContext.cs
+
+
+ Microsoft\Data\SqlClient\ActiveDirectoryAuthenticationProvider.cs
+
+
+ Microsoft\Data\SqlClient\ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
+
Microsoft\Data\SqlClient\AlwaysEncrypted\ColumnMasterKeyMetadata.cs
Microsoft\Data\SqlClient\AlwaysEncrypted\EncryptedColumnEncryptionKeyParameters.cs
+
+ Microsoft\Data\SqlClient\AlwaysEncryptedEnclaveProviderUtils.cs
+
+
+ Microsoft\Data\SqlClient\AlwaysEncryptedHelperClasses.cs
+
+
+ Microsoft\Data\SqlClient\AlwaysEncryptedKeyConverter.cs
+
+
+ Microsoft\Data\SqlClient\ApplicationIntent.cs
+
+
+ Microsoft\Data\SqlClient\AssemblyRef.cs
+
+
+ Microsoft\Data\SqlClient\AzureAttestationBasedEnclaveProvider.cs
+
+
+ Microsoft\Data\SqlClient\ColumnEncryptionKeyInfo.cs
+
+
+ Microsoft\Data\SqlClient\Connection\ServerInfo.cs
+
+
+ Microsoft\Data\SqlClient\Connection\SessionData.cs
+
+
+ Microsoft\Data\SqlClient\Connection\SessionStateRecord.cs
+
Microsoft\Data\SqlClient\ConnectionPool\ChannelDbConnectionPool.cs
@@ -301,9 +372,6 @@
Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.cs
-
- Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolIdentity.Windows.cs
-
Microsoft\Data\SqlClient\ConnectionPool\DbConnectionPoolKey.cs
@@ -323,7 +391,7 @@
Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolGroupProviderInfo.cs
- Microsoft\Data\SqlClient\SqlConnectionPoolKey.cs
+ Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolKey.cs
Microsoft\Data\SqlClient\ConnectionPool\SqlConnectionPoolProviderInfo.cs
@@ -334,6 +402,9 @@
Microsoft\Data\SqlClient\ConnectionPool\WaitHandleDbConnectionPool.cs
+
+ Microsoft\Data\SqlClient\DataClassification\SensitivityClassification.cs
+
Microsoft\Data\SqlClient\Diagnostics\DiagnosticScope.cs
@@ -391,93 +462,6 @@
Microsoft\Data\SqlClient\Diagnostics\SqlDiagnosticListener.cs
-
- Microsoft\Data\ProviderBase\DbMetaDataFactory.cs
-
-
- Microsoft\Data\ProviderBase\DbReferenceCollection.cs
-
-
- Microsoft\Data\ProviderBase\FieldNameLookup.cs
-
-
- Microsoft\Data\ProviderBase\TimeoutTimer.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumerator.Windows.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumeratorNativeHelper.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumeratorUtil.cs
-
-
- Microsoft\Data\Sql\SqlNotificationRequest.cs
-
-
- Resources\ResCategoryAttribute.cs
-
-
- Microsoft\Data\SqlClient\SSPI\NativeSspiContextProvider.cs
-
-
- Microsoft\Data\SqlClient\SSPI\NegotiateSspiContextProvider.cs
-
-
- Microsoft\Data\SqlClient\SSPI\SspiContextProvider.cs
-
-
- Microsoft\Data\SqlClient\SSPI\SspiAuthenticationParameters.cs
-
-
- Microsoft\Data\SqlClient\TdsParser.cs
-
-
- Microsoft\Data\Sql\SqlDataSourceEnumerator.cs
-
-
- Microsoft\Data\SqlClient\AAsyncCallContext.cs
-
-
- Microsoft\Data\SqlClient\ActiveDirectoryAuthenticationTimeoutRetryHelper.cs
-
-
- Microsoft\Data\SqlClient\ApplicationIntent.cs
-
-
- Microsoft\Data\SqlClient\AssemblyRef.cs
-
-
- Microsoft\Data\SqlClient\ActiveDirectoryAuthenticationProvider.cs
-
-
- Microsoft\Data\SqlClient\AlwaysEncryptedEnclaveProviderUtils.cs
-
-
- Microsoft\Data\SqlClient\AlwaysEncryptedHelperClasses.cs
-
-
- Microsoft\Data\SqlClient\AlwaysEncryptedKeyConverter.cs
-
-
- Microsoft\Data\SqlClient\AzureAttestationBasedEnclaveProvider.cs
-
-
- Microsoft\Data\SqlClient\ColumnEncryptionKeyInfo.cs
-
-
- Microsoft\Data\SqlClient\Connection\ServerInfo.cs
-
-
- Microsoft\Data\SqlClient\Connection\SessionData.cs
-
-
- Microsoft\Data\SqlClient\Connection\SessionStateRecord.cs
-
-
- Microsoft\Data\SqlClient\DataClassification\SensitivityClassification.cs
-
Microsoft\Data\SqlClient\DisposableTemporaryOnStack.cs
@@ -496,8 +480,11 @@
Microsoft\Data\SqlClient\EnclaveSessionCache.cs
-
- Microsoft\Data\SqlClient\LocalDb\LocalDbApi.Windows.cs
+
+ Microsoft\Data\SqlClient\LocalAppContextSwitches.cs
+
+
+ Microsoft\Data\SqlClient\LocalDb\LocalDbApi.windows.cs
Microsoft\Data\SqlClient\LocalDb\LocalDbConfigurationSection.netfx.cs
@@ -508,9 +495,6 @@
Microsoft\Data\SqlClient\LocalDb\LocalDbInstancesCollection.netfx.cs
-
- Microsoft\Data\SqlClient\LocalAppContextSwitches.cs
-
Microsoft\Data\SqlClient\ManagedSni\ResolvedServerSpn.cs
@@ -523,8 +507,8 @@
Microsoft\Data\SqlClient\Packet.cs
-
- Microsoft\Data\SqlClient\PacketHandle.Windows.cs
+
+ Microsoft\Data\SqlClient\PacketHandle.netfx.cs
Microsoft\Data\SqlClient\ParameterPeekAheadValue.cs
@@ -535,32 +519,38 @@
Microsoft\Data\SqlClient\Reliability\AppConfigManager.cs
-
- Microsoft\Data\SqlClient\Reliability\IAppContextSwitchOverridesSection.cs
-
-
- Microsoft\Data\SqlClient\Reliability\ISqlConfigurableRetryCommandSection.cs
-
-
- Microsoft\Data\SqlClient\Reliability\ISqlConfigurableRetryConnectionSection.cs
-
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryingEventArgs.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryingEventArgs.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryIntervalBaseEnumerator.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryIntervalBaseEnumerator.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogic.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryLogic.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogicBase.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryLogicBase.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogicBaseProvider.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryLogicBaseProvider.cs
+
- Microsoft\Data\SqlClient\Reliability\SqlRetryLogicProvider.cs
+ Microsoft\Data\SqlClient\Reliability\Common\SqlRetryLogicProvider.cs
+
+
+ Microsoft\Data\SqlClient\Reliability\IAppContextSwitchOverridesSection.cs
+
+
+ Microsoft\Data\SqlClient\Reliability\ISqlConfigurableRetryCommandSection.cs
+
+
+ Microsoft\Data\SqlClient\Reliability\ISqlConfigurableRetryConnectionSection.cs
Microsoft\Data\SqlClient\Reliability\SqlConfigurableRetryFactory.cs
@@ -611,7 +601,7 @@
Microsoft\Data\SqlClient\Server\SmiTypedGetterSetter.cs
- Microsoft\Data\SqlClient\Server\SmiXetterAccess.cs
+ Microsoft\Data\SqlClient\Server\SmiXetterAccessMap.cs
Microsoft\Data\SqlClient\Server\SmiXetterTypeCode.cs
@@ -637,18 +627,12 @@
Microsoft\Data\SqlClient\Server\SqlSer.cs
-
- Microsoft\Data\SqlClient\ISqlVector.cs
-
-
- Microsoft\Data\SqlClient\SessionHandle.Windows.cs
+
+ Microsoft\Data\SqlClient\SessionHandle.netfx.cs
Microsoft\Data\SqlClient\SignatureVerificationCache.cs
-
- Microsoft\Data\SqlClient\SortOrder.cs
-
Microsoft\Data\SqlClient\SqlAeadAes256CbcHmac256Algorithm.cs
@@ -667,18 +651,18 @@
Microsoft\Data\SqlClient\SqlAuthenticationProviderManager.cs
-
- Microsoft\Data\SqlClient\SqlBuffer.cs
-
-
- Microsoft\Data\SqlClient\SqlBulkCopy.cs
-
Microsoft\Data\SqlClient\SqlAuthenticationToken.cs
Microsoft\Data\SqlClient\SqlBatchCommand.cs
+
+ Microsoft\Data\SqlClient\SqlBuffer.cs
+
+
+ Microsoft\Data\SqlClient\SqlBulkCopy.cs
+
Microsoft\Data\SqlClient\SqlBulkCopyColumnMapping.cs
@@ -736,11 +720,11 @@
Microsoft\Data\SqlClient\SqlColumnEncryptionCertificateStoreProvider.cs
-
- Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.cs
+
+ Microsoft\Data\SqlClient\SqlColumnEncryptionCngProvider.windows.cs
-
- Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.cs
+
+ Microsoft\Data\SqlClient\SqlColumnEncryptionCspProvider.windows.cs
Microsoft\Data\SqlClient\SqlColumnEncryptionEnclaveProvider.cs
@@ -874,12 +858,12 @@
Microsoft\Data\SqlClient\SqlNotificationType.cs
-
- Microsoft\Data\SqlClient\SqlParameterCollection.cs
-
Microsoft\Data\SqlClient\SqlParameter.cs
+
+ Microsoft\Data\SqlClient\SqlParameterCollection.cs
+
Microsoft\Data\SqlClient\SqlQueryMetadataCache.cs
@@ -904,14 +888,14 @@
Microsoft\Data\SqlClient\SqlSequentialStream.cs
-
- Microsoft\Data\SqlClient\SqlStream.cs
+
+ Microsoft\Data\SqlClient\SqlSequentialTextReader.cs
Microsoft\Data\SqlClient\SqlStatistics.cs
-
- Microsoft\Data\SqlClient\SqlSequentialTextReader.cs
+
+ Microsoft\Data\SqlClient\SqlStream.cs
Microsoft\Data\SqlClient\SqlSymmetricKeyCache.cs
@@ -925,14 +909,32 @@
Microsoft\Data\SqlClient\SqlUtil.cs
+
+ Microsoft\Data\SqlClient\SSPI\NativeSspiContextProvider.windows..cs
+
+
+ Microsoft\Data\SqlClient\SSPI\NegotiateSspiContextProvider.cs
+
+
+ Microsoft\Data\SqlClient\SSPI\SspiAuthenticationParameters.cs
+
+
+ Microsoft\Data\SqlClient\SSPI\SspiContextProvider.cs
+
+
+ Microsoft\Data\SqlClient\SortOrder.cs
+
Microsoft\Data\SqlClient\TdsEnums.cs
Microsoft\Data\SqlClient\TdsParameterSetter.cs
-
- Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs
+
+ Microsoft\Data\SqlClient\TdsParser.cs
+
+
+ Microsoft\Data\SqlClient\TdsParserSafeHandles.windows.cs
Microsoft\Data\SqlClient\TdsParserStateObject.cs
@@ -940,11 +942,11 @@
Microsoft\Data\SqlClient\TdsParserStateObject.Multiplexer.cs
-
- Microsoft\Data\SqlClient\TdsParserStateObjectFactory.Windows.cs
+
+ Microsoft\Data\SqlClient\TdsParserStateObjectFactory.windows.cs
-
- Microsoft\Data\SqlClient\TdsParserStateObjectNative.Windows.cs
+
+ Microsoft\Data\SqlClient\TdsParserStateObjectNative.windows.cs
Microsoft\Data\SqlClient\TdsParserStaticMethods.cs
@@ -962,7 +964,7 @@
Microsoft\Data\SqlClient\TdsValueSetter.cs
- Microsoft\Data\SqlClient\TransactionRequest.cs
+ Microsoft\Data\SqlClient\TransactionRequest.cs
Microsoft\Data\SqlClient\Utilities\BufferWriterExtensions.netfx.cs
@@ -982,14 +984,8 @@
Microsoft\Data\SqlDbTypeExtensions.cs
-
- Microsoft\Data\SqlTypes\SqlFileStream.cs
-
-
- Microsoft\Data\SqlTypes\SQLResource.cs
-
-
- Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs
+
+ Microsoft\Data\SqlTypes\SqlFileStream.windows.cs
Microsoft\Data\SqlTypes\SqlJson.cs
@@ -997,20 +993,32 @@
Microsoft\Data\SqlTypes\SqlVector.cs
+
+ Microsoft\Data\SqlTypes\SQLResource.cs
+
+
+ Microsoft\Data\SqlTypes\SqlTypeWorkarounds.cs
+
Microsoft\Data\SqlClient\UserAgent\UserAgentInfo.cs
Microsoft\Data\SqlClient\UserAgent\UserAgentInfoDto.cs
+
+ Resources\ResCategoryAttribute.cs
+
+
+ Resources\StringsHelper.cs
+
Resources\ResDescriptionAttribute.cs
System\Buffers\ArrayBufferWriter.netfx.cs
-
- System\Diagnostics\CodeAnalysis.cs
+
+ System\Diagnostics\CodeAnalysis.netfx.cs
System\IO\StreamExtensions.netfx.cs
@@ -1019,17 +1027,16 @@
System\Runtime\CompilerServices\IsExternalInit.netfx.cs
-
+
+
-
- Resources\StringsHelper.cs
-
-
- Resources\Strings.Designer.cs
- True
- True
- Strings.resx
-
+
+ Resources\Microsoft.Data.SqlClient.SqlMetaData.xml
+ Microsoft.Data.SqlClient.SqlMetaData.xml
+ PreserveNewest
+
+
+
Resources\Strings.resx
Microsoft.Data.SqlClient.Resources.Strings.resources
@@ -1037,16 +1044,23 @@
ResXFileCodeGeneratorStrings.Designer.cs
+
+
Resources\%(RecursiveDir)%(Filename)%(Extension)
Microsoft.Data.SqlClient.Resources.%(Filename).resources
-
- Microsoft.Data.SqlClient.SqlMetaData.xml
- Resources\Microsoft.Data.SqlClient.SqlMetaData.xml
- PreserveNewest
-
+
+
+
+ Resources\Strings.Designer.cs
+ True
+ True
+ Strings.resx
+
+
+
@@ -1064,9 +1078,11 @@
-
+
+
+
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Handles/SafeLibraryHandle.netcore.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Handles/SafeLibraryHandle.netcore.cs
index 47728b3726..64bc92d6d4 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Handles/SafeLibraryHandle.netcore.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Handles/SafeLibraryHandle.netcore.cs
@@ -2,9 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Microsoft.Win32.SafeHandles;
+#if NET && _WINDOWS
-#if NET
+using Microsoft.Win32.SafeHandles;
namespace Interop.Windows.Handles
{
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/FileTypes.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/FileTypes.cs
index 59b1c67dcf..8dbbd6fbde 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/FileTypes.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/FileTypes.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.Kernel32
{
internal class FileTypes
@@ -12,3 +14,5 @@ internal class FileTypes
internal const int FILE_TYPE_PIPE = 0x0003;
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/IoControlCodeAccess.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/IoControlCodeAccess.cs
index a7f0c52f8a..bbfce78672 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/IoControlCodeAccess.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/IoControlCodeAccess.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
namespace Interop.Windows.Kernel32
@@ -31,3 +33,5 @@ public enum IoControlCodeAccess
FILE_WRITE_DATA = 0x02
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/IoControlTransferType.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/IoControlTransferType.cs
index 6b0e8571af..8099827bc8 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/IoControlTransferType.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/IoControlTransferType.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.Kernel32
{
///
@@ -35,3 +37,5 @@ public enum IoControlTransferType
METHOD_NEITHER
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/Kernel32.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/Kernel32.cs
index 530838ba38..a938fa2fcc 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/Kernel32.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/Kernel32.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
@@ -92,3 +94,5 @@ internal static extern int GetFullPathName(
internal static extern bool SetThreadErrorMode(uint dwNewMode, out uint lpOldMode);
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/Kernel32Safe.netfx.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/Kernel32Safe.netfx.cs
index 45fe78f630..506cf92c0c 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/Kernel32Safe.netfx.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Kernel32/Kernel32Safe.netfx.cs
@@ -2,13 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NETFRAMEWORK
+#if NETFRAMEWORK && _WINDOWS
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
-using System.Text;
namespace Interop.Windows.Kernel32
{
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/CreateDisposition.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/CreateDisposition.cs
index 8f03025bee..7502a94e64 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/CreateDisposition.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/CreateDisposition.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.NtDll
{
///
@@ -54,3 +56,5 @@ internal enum CreateDisposition : uint
FILE_OVERWRITE_IF = 5
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/CreateOptions.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/CreateOptions.cs
index 39677ab3d5..5c169ec5a0 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/CreateOptions.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/CreateOptions.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
namespace Interop.Windows.NtDll
@@ -196,3 +198,5 @@ internal enum CreateOptions : uint
// FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/DesiredAccess.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/DesiredAccess.cs
index f15fbcf0dc..acf7f9ee0f 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/DesiredAccess.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/DesiredAccess.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
namespace Interop.Windows.NtDll
@@ -188,3 +190,5 @@ internal enum DesiredAccess : uint
FILE_GENERIC_EXECUTE = 0x20000000 // GENERIC_EXECUTE
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/FileFullEaInformation.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/FileFullEaInformation.cs
index 76322ce604..5e545ce131 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/FileFullEaInformation.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/FileFullEaInformation.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System.Runtime.InteropServices;
namespace Interop.Windows.NtDll
@@ -35,3 +37,5 @@ internal struct FileFullEaInformation
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ImpersonationLevel.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ImpersonationLevel.cs
index 5386a4094b..70c606e95b 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ImpersonationLevel.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ImpersonationLevel.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.NtDll
{
///
@@ -39,3 +41,5 @@ internal enum ImpersonationLevel
SecurityDelegation = 3,
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/IoStatusBlock.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/IoStatusBlock.cs
index 7018ef3abd..0e173186b8 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/IoStatusBlock.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/IoStatusBlock.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.Runtime.InteropServices;
@@ -42,3 +44,5 @@ public struct IoStatus
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/NtDll.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/NtDll.cs
index 8dddda19d3..20b5e314db 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/NtDll.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/NtDll.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.IO;
using System.Runtime.InteropServices;
@@ -118,3 +120,5 @@ private static extern unsafe int NtCreateFile(
uint EaLength);
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ObjectAttributeFlags.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ObjectAttributeFlags.cs
index 31dfd80ead..0f70ffa6cf 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ObjectAttributeFlags.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ObjectAttributeFlags.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
namespace Interop.Windows.NtDll
@@ -52,3 +54,5 @@ internal enum ObjectAttributeFlags : uint
// OBJ_VALID_ATTRIBUTES = 0x000001F2
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ObjectAttributes.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ObjectAttributes.cs
index f3198f923e..3093763429 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ObjectAttributes.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/ObjectAttributes.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
namespace Interop.Windows.NtDll
@@ -58,3 +60,5 @@ public ObjectAttributes(
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/SecurityQualityOfService.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/SecurityQualityOfService.cs
index 7f268255d9..0cfa77a2d5 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/SecurityQualityOfService.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/NtDll/SecurityQualityOfService.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System.Runtime.InteropServices;
namespace Interop.Windows.NtDll
@@ -48,3 +50,5 @@ public SecurityQualityOfService(
public bool IsEffectiveOnly { get; set; }
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/AuthProviderInfo.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/AuthProviderInfo.cs
index 7b0818b7c5..e273e5fc1b 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/AuthProviderInfo.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/AuthProviderInfo.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System.Runtime.InteropServices;
namespace Interop.Windows.Sni
@@ -23,3 +25,5 @@ internal struct AuthProviderInfo
public string serverCertFileName;
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ConsumerInfo.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ConsumerInfo.cs
index 358e35cda0..fcb7b9a20d 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ConsumerInfo.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ConsumerInfo.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.Runtime.InteropServices;
@@ -16,3 +18,5 @@ internal struct ConsumerInfo
internal IntPtr key;
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ConsumerNumber.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ConsumerNumber.cs
index a1d4fdf292..f7b11801c9 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ConsumerNumber.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ConsumerNumber.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.Sni
{
internal enum ConsumerNumber
@@ -12,3 +14,5 @@ internal enum ConsumerNumber
SNI_Consumer_Invalid,
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Delegates.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Delegates.cs
index fd1f2d8e39..720ad481e4 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Delegates.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Delegates.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.Runtime.InteropServices;
@@ -12,3 +14,5 @@ namespace Interop.Windows.Sni
internal delegate IntPtr SqlClientCertificateDelegate(IntPtr pCallbackContext);
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ISniNativeMethods.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ISniNativeMethods.cs
index c05c76b188..194e61a4b6 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ISniNativeMethods.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/ISniNativeMethods.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.Runtime.InteropServices;
using System.Text;
@@ -99,3 +101,5 @@ unsafe uint SniSecGenClientContextWrapper(
uint SniWriteSyncOverAsync(SNIHandle pConn, SNIPacket pPacket);
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/IoType.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/IoType.cs
index 167a7a23b5..ef02350e84 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/IoType.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/IoType.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.Sni
{
internal enum IoType
@@ -10,3 +12,5 @@ internal enum IoType
WRITE,
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Prefix.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Prefix.cs
index 45ec71a2cf..52c98bfde9 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Prefix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Prefix.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.Sni
{
internal enum Prefix
@@ -14,3 +16,5 @@ internal enum Prefix
INVALID_PREFIX,
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Provider.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Provider.cs
index 61b33ebfc1..c9bf7a980c 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Provider.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/Provider.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.Sni
{
internal enum Provider
@@ -24,3 +26,5 @@ internal enum Provider
INVALID_PROV,
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/QueryType.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/QueryType.cs
index 5fca987240..14de40336f 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/QueryType.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/QueryType.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.Sni
{
internal enum QueryType
@@ -47,3 +49,5 @@ internal enum QueryType
#endif
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniClientConsumerInfo.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniClientConsumerInfo.cs
index 062c36679f..89199e4417 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniClientConsumerInfo.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniClientConsumerInfo.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System.Runtime.InteropServices;
using Microsoft.Data.SqlClient;
@@ -34,3 +36,5 @@ internal unsafe struct SniClientConsumerInfo
public SniDnsCacheInfo DNSCacheInfo;
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniConsumerInfo.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniConsumerInfo.cs
index 2f084f228d..8cb27dfb5f 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniConsumerInfo.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniConsumerInfo.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.Runtime.InteropServices;
@@ -21,3 +23,5 @@ internal struct SniConsumerInfo
public IntPtr NodeAffinity;
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniDnsCacheInfo.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniDnsCacheInfo.cs
index e0e3c91efe..1d5600aec9 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniDnsCacheInfo.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniDnsCacheInfo.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System.Runtime.InteropServices;
namespace Interop.Windows.Sni
@@ -19,3 +21,5 @@ internal struct SniDnsCacheInfo
public string wszCachedTcpPort;
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniError.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniError.cs
index 2e519c15ab..55f64a32d3 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniError.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniError.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System.Runtime.InteropServices;
namespace Interop.Windows.Sni
@@ -21,3 +23,5 @@ internal struct SniError
internal uint lineNumber;
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethods.netcore.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethods.netcore.cs
index b780f8f63c..32109770e0 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethods.netcore.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethods.netcore.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NET
+#if NET && _WINDOWS
using System;
using System.Runtime.InteropServices;
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsArm64.netfx.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsArm64.netfx.cs
index 7839a047cd..c39c1dbefa 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsArm64.netfx.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsArm64.netfx.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NETFRAMEWORK
+#if NETFRAMEWORK && _WINDOWS
using System;
using System.Runtime.InteropServices;
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsNotSupported.netfx.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsNotSupported.netfx.cs
index 7139ee0b08..0d8600f193 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsNotSupported.netfx.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsNotSupported.netfx.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NETFRAMEWORK
+#if NETFRAMEWORK && _WINDOWS
using System;
using System.Runtime.InteropServices;
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX64.netfx.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX64.netfx.cs
index e899250786..0849e1a22d 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX64.netfx.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX64.netfx.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NETFRAMEWORK
+#if NETFRAMEWORK && _WINDOWS
using System;
using System.Runtime.InteropServices;
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX86.netfx.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX86.netfx.cs
index 4c022821dd..270a522aa6 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX86.netfx.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeMethodsX86.netfx.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NETFRAMEWORK
+#if NETFRAMEWORK && _WINDOWS
using System;
using System.Runtime.InteropServices;
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeWrapper.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeWrapper.cs
index 60f5f98dcd..a563cf73b9 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeWrapper.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniNativeWrapper.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+ #if _WINDOWS
+
using System;
using System.Buffers;
using System.Diagnostics;
@@ -455,3 +457,5 @@ private static void MarshalConsumerInfo(ConsumerInfo consumerInfo, ref SniConsum
#endregion
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniSslProtocols.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniSslProtocols.cs
index cd9bf47ed3..f070082c16 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniSslProtocols.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SniSslProtocols.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.Sni
{
internal enum SniSslProtocols : uint
@@ -30,3 +32,5 @@ internal enum SniSslProtocols : uint
SP_PROT_TLS1_3 = SP_PROT_TLS1_3_SERVER | SP_PROT_TLS1_3_CLIENT,
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SqlDependencyProcessDispatcherStorage.netfx.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SqlDependencyProcessDispatcherStorage.netfx.cs
index dddfcb5e07..19d8b261c3 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SqlDependencyProcessDispatcherStorage.netfx.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/SqlDependencyProcessDispatcherStorage.netfx.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NETFRAMEWORK
+#if NETFRAMEWORK && _WINDOWS
using System;
using System.Diagnostics;
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/TransparentNetworkResolutionMode.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/TransparentNetworkResolutionMode.cs
index fe68cd420d..8d1ac82449 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/TransparentNetworkResolutionMode.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/Sni/TransparentNetworkResolutionMode.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows.Sni
{
internal enum TransparentNetworkResolutionMode : byte
@@ -11,3 +13,5 @@ internal enum TransparentNetworkResolutionMode : byte
ParallelMode
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/SystemErrors.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/SystemErrors.cs
index 40819ef4d9..2265ee1427 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/SystemErrors.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/SystemErrors.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
namespace Interop.Windows
{
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382.aspx
@@ -20,3 +22,5 @@ internal class SystemErrors
internal const int ERROR_MR_MID_NOT_FOUND = 317;
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Interop/Windows/UnicodeString.cs b/src/Microsoft.Data.SqlClient/src/Interop/Windows/UnicodeString.cs
index 7fc87decbf..07ff56dbb4 100644
--- a/src/Microsoft.Data.SqlClient/src/Interop/Windows/UnicodeString.cs
+++ b/src/Microsoft.Data.SqlClient/src/Interop/Windows/UnicodeString.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System.Runtime.InteropServices;
namespace Interop.Windows
@@ -34,3 +36,5 @@ public UnicodeString(char* buffer, int length)
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj
index f428f19b20..69ddbf01fd 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj
@@ -4,7 +4,28 @@
true
-
+
+
+
+
+ $(OS)
+
+
+
+
+
+
+
+ $(DefineConstants),_UNIX
+ $(DefineConstants),_WINDOWS
+
+
+
+
+
+
+
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.Unix.cs
deleted file mode 100644
index 8b84feecfc..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.Unix.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// 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.
-
-namespace Microsoft.Data.Common
-{
- ///
- /// The class ADP defines the exceptions that are specific to the Adapters.
- /// The class contains functions that take the proper informational variables and then construct
- /// the appropriate exception with an error string obtained from the resource framework.
- /// The exception is then returned to the caller, so that the caller may then throw from its
- /// location so that the catcher of the exception will have the appropriate call stack.
- /// This class is used so that there will be compile time checking of error messages.
- /// The resource Framework.txt will ensure proper string text based on the appropriate locale.
- ///
- internal static partial class ADP
- {
- internal static object LocalMachineRegistryValue(string subkey, string queryvalue)
- {
- // No registry in non-Windows environments
- return null;
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.Windows.cs
deleted file mode 100644
index 6fbdfcb343..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.Windows.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// 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 System;
-using System.Runtime.InteropServices;
-using System.Runtime.Versioning;
-using System.Security;
-using System.Security.Permissions;
-using Microsoft.Win32;
-
-namespace Microsoft.Data.Common
-{
- ///
- /// The class ADP defines the exceptions that are specific to the Adapters.
- /// The class contains functions that take the proper informational variables and then construct
- /// the appropriate exception with an error string obtained from the resource framework.
- /// The exception is then returned to the caller, so that the caller may then throw from its
- /// location so that the catcher of the exception will have the appropriate call stack.
- /// This class is used so that there will be compile time checking of error messages.
- /// The resource Framework.txt will ensure proper string text based on the appropriate locale.
- ///
- internal static partial class ADP
- {
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- internal static object LocalMachineRegistryValue(string subkey, string queryvalue)
- { // MDAC 77697
-#if NETFRAMEWORK
- (new RegistryPermission(RegistryPermissionAccess.Read, "HKEY_LOCAL_MACHINE\\" + subkey)).Assert(); // MDAC 62028
-#endif
- try
- {
- using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subkey, false))
- {
- return key?.GetValue(queryvalue);
- }
- }
- catch (SecurityException e)
- {
- // Even though we assert permission - it's possible there are
- // ACL's on registry that cause SecurityException to be thrown.
- ADP.TraceExceptionWithoutRethrow(e);
- return null;
- }
-#if NETFRAMEWORK
- finally
- {
- RegistryPermission.RevertAssert();
- }
-#endif
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs
index 46375fbf20..dcd9f4bac9 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections;
+using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlTypes;
@@ -11,27 +12,26 @@
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
-
using System.Security;
-using System.Security.Permissions;
+using System.Security.Authentication;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
using Microsoft.Data.Common.ConnectionString;
using Microsoft.Data.SqlClient;
-using IsolationLevel = System.Data.IsolationLevel;
using Microsoft.Identity.Client;
using Microsoft.SqlServer.Server;
-using System.Security.Authentication;
-using System.Collections.Generic;
+using IsolationLevel = System.Data.IsolationLevel;
#if NETFRAMEWORK
using System.Reflection;
-using System.Runtime.ConstrainedExecution;
-using System.Runtime.InteropServices;
+using System.Security.Permissions;
+#endif
+
+#if _WINDOWS
using System.Runtime.Versioning;
-using Interop.Windows.Kernel32;
+using Microsoft.Win32;
#endif
namespace Microsoft.Data.Common
@@ -45,6 +45,7 @@ namespace Microsoft.Data.Common
/// This class is used so that there will be compile time checking of error messages.
/// The resource Framework.txt will ensure proper string text based on the appropriate locale.
///
+ // @TODO: This file needs to be broken up
internal static partial class ADP
{
// NOTE: Initializing a Task in SQL CLR requires the "UNSAFE" permission set (http://msdn.microsoft.com/en-us/library/ms172338.aspx)
@@ -76,6 +77,7 @@ internal static partial class ADP
///
internal static InvalidUdtException CreateInvalidUdtException(Type udtType, string resourceReasonName)
{
+ // @TODO: Can we adopt the netcore version?
InvalidUdtException e =
#if NETFRAMEWORK
(InvalidUdtException)s_method.Invoke(null, new object[] { udtType, resourceReasonName });
@@ -427,6 +429,46 @@ internal static ArgumentOutOfRangeException InvalidCommandBehavior(CommandBehavi
return InvalidEnumerationValue(typeof(CommandBehavior), (int)value);
}
+
+ #if _UNIX
+ internal static object LocalMachineRegistryValue(string subkey, string queryvalue)
+ {
+ // No registry in non-Windows environments
+ return null;
+ }
+ #endif
+ #if _WINDOWS
+ [ResourceExposure(ResourceScope.Machine)]
+ [ResourceConsumption(ResourceScope.Machine)]
+ internal static object LocalMachineRegistryValue(string subkey, string queryvalue)
+ {
+ #if NETFRAMEWORK
+ new RegistryPermission(RegistryPermissionAccess.Read, $@"HKEY_LOCAL_MACHINE\{subkey}").Assert();
+ #endif
+
+ try
+ {
+ using (RegistryKey key = Registry.LocalMachine.OpenSubKey(subkey, false))
+ {
+ return key?.GetValue(queryvalue);
+ }
+ }
+ catch (SecurityException e)
+ {
+ // Even though we assert permission - it's possible there are
+ // ACL's on registry that cause SecurityException to be thrown.
+ ADP.TraceExceptionWithoutRethrow(e);
+ return null;
+ }
+ #if NETFRAMEWORK
+ finally
+ {
+ CodeAccessPermission.RevertAssert();
+ }
+ #endif
+ }
+ #endif
+
internal static void ValidateCommandBehavior(CommandBehavior value)
{
if (((int)value < 0) || (0x3F < (int)value))
@@ -944,6 +986,27 @@ private static string ConnectionStateMsg(ConnectionState state)
};
}
+ internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value)
+ {
+ // @TODO: Use single line debug assert?
+ #if DEBUG
+ switch (value)
+ {
+ case IsolationLevel.Unspecified:
+ case IsolationLevel.Chaos:
+ case IsolationLevel.ReadUncommitted:
+ case IsolationLevel.ReadCommitted:
+ case IsolationLevel.RepeatableRead:
+ case IsolationLevel.Serializable:
+ case IsolationLevel.Snapshot:
+ Debug.Fail("valid IsolationLevel " + value.ToString());
+ break;
+ }
+ #endif
+
+ return InvalidEnumerationValue(typeof(IsolationLevel), (int)value);
+ }
+
internal static InvalidOperationException NoConnectionString()
=> InvalidOperation(StringsHelper.GetString(Strings.ADP_NoConnectionString));
@@ -1278,6 +1341,24 @@ internal static ArgumentException UnknownDataTypeCode(Type dataType, TypeCode ty
internal static ArgumentException InvalidOffsetValue(int value)
=> Argument(StringsHelper.GetString(Strings.ADP_InvalidOffsetValue, value.ToString(CultureInfo.InvariantCulture)));
+ internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value)
+ {
+ // @TODO: Use single line debug assert?
+ #if DEBUG
+ switch (value)
+ {
+ case ParameterDirection.Input:
+ case ParameterDirection.Output:
+ case ParameterDirection.InputOutput:
+ case ParameterDirection.ReturnValue:
+ Debug.Fail("valid ParameterDirection " + value.ToString());
+ break;
+ }
+ #endif
+
+ return InvalidEnumerationValue(typeof(ParameterDirection), (int)value);
+ }
+
internal static ArgumentException InvalidSizeValue(int value)
=> Argument(StringsHelper.GetString(Strings.ADP_InvalidSizeValue, value.ToString(CultureInfo.InvariantCulture)));
@@ -1378,167 +1459,5 @@ internal static Exception InvalidMixedUsageOfAccessTokenCallbackAndIntegratedSec
#endregion
internal static readonly IntPtr s_ptrZero = IntPtr.Zero;
-#if NETFRAMEWORK
-#region netfx project only
- //
- // Helper Functions
- //
- internal static void CheckArgumentLength(string value, string parameterName)
- {
- CheckArgumentNull(value, parameterName);
- if (0 == value.Length)
- {
- throw Argument(StringsHelper.GetString(Strings.ADP_EmptyString, parameterName)); // MDAC 94859
- }
- }
-
- // IDbConnection.BeginTransaction, OleDbTransaction.Begin
- internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value)
- {
-#if DEBUG
- switch (value)
- {
- case IsolationLevel.Unspecified:
- case IsolationLevel.Chaos:
- case IsolationLevel.ReadUncommitted:
- case IsolationLevel.ReadCommitted:
- case IsolationLevel.RepeatableRead:
- case IsolationLevel.Serializable:
- case IsolationLevel.Snapshot:
- Debug.Assert(false, "valid IsolationLevel " + value.ToString());
- break;
- }
-#endif
- return InvalidEnumerationValue(typeof(IsolationLevel), (int)value);
- }
-
- // DBDataPermissionAttribute.KeyRestrictionBehavior
- internal static ArgumentOutOfRangeException InvalidKeyRestrictionBehavior(KeyRestrictionBehavior value)
- {
-#if DEBUG
- switch (value)
- {
- case KeyRestrictionBehavior.PreventUsage:
- case KeyRestrictionBehavior.AllowOnly:
- Debug.Assert(false, "valid KeyRestrictionBehavior " + value.ToString());
- break;
- }
-#endif
- return InvalidEnumerationValue(typeof(KeyRestrictionBehavior), (int)value);
- }
-
- // IDataParameter.Direction
- internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value)
- {
-#if DEBUG
- switch (value)
- {
- case ParameterDirection.Input:
- case ParameterDirection.Output:
- case ParameterDirection.InputOutput:
- case ParameterDirection.ReturnValue:
- Debug.Assert(false, "valid ParameterDirection " + value.ToString());
- break;
- }
-#endif
- return InvalidEnumerationValue(typeof(ParameterDirection), (int)value);
- }
-
- //
- // DbConnectionOptions, DataAccess
- //
- internal static ArgumentException InvalidKeyname(string parameterName)
- {
- return Argument(StringsHelper.GetString(Strings.ADP_InvalidKey), parameterName);
- }
- internal static ArgumentException InvalidValue(string parameterName)
- {
- return Argument(StringsHelper.GetString(Strings.ADP_InvalidValue), parameterName);
- }
- internal static Exception InvalidMixedUsageOfAccessTokenAndCredential()
- {
- return ADP.InvalidOperation(StringsHelper.GetString(Strings.ADP_InvalidMixedUsageOfAccessTokenAndCredential));
- }
-
- //
- // DBDataPermission, DataAccess, Odbc
- //
- internal static Exception InvalidXMLBadVersion()
- {
- return Argument(StringsHelper.GetString(Strings.ADP_InvalidXMLBadVersion));
- }
- internal static Exception NotAPermissionElement()
- {
- return Argument(StringsHelper.GetString(Strings.ADP_NotAPermissionElement));
- }
- internal static Exception PermissionTypeMismatch()
- {
- return Argument(StringsHelper.GetString(Strings.ADP_PermissionTypeMismatch));
- }
-
- //
- // DbDataAdapter
- //
- internal static InvalidOperationException ComputerNameEx(int lastError)
- {
- return InvalidOperation(StringsHelper.GetString(Strings.ADP_ComputerNameEx, lastError));
- }
-
- //
- // SNI
- //
- internal static PlatformNotSupportedException SNIPlatformNotSupported(string platform) => new(StringsHelper.GetString(Strings.SNI_PlatformNotSupportedNetFx, platform));
-
- // global constant strings
- internal const float FailoverTimeoutStepForTnir = 0.125F; // Fraction of timeout to use in case of Transparent Network IP resolution.
- internal const int MinimumTimeoutForTnirMs = 500; // The first login attempt in Transparent network IP Resolution
-
- internal static readonly bool s_isWindowsNT = (PlatformID.Win32NT == Environment.OSVersion.Platform);
-
-#endregion
-#else
-#region netcore project only
-
- // IDbConnection.BeginTransaction, OleDbTransaction.Begin
- internal static ArgumentOutOfRangeException InvalidIsolationLevel(IsolationLevel value)
- {
-#if DEBUG
- switch (value)
- {
- case IsolationLevel.Unspecified:
- case IsolationLevel.Chaos:
- case IsolationLevel.ReadUncommitted:
- case IsolationLevel.ReadCommitted:
- case IsolationLevel.RepeatableRead:
- case IsolationLevel.Serializable:
- case IsolationLevel.Snapshot:
- Debug.Fail("valid IsolationLevel " + value.ToString());
- break;
- }
-#endif
- return InvalidEnumerationValue(typeof(IsolationLevel), (int)value);
- }
-
- // ConnectionUtil
- internal static Exception IncorrectPhysicalConnectionType() => new ArgumentException(StringsHelper.GetString(StringsHelper.SNI_IncorrectPhysicalConnectionType));
-
- // IDataParameter.Direction
- internal static ArgumentOutOfRangeException InvalidParameterDirection(ParameterDirection value)
- {
-#if DEBUG
- switch (value)
- {
- case ParameterDirection.Input:
- case ParameterDirection.Output:
- case ParameterDirection.InputOutput:
- case ParameterDirection.ReturnValue:
- Debug.Fail("valid ParameterDirection " + value.ToString());
- break;
- }
-#endif
- return InvalidEnumerationValue(typeof(ParameterDirection), (int)value);
- }
-#endregion
-#endif
}
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.netcore.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.netcore.cs
new file mode 100644
index 0000000000..a91bd0f507
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.netcore.cs
@@ -0,0 +1,22 @@
+// 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.
+
+#if NET
+
+using System;
+using System.Data;
+using System.Diagnostics;
+using IsolationLevel = System.Data.IsolationLevel;
+
+namespace Microsoft.Data.Common
+{
+ internal static partial class ADP
+ {
+ // ConnectionUtil
+ internal static Exception IncorrectPhysicalConnectionType() =>
+ new ArgumentException(StringsHelper.GetString(Strings.SNI_IncorrectPhysicalConnectionType));
+ }
+}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.netfx.cs
new file mode 100644
index 0000000000..c7427a6a8d
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/AdapterUtil.netfx.cs
@@ -0,0 +1,110 @@
+// 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.
+
+#if NETFRAMEWORK
+
+using System;
+using System.Data;
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
+using System.Security.Permissions;
+using System.Text;
+using System.Threading.Tasks;
+using Interop.Windows.Kernel32;
+
+namespace Microsoft.Data.Common
+{
+ internal static partial class ADP
+ {
+ #region Constants
+
+ ///
+ /// Fraction of timeout to use in case of Transparent Network IP resolution.
+ ///
+ internal const float FailoverTimeoutStepForTnir = 0.125F;
+
+ ///
+ /// The first login attempt in Transparent network IP Resolution.
+ ///
+ internal const int MinimumTimeoutForTnirMs = 500;
+
+ // @TODO: Use naming rules
+ // @TODO: All values but Unix and Windows32NT are used today, for netfx this should always be Win32NT. We can likely hard code this to true for netfx.
+ internal static readonly bool s_isWindowsNT = Environment.OSVersion.Platform == PlatformID.Win32NT;
+
+ #endregion
+
+ #region Utility Methods
+
+ internal static void CheckArgumentLength(string value, string parameterName)
+ {
+ CheckArgumentNull(value, parameterName);
+ if (value.Length == 0)
+ {
+ throw Argument(StringsHelper.GetString(Strings.ADP_EmptyString, parameterName));
+ }
+ }
+
+ #endregion
+
+ #region Exception Throwing Methods (sorted by users)
+
+ #region DbConnectionOptions, DataAccess
+
+ internal static ArgumentException InvalidKeyname(string parameterName) =>
+ Argument(StringsHelper.GetString(Strings.ADP_InvalidKey), parameterName);
+
+ internal static Exception InvalidMixedUsageOfAccessTokenAndCredential() =>
+ InvalidOperation(StringsHelper.GetString(Strings.ADP_InvalidMixedUsageOfAccessTokenAndCredential));
+
+ internal static ArgumentException InvalidValue(string parameterName) =>
+ Argument(StringsHelper.GetString(Strings.ADP_InvalidValue), parameterName);
+
+ #endregion
+
+ // DbDataAdapter
+ internal static InvalidOperationException ComputerNameEx(int lastError) =>
+ InvalidOperation(StringsHelper.GetString(Strings.ADP_ComputerNameEx, lastError));
+
+ // DBDataPermissionAttribute.KeyRestrictionBehavior
+ internal static ArgumentOutOfRangeException InvalidKeyRestrictionBehavior(KeyRestrictionBehavior value)
+ {
+ // @TODO: Use a one line debug assert?
+ #if DEBUG
+ switch (value)
+ {
+ case KeyRestrictionBehavior.PreventUsage:
+ case KeyRestrictionBehavior.AllowOnly:
+ Debug.Assert(false, "valid KeyRestrictionBehavior " + value.ToString());
+ break;
+ }
+ #endif
+
+ return InvalidEnumerationValue(typeof(KeyRestrictionBehavior), (int)value);
+ }
+
+ #region DbDataPermission, DataAccess
+
+ internal static Exception InvalidXMLBadVersion() =>
+ Argument(StringsHelper.GetString(Strings.ADP_InvalidXMLBadVersion));
+
+ internal static Exception NotAPermissionElement() =>
+ Argument(StringsHelper.GetString(Strings.ADP_NotAPermissionElement));
+
+ internal static Exception PermissionTypeMismatch() =>
+ Argument(StringsHelper.GetString(Strings.ADP_PermissionTypeMismatch));
+
+ #endregion
+
+ // SNI
+ internal static PlatformNotSupportedException SNIPlatformNotSupported(string platform) =>
+ new(StringsHelper.GetString(Strings.SNI_PlatformNotSupportedNetFx, platform));
+
+ #endregion
+ }
+}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.Windows.cs
deleted file mode 100644
index f92e9beb32..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.Windows.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// 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 System.Data;
-using System.Data.Common;
-using Microsoft.Data.SqlClient.Server;
-
-namespace Microsoft.Data.Sql
-{
- ///
- public sealed partial class SqlDataSourceEnumerator : DbDataSourceEnumerator
- {
- private partial DataTable GetDataSourcesInternal()
- {
-#if NETFRAMEWORK
- return SqlDataSourceEnumeratorNativeHelper.GetDataSources();
-#else
- return SqlClient.LocalAppContextSwitches.UseManagedNetworking ? SqlDataSourceEnumeratorManagedHelper.GetDataSources() : SqlDataSourceEnumeratorNativeHelper.GetDataSources();
-#endif
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.cs
index 496c887294..0356d7bcd3 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.cs
@@ -4,22 +4,39 @@
using System;
using System.Data;
using System.Data.Common;
+using Microsoft.Data.SqlClient.Server;
namespace Microsoft.Data.Sql
{
///
public sealed partial class SqlDataSourceEnumerator : DbDataSourceEnumerator
{
- private static readonly Lazy s_singletonInstance = new(() => new SqlDataSourceEnumerator());
+ private static readonly Lazy s_singletonInstance =
+ new(() => new SqlDataSourceEnumerator());
- private SqlDataSourceEnumerator() : base(){}
+ private SqlDataSourceEnumerator() : base()
+ {
+ }
///
public static SqlDataSourceEnumerator Instance => s_singletonInstance.Value;
///
- override public DataTable GetDataSources() => GetDataSourcesInternal();
+ public override DataTable GetDataSources()
+ {
+ #if NETFRAMEWORK
+ return SqlDataSourceEnumeratorNativeHelper.GetDataSources();
+ #else
- private partial DataTable GetDataSourcesInternal();
+ #if _UNIX
+ return SqlDataSourceEnumeratorManagedHelper.GetDataSources();
+ #else
+ return SqlClient.LocalAppContextSwitches.UseManagedNetworking
+ ? SqlDataSourceEnumeratorManagedHelper.GetDataSources()
+ : SqlDataSourceEnumeratorNativeHelper.GetDataSources();
+ #endif
+
+ #endif
+ }
}
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.netcore.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.netcore.Unix.cs
deleted file mode 100644
index 196e38b579..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumerator.netcore.Unix.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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.
-
-#if NET
-
-using System.Data;
-using System.Data.Common;
-using Microsoft.Data.SqlClient.Server;
-
-namespace Microsoft.Data.Sql
-{
- ///
- public sealed partial class SqlDataSourceEnumerator : DbDataSourceEnumerator
- {
- private partial DataTable GetDataSourcesInternal() => SqlDataSourceEnumeratorManagedHelper.GetDataSources();
- }
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.windows.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.windows.cs
index d777710eee..3dfe29704b 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/Sql/SqlDataSourceEnumeratorNativeHelper.windows.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.Data;
using System.Diagnostics;
@@ -172,3 +174,5 @@ private static DataTable ParseServerEnumString(string serverInstances)
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Unix.cs
deleted file mode 100644
index 3eadc8761a..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Unix.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// 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.
-
-namespace Microsoft.Data.SqlClient.ConnectionPool
-{
- partial class DbConnectionPoolIdentity
- {
- internal static DbConnectionPoolIdentity GetCurrent()
- {
- return GetCurrentManaged();
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Windows.cs
deleted file mode 100644
index 0c6fd07503..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.Windows.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// 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 System;
-using System.Runtime.Versioning;
-using System.Security.Permissions;
-using System.Security.Principal;
-using Microsoft.Data.SqlClient;
-
-namespace Microsoft.Data.SqlClient.ConnectionPool
-{
- partial class DbConnectionPoolIdentity
- {
-#if NETFRAMEWORK
- [ResourceExposure(ResourceScope.None)] // SxS: this method does not create named objects
- [ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
- internal static DbConnectionPoolIdentity GetCurrent()
- {
- return GetCurrentNative();
- }
-
- [SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.ControlPrincipal)]
- internal static WindowsIdentity GetCurrentWindowsIdentity()
- {
- return WindowsIdentity.GetCurrent();
- }
-#else
- internal static DbConnectionPoolIdentity GetCurrent()
- {
- return LocalAppContextSwitches.UseManagedNetworking ? GetCurrentManaged() : GetCurrentNative();
- }
-#endif
-
- private static DbConnectionPoolIdentity GetCurrentNative()
- {
- DbConnectionPoolIdentity current;
- using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
- {
- IntPtr token = identity.AccessToken.DangerousGetHandle();
- SecurityIdentifier user = identity.User;
- bool isNetwork = user.IsWellKnown(WellKnownSidType.NetworkSid);
- string sidString = user.Value;
-
- // Win32NativeMethods.IsTokenRestricted will raise exception if the native call fails
- SniNativeWrapper.SniIsTokenRestricted(token, out bool isRestricted);
-
- var lastIdentity = s_lastIdentity;
- if (lastIdentity != null &&
- lastIdentity._sidString == sidString &&
- lastIdentity._isRestricted == isRestricted &&
- lastIdentity._isNetwork == isNetwork)
- {
- current = lastIdentity;
- }
- else
- {
- current = new DbConnectionPoolIdentity(sidString, isRestricted, isNetwork);
- }
- }
- s_lastIdentity = current;
- return current;
- }
- }
-}
-
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.cs
index 5716146a6b..7eca7bd0f6 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ConnectionPool/DbConnectionPoolIdentity.cs
@@ -2,11 +2,23 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System;
+
+#if NETFRAMEWORK
+using System.Runtime.Versioning;
+#endif
+
+#if _WINDOWS
+using System.Security.Principal;
+#endif
+
namespace Microsoft.Data.SqlClient.ConnectionPool
{
- sealed internal partial class DbConnectionPoolIdentity
+ internal sealed partial class DbConnectionPoolIdentity
{
- public static readonly DbConnectionPoolIdentity NoIdentity = new DbConnectionPoolIdentity(string.Empty, false, true);
+ public static readonly DbConnectionPoolIdentity NoIdentity =
+ new DbConnectionPoolIdentity(sidString: string.Empty, isRestricted: false, isNetwork: true);
+
private static DbConnectionPoolIdentity s_lastIdentity = null;
private readonly string _sidString;
@@ -22,49 +34,108 @@ private DbConnectionPoolIdentity(string sidString, bool isRestricted, bool isNet
_hashCode = sidString == null ? 0 : sidString.GetHashCode();
}
+ // @TODO: Make auto-property
internal bool IsRestricted
{
get { return _isRestricted; }
}
-
- override public bool Equals(object value)
+ public override bool Equals(object value)
{
- bool result = ((this == NoIdentity) || (this == value));
+ bool result = this == NoIdentity || this == value;
if (!result && value != null)
{
- DbConnectionPoolIdentity that = ((DbConnectionPoolIdentity)value);
- result = ((_sidString == that._sidString) && (_isRestricted == that._isRestricted) && (_isNetwork == that._isNetwork));
+ DbConnectionPoolIdentity that = (DbConnectionPoolIdentity)value;
+ result = _sidString == that._sidString &&
+ _isRestricted == that._isRestricted &&
+ _isNetwork == that._isNetwork;
}
+
return result;
}
- override public int GetHashCode()
+ public override int GetHashCode()
{
return _hashCode;
}
+ #if NETFRAMEWORK
+ [ResourceConsumption(ResourceScope.Process, ResourceScope.Process)]
+ [ResourceExposure(ResourceScope.None)] // SxS: this method does not create named objects
+ #endif
+ internal static DbConnectionPoolIdentity GetCurrent()
+ {
+ #if NETFRAMEWORK
+ return GetCurrentNative();
+ #else
+
+ #if _UNIX
+ return GetCurrentManaged();
+ #else
+ return LocalAppContextSwitches.UseManagedNetworking
+ ? GetCurrentManaged()
+ : GetCurrentNative();
+ #endif
+
+ #endif
+ }
+
+ #if NETFRAMEWORK
+ internal static WindowsIdentity GetCurrentWindowsIdentity() =>
+ WindowsIdentity.GetCurrent();
+ #endif
+
private static DbConnectionPoolIdentity GetCurrentManaged()
{
- DbConnectionPoolIdentity current;
- string domainString = System.Environment.UserDomainName;
- string sidString = (!string.IsNullOrWhiteSpace(domainString) ? domainString + "\\" : "") + System.Environment.UserName;
- bool isNetwork = false;
- bool isRestricted = false;
+ string domainString = Environment.UserDomainName;
+ string sidString = string.IsNullOrWhiteSpace(domainString)
+ ? Environment.UserName
+ : $@"{domainString}\{Environment.UserName}";
var lastIdentity = s_lastIdentity;
+
+ DbConnectionPoolIdentity current = lastIdentity != null &&
+ lastIdentity._sidString == sidString &&
+ !lastIdentity._isRestricted &&
+ !lastIdentity._isNetwork
+ ? lastIdentity
+ : new DbConnectionPoolIdentity(sidString, isRestricted: false, isNetwork: false);
- if ((lastIdentity != null) && (lastIdentity._sidString == sidString) && (lastIdentity._isRestricted == isRestricted) && (lastIdentity._isNetwork == isNetwork))
- {
- current = lastIdentity;
- }
- else
+ s_lastIdentity = current;
+ return current;
+ }
+
+ #if _WINDOWS
+ private static DbConnectionPoolIdentity GetCurrentNative()
+ {
+ DbConnectionPoolIdentity current;
+ using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
{
- current = new DbConnectionPoolIdentity(sidString, isRestricted, isNetwork);
+ IntPtr token = identity.AccessToken.DangerousGetHandle();
+ SecurityIdentifier user = identity.User;
+ bool isNetwork = user.IsWellKnown(WellKnownSidType.NetworkSid);
+ string sidString = user.Value;
+
+ // Win32NativeMethods.IsTokenRestricted will raise exception if the native call fails
+ SniNativeWrapper.SniIsTokenRestricted(token, out bool isRestricted);
+
+ var lastIdentity = s_lastIdentity;
+ if (lastIdentity != null &&
+ lastIdentity._sidString == sidString &&
+ lastIdentity._isRestricted == isRestricted &&
+ lastIdentity._isNetwork == isNetwork)
+ {
+ current = lastIdentity;
+ }
+ else
+ {
+ current = new DbConnectionPoolIdentity(sidString, isRestricted, isNetwork);
+ }
}
s_lastIdentity = current;
return current;
}
+ #endif
}
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
index f2ca2db2cc..a12587411c 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalAppContextSwitches.cs
@@ -8,6 +8,7 @@ namespace Microsoft.Data.SqlClient
{
internal static partial class LocalAppContextSwitches
{
+ // @TODO: Replace with `bool?` since that's exactly how this is being used
private enum Tristate : byte
{
NotInitialized = 0,
@@ -26,13 +27,17 @@ private enum Tristate : byte
private const string TruncateScaledDecimalString = @"Switch.Microsoft.Data.SqlClient.TruncateScaledDecimal";
private const string IgnoreServerProvidedFailoverPartnerString = @"Switch.Microsoft.Data.SqlClient.IgnoreServerProvidedFailoverPartner";
private const string EnableUserAgentString = @"Switch.Microsoft.Data.SqlClient.EnableUserAgent";
-#if NET
+
+ #if NET
private const string GlobalizationInvariantModeString = @"System.Globalization.Invariant";
private const string GlobalizationInvariantModeEnvironmentVariable = "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT";
+
+ #if _WINDOWS
private const string UseManagedNetworkingOnWindowsString = "Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows";
-#else
+ #endif
+ #else
private const string DisableTnirByDefaultString = @"Switch.Microsoft.Data.SqlClient.DisableTNIRByDefaultInConnectionString";
-#endif
+ #endif
// this field is accessed through reflection in tests and should not be renamed or have the type changed without refactoring NullRow related tests
private static Tristate s_legacyRowVersionNullBehavior;
@@ -47,28 +52,36 @@ private enum Tristate : byte
private static Tristate s_truncateScaledDecimal;
private static Tristate s_ignoreServerProvidedFailoverPartner;
private static Tristate s_enableUserAgent;
-#if NET
+
+ #if NET
private static Tristate s_globalizationInvariantMode;
+
+ #if _WINDOWS
private static Tristate s_useManagedNetworking;
-#else
+ #endif
+ #else
private static Tristate s_disableTnirByDefault;
-#endif
+ #endif
-#if NET
+ #if NET
static LocalAppContextSwitches()
{
IAppContextSwitchOverridesSection appContextSwitch = AppConfigManager.FetchConfigurationSection(AppContextSwitchOverridesSection.Name);
+
try
{
SqlAppContextSwitchManager.ApplyContextSwitches(appContextSwitch);
}
catch (Exception e)
{
+ // @TODO: Adopt netcore style of trace logs
// Don't throw an exception for an invalid config file
SqlClientEventSource.Log.TryTraceEvent(": {1}", nameof(LocalAppContextSwitches), e);
}
}
-#endif
+ #endif
+
+ // @TODO: Sort by name
///
/// In TdsParser, the ProcessSni function changed significantly when the packet
@@ -351,7 +364,8 @@ public static bool EnableUserAgent
return s_enableUserAgent == Tristate.True;
}
}
-#if NET
+
+ #if NET
///
/// .NET Core 2.0 and up supports Globalization Invariant mode, which reduces the size of the required libraries for
/// applications which don't need globalization support. SqlClient requires those libraries for core functionality,
@@ -363,7 +377,7 @@ public static bool GlobalizationInvariantMode
{
if (s_globalizationInvariantMode == Tristate.NotInitialized)
{
- // Check if invariant mode is has been set by the AppContext switch directly
+ // Check if invariant mode has been set by the AppContext switch directly
if (AppContext.TryGetSwitch(GlobalizationInvariantModeString, out bool returnedValue) && returnedValue)
{
s_globalizationInvariantMode = Tristate.True;
@@ -400,7 +414,19 @@ public static bool GlobalizationInvariantMode
return s_globalizationInvariantMode == Tristate.True;
}
}
+ #else
+ ///
+ /// .NET Framework does not support Globalization Invariant mode, so this will always be false.
+ ///
+ public static bool GlobalizationInvariantMode
+ {
+ get => false;
+ }
+ #endif
+
+ #if NET
+ #if _WINDOWS
///
/// When set to true, .NET Core will use the managed SNI implementation instead of the native SNI implementation.
///
@@ -437,30 +463,34 @@ public static bool UseManagedNetworking
return s_useManagedNetworking == Tristate.True;
}
}
-#else
+ #else
///
- /// .NET Framework does not support Globalization Invariant mode, so this will always be false.
+ /// .NET Core on Unix does not support the native SNI, so this will always be true.
///
- public const bool GlobalizationInvariantMode = false;
+ public static bool UseManagedNetworking => true;
+ #endif
+ #else
///
/// .NET Framework does not support the managed SNI, so this will always be false.
///
- public const bool UseManagedNetworking = false;
+ public static bool UseManagedNetworking => false;
+ #endif
+ #if NETFRAMEWORK
///
/// Transparent Network IP Resolution (TNIR) is a revision of the existing MultiSubnetFailover feature.
/// TNIR affects the connection sequence of the driver in the case where the first resolved IP of the hostname
/// doesn't respond and there are multiple IPs associated with the hostname.
- ///
+ ///
/// TNIR interacts with MultiSubnetFailover to provide the following three connection sequences:
/// 0: One IP is attempted, followed by all IPs in parallel
/// 1: All IPs are attempted in parallel
/// 2: All IPs are attempted one after another
- ///
+ ///
/// TransparentNetworkIPResolution is enabled by default. MultiSubnetFailover is disabled by default.
/// To disable TNIR, you can enable the app context switch.
- ///
+ ///
/// This app context switch defaults to 'false'.
///
public static bool DisableTnirByDefault
@@ -481,6 +511,6 @@ public static bool DisableTnirByDefault
return s_disableTnirByDefault == Tristate.True;
}
}
-#endif
+ #endif
}
}
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.unix.cs
similarity index 97%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.Unix.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.unix.cs
index e6f7bcbd1e..b016c7dc97 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.Unix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.unix.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _UNIX
+
using System;
namespace Microsoft.Data.SqlClient.LocalDb
@@ -15,3 +17,5 @@ internal static string GetLocalDbMessage(int hrCode) =>
throw new PlatformNotSupportedException(Strings.LocalDBNotSupported); // LocalDB is not available for Unix and hence it cannot be supported.
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.windows.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.windows.cs
index e64d4fcf2f..9a922c3286 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/LocalDb/LocalDbApi.windows.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.Diagnostics;
using System.Globalization;
@@ -14,8 +16,6 @@
#if NETFRAMEWORK
using System.Collections.Generic;
using System.Configuration;
-using System.Runtime.CompilerServices;
-using System.Threading;
#endif
namespace Microsoft.Data.SqlClient.LocalDb
@@ -421,3 +421,5 @@ internal InstanceInfo(string version)
#endif
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.unix.cs
similarity index 97%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.Unix.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.unix.cs
index 8ab05865a2..64ba1da0f8 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.Unix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.unix.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NET
+#if NET && _UNIX
using System;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.windows.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.windows.cs
index 6f9452b420..b949e494d7 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/LocalDB.netcore.windows.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NET
+#if NET && _WINDOWS
using System;
using System.Runtime.InteropServices;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SslOverTdsStream.NetCoreApp.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SslOverTdsStream.NetCoreApp.cs
deleted file mode 100644
index ff3358c50a..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SslOverTdsStream.NetCoreApp.cs
+++ /dev/null
@@ -1,299 +0,0 @@
-// 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.
-
-#if NET
-
-using System;
-using System.Buffers;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Microsoft.Data.SqlClient.ManagedSni
-{
- internal sealed partial class SslOverTdsStream
- {
- public override int Read(byte[] buffer, int offset, int count) =>
- Read(buffer.AsSpan(offset, count));
-
- public override void Write(byte[] buffer, int offset, int count) =>
- Write(buffer.AsSpan(offset, count));
-
- public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) =>
- ReadAsync(new Memory(buffer, offset, count), cancellationToken).AsTask();
-
- public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) =>
- WriteAsync(new ReadOnlyMemory(buffer, offset, count), cancellationToken).AsTask();
-
- public override int Read(Span buffer)
- {
- using (TrySNIEventScope.Create(nameof(SslOverTdsStream)))
- {
- if (!_encapsulate)
- {
- return _stream.Read(buffer);
- }
- if (_packetBytes > 0)
- {
- // there are queued bytes from a previous packet available
- // work out how many of the remaining bytes we can consume
- int wantedCount = Math.Min(buffer.Length, _packetBytes);
- int readCount = _stream.Read(buffer.Slice(0, wantedCount));
- if (readCount == 0)
- {
- // 0 means the connection was closed, tell the caller
- return 0;
- }
- _packetBytes -= readCount;
- return readCount;
- }
- else
- {
- Span headerBytes = stackalloc byte[TdsEnums.HEADER_LEN];
-
- // fetch the packet header to determine how long the packet is
- int headerBytesRead = 0;
- do
- {
- int headerBytesReadIteration = _stream.Read(headerBytes.Slice(headerBytesRead, TdsEnums.HEADER_LEN - headerBytesRead));
- if (headerBytesReadIteration == 0)
- {
- // 0 means the connection was closed, tell the caller
- return 0;
- }
- headerBytesRead += headerBytesReadIteration;
- } while (headerBytesRead < TdsEnums.HEADER_LEN);
-
- // read the packet data size from the header and store it in case it is needed for a subsequent call
- _packetBytes = ((headerBytes[TdsEnums.HEADER_LEN_FIELD_OFFSET] << 8) | headerBytes[TdsEnums.HEADER_LEN_FIELD_OFFSET + 1]) - TdsEnums.HEADER_LEN;
-
- // read as much from the packet as the caller can accept
- int packetBytesRead = _stream.Read(buffer.Slice(0, Math.Min(buffer.Length, _packetBytes)));
- _packetBytes -= packetBytesRead;
- return packetBytesRead;
- }
- }
- }
-
- public override async ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default)
- {
- using (TrySNIEventScope.Create(nameof(SslOverTdsStream)))
- {
- if (!_encapsulate)
- {
- int read;
- {
- ValueTask readValueTask = _stream.ReadAsync(buffer, cancellationToken);
- if (readValueTask.IsCompletedSuccessfully)
- {
- read = readValueTask.Result;
- }
- else
- {
- read = await readValueTask.ConfigureAwait(false);
- }
- }
- return read;
- }
- if (_packetBytes > 0)
- {
- // there are queued bytes from a previous packet available
- // work out how many of the remaining bytes we can consume
- int wantedCount = Math.Min(buffer.Length, _packetBytes);
-
- int readCount;
- {
- ValueTask remainderReadValueTask = _stream.ReadAsync(buffer.Slice(0, wantedCount), cancellationToken);
- if (remainderReadValueTask.IsCompletedSuccessfully)
- {
- readCount = remainderReadValueTask.Result;
- }
- else
- {
- readCount = await remainderReadValueTask.ConfigureAwait(false);
- }
- }
- if (readCount == 0)
- {
- // 0 means the connection was closed, tell the caller
- return 0;
- }
- _packetBytes -= readCount;
- return readCount;
- }
- else
- {
- byte[] headerBytes = ArrayPool.Shared.Rent(TdsEnums.HEADER_LEN);
-
- // fetch the packet header to determine how long the packet is
- int headerBytesRead = 0;
- do
- {
- int headerBytesReadIteration;
- {
- ValueTask headerReadValueTask = _stream.ReadAsync(headerBytes.AsMemory(headerBytesRead, (TdsEnums.HEADER_LEN - headerBytesRead)), cancellationToken);
- if (headerReadValueTask.IsCompletedSuccessfully)
- {
- headerBytesReadIteration = headerReadValueTask.Result;
- }
- else
- {
- headerBytesReadIteration = await headerReadValueTask.ConfigureAwait(false);
- }
- }
- if (headerBytesReadIteration == 0)
- {
- // 0 means the connection was closed, cleanup the rented array and then tell the caller
- ArrayPool.Shared.Return(headerBytes, clearArray: true);
- return 0;
- }
- headerBytesRead += headerBytesReadIteration;
- } while (headerBytesRead < TdsEnums.HEADER_LEN);
-
- // read the packet data size from the header and store it in case it is needed for a subsequent call
- _packetBytes = ((headerBytes[TdsEnums.HEADER_LEN_FIELD_OFFSET] << 8) | headerBytes[TdsEnums.HEADER_LEN_FIELD_OFFSET + 1]) - TdsEnums.HEADER_LEN;
-
- ArrayPool.Shared.Return(headerBytes, clearArray: true);
-
- // read as much from the packet as the caller can accept
- int packetBytesRead;
- {
- ValueTask packetReadValueTask = _stream.ReadAsync(buffer.Slice(0, Math.Min(buffer.Length, _packetBytes)), cancellationToken);
- if (packetReadValueTask.IsCompletedSuccessfully)
- {
- packetBytesRead = packetReadValueTask.Result;
- }
- else
- {
- packetBytesRead = await packetReadValueTask.ConfigureAwait(false);
- }
- }
- _packetBytes -= packetBytesRead;
- return packetBytesRead;
- }
- }
- }
-
- public override void Write(ReadOnlySpan buffer)
- {
- using (TrySNIEventScope.Create(nameof(SslOverTdsStream)))
- {
- // During the SSL negotiation phase, SSL is tunnelled over TDS packet type 0x12. After
- // negotiation, the underlying socket only sees SSL frames.
- if (!_encapsulate)
- {
- _stream.Write(buffer);
- _stream.Flush();
- return;
- }
-
- ReadOnlySpan remaining = buffer;
- byte[] packetBuffer = null;
- try
- {
- while (remaining.Length > 0)
- {
- int dataLength = Math.Min(PACKET_SIZE_WITHOUT_HEADER, remaining.Length);
- int packetLength = TdsEnums.HEADER_LEN + dataLength;
-
- if (packetBuffer == null)
- {
- packetBuffer = ArrayPool.Shared.Rent(packetLength);
- }
- else if (packetBuffer.Length < packetLength)
- {
- ArrayPool.Shared.Return(packetBuffer, clearArray: true);
- packetBuffer = ArrayPool.Shared.Rent(packetLength);
- }
-
- SetupPreLoginPacketHeader(packetBuffer, dataLength, remaining.Length - dataLength);
-
- Span data = packetBuffer.AsSpan(TdsEnums.HEADER_LEN, dataLength);
- remaining.Slice(0, dataLength).CopyTo(data);
-
- _stream.Write(packetBuffer.AsSpan(0, packetLength));
- _stream.Flush();
-
- remaining = remaining.Slice(dataLength);
- }
- }
- finally
- {
- if (packetBuffer != null)
- {
- ArrayPool.Shared.Return(packetBuffer, clearArray: true);
- }
- }
- }
- }
-
- public override async ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default)
- {
- using (TrySNIEventScope.Create(nameof(SslOverTdsStream)))
- {
- if (!_encapsulate)
- {
- {
- ValueTask valueTask = _stream.WriteAsync(buffer, cancellationToken);
- if (!valueTask.IsCompletedSuccessfully)
- {
- await valueTask.ConfigureAwait(false);
- }
- }
- Task flushTask = _stream.FlushAsync();
- if (flushTask.IsCompletedSuccessfully)
- {
- await flushTask.ConfigureAwait(false);
- }
- return;
- }
-
- ReadOnlyMemory remaining = buffer;
- byte[] packetBuffer = null;
- try
- {
- while (remaining.Length > 0)
- {
- int dataLength = Math.Min(PACKET_SIZE_WITHOUT_HEADER, remaining.Length);
- int packetLength = TdsEnums.HEADER_LEN + dataLength;
-
- if (packetBuffer == null)
- {
- packetBuffer = ArrayPool.Shared.Rent(packetLength);
- }
- else if (packetBuffer.Length < packetLength)
- {
- ArrayPool.Shared.Return(packetBuffer, clearArray: true);
- packetBuffer = ArrayPool.Shared.Rent(packetLength);
- }
-
- SetupPreLoginPacketHeader(packetBuffer, dataLength, remaining.Length - dataLength);
-
- remaining.Span.Slice(0, dataLength).CopyTo(packetBuffer.AsSpan(TdsEnums.HEADER_LEN, dataLength));
-
- {
- ValueTask packetWriteValueTask = _stream.WriteAsync(new ReadOnlyMemory(packetBuffer, 0, packetLength), cancellationToken);
- if (!packetWriteValueTask.IsCompletedSuccessfully)
- {
- await packetWriteValueTask.ConfigureAwait(false);
- }
- }
-
- await _stream.FlushAsync().ConfigureAwait(false);
-
- remaining = remaining.Slice(dataLength);
- }
- }
- finally
- {
- if (packetBuffer != null)
- {
- ArrayPool.Shared.Return(packetBuffer, clearArray: true);
- }
- }
- }
- }
- }
-}
-
-#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SslOverTdsStream.netcore.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SslOverTdsStream.netcore.cs
index ae3dae0c06..1d18e9d63c 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SslOverTdsStream.netcore.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ManagedSni/SslOverTdsStream.netcore.cs
@@ -5,8 +5,11 @@
#if NET
using System;
+using System.Buffers;
using System.IO;
using System.IO.Pipes;
+using System.Threading;
+using System.Threading.Tasks;
namespace Microsoft.Data.SqlClient.ManagedSni
{
@@ -110,6 +113,301 @@ public override long Position
///
public override long Length => throw new NotSupportedException();
+ #region Public Methods
+
+ ///
+ public override int Read(byte[] buffer, int offset, int count) =>
+ Read(buffer.AsSpan(offset, count));
+
+ ///
+ public override int Read(Span buffer)
+ {
+ using (TrySNIEventScope.Create(nameof(SslOverTdsStream)))
+ {
+ if (!_encapsulate)
+ {
+ return _stream.Read(buffer);
+ }
+
+ if (_packetBytes > 0)
+ {
+ // there are queued bytes from a previous packet available
+ // work out how many of the remaining bytes we can consume
+ int wantedCount = Math.Min(buffer.Length, _packetBytes);
+ int readCount = _stream.Read(buffer.Slice(0, wantedCount));
+ if (readCount == 0)
+ {
+ // 0 means the connection was closed, tell the caller
+ return 0;
+ }
+ _packetBytes -= readCount;
+ return readCount;
+ }
+ else
+ {
+ Span headerBytes = stackalloc byte[TdsEnums.HEADER_LEN];
+
+ // fetch the packet header to determine how long the packet is
+ int headerBytesRead = 0;
+ do
+ {
+ int headerBytesReadIteration = _stream.Read(headerBytes.Slice(headerBytesRead, TdsEnums.HEADER_LEN - headerBytesRead));
+ if (headerBytesReadIteration == 0)
+ {
+ // 0 means the connection was closed, tell the caller
+ return 0;
+ }
+ headerBytesRead += headerBytesReadIteration;
+ } while (headerBytesRead < TdsEnums.HEADER_LEN);
+
+ // read the packet data size from the header and store it in case it is needed for a subsequent call
+ _packetBytes = ((headerBytes[TdsEnums.HEADER_LEN_FIELD_OFFSET] << 8) | headerBytes[TdsEnums.HEADER_LEN_FIELD_OFFSET + 1]) - TdsEnums.HEADER_LEN;
+
+ // read as much from the packet as the caller can accept
+ int packetBytesRead = _stream.Read(buffer.Slice(0, Math.Min(buffer.Length, _packetBytes)));
+ _packetBytes -= packetBytesRead;
+ return packetBytesRead;
+ }
+ }
+ }
+
+ ///
+ public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) =>
+ ReadAsync(new Memory(buffer, offset, count), cancellationToken).AsTask();
+
+ ///
+ public override async ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default)
+ {
+ using (TrySNIEventScope.Create(nameof(SslOverTdsStream)))
+ {
+ if (!_encapsulate)
+ {
+ int read;
+ {
+ ValueTask readValueTask = _stream.ReadAsync(buffer, cancellationToken);
+ if (readValueTask.IsCompletedSuccessfully)
+ {
+ read = readValueTask.Result;
+ }
+ else
+ {
+ read = await readValueTask.ConfigureAwait(false);
+ }
+ }
+ return read;
+ }
+
+ if (_packetBytes > 0)
+ {
+ // there are queued bytes from a previous packet available
+ // work out how many of the remaining bytes we can consume
+ int wantedCount = Math.Min(buffer.Length, _packetBytes);
+
+ int readCount;
+ {
+ ValueTask remainderReadValueTask = _stream.ReadAsync(buffer.Slice(0, wantedCount), cancellationToken);
+ if (remainderReadValueTask.IsCompletedSuccessfully)
+ {
+ readCount = remainderReadValueTask.Result;
+ }
+ else
+ {
+ readCount = await remainderReadValueTask.ConfigureAwait(false);
+ }
+ }
+ if (readCount == 0)
+ {
+ // 0 means the connection was closed, tell the caller
+ return 0;
+ }
+ _packetBytes -= readCount;
+ return readCount;
+ }
+ else
+ {
+ byte[] headerBytes = ArrayPool.Shared.Rent(TdsEnums.HEADER_LEN);
+
+ // fetch the packet header to determine how long the packet is
+ int headerBytesRead = 0;
+ do
+ {
+ int headerBytesReadIteration;
+ {
+ ValueTask headerReadValueTask = _stream.ReadAsync(headerBytes.AsMemory(headerBytesRead, (TdsEnums.HEADER_LEN - headerBytesRead)), cancellationToken);
+ if (headerReadValueTask.IsCompletedSuccessfully)
+ {
+ headerBytesReadIteration = headerReadValueTask.Result;
+ }
+ else
+ {
+ headerBytesReadIteration = await headerReadValueTask.ConfigureAwait(false);
+ }
+ }
+ if (headerBytesReadIteration == 0)
+ {
+ // 0 means the connection was closed, cleanup the rented array and then tell the caller
+ ArrayPool.Shared.Return(headerBytes, clearArray: true);
+ return 0;
+ }
+ headerBytesRead += headerBytesReadIteration;
+ } while (headerBytesRead < TdsEnums.HEADER_LEN);
+
+ // read the packet data size from the header and store it in case it is needed for a subsequent call
+ _packetBytes = ((headerBytes[TdsEnums.HEADER_LEN_FIELD_OFFSET] << 8) | headerBytes[TdsEnums.HEADER_LEN_FIELD_OFFSET + 1]) - TdsEnums.HEADER_LEN;
+
+ ArrayPool.Shared.Return(headerBytes, clearArray: true);
+
+ // read as much from the packet as the caller can accept
+ int packetBytesRead;
+ {
+ ValueTask packetReadValueTask = _stream.ReadAsync(buffer.Slice(0, Math.Min(buffer.Length, _packetBytes)), cancellationToken);
+ if (packetReadValueTask.IsCompletedSuccessfully)
+ {
+ packetBytesRead = packetReadValueTask.Result;
+ }
+ else
+ {
+ packetBytesRead = await packetReadValueTask.ConfigureAwait(false);
+ }
+ }
+ _packetBytes -= packetBytesRead;
+ return packetBytesRead;
+ }
+ }
+ }
+
+ ///
+ public override void Write(byte[] buffer, int offset, int count) =>
+ Write(buffer.AsSpan(offset, count));
+
+ ///
+ public override void Write(ReadOnlySpan buffer)
+ {
+ using (TrySNIEventScope.Create(nameof(SslOverTdsStream)))
+ {
+ // During the SSL negotiation phase, SSL is tunnelled over TDS packet type 0x12. After
+ // negotiation, the underlying socket only sees SSL frames.
+ if (!_encapsulate)
+ {
+ _stream.Write(buffer);
+ _stream.Flush();
+ return;
+ }
+
+ ReadOnlySpan remaining = buffer;
+ byte[] packetBuffer = null;
+ try
+ {
+ while (remaining.Length > 0)
+ {
+ int dataLength = Math.Min(PACKET_SIZE_WITHOUT_HEADER, remaining.Length);
+ int packetLength = TdsEnums.HEADER_LEN + dataLength;
+
+ if (packetBuffer == null)
+ {
+ packetBuffer = ArrayPool.Shared.Rent(packetLength);
+ }
+ else if (packetBuffer.Length < packetLength)
+ {
+ ArrayPool.Shared.Return(packetBuffer, clearArray: true);
+ packetBuffer = ArrayPool.Shared.Rent(packetLength);
+ }
+
+ SetupPreLoginPacketHeader(packetBuffer, dataLength, remaining.Length - dataLength);
+
+ Span data = packetBuffer.AsSpan(TdsEnums.HEADER_LEN, dataLength);
+ remaining.Slice(0, dataLength).CopyTo(data);
+
+ _stream.Write(packetBuffer.AsSpan(0, packetLength));
+ _stream.Flush();
+
+ remaining = remaining.Slice(dataLength);
+ }
+ }
+ finally
+ {
+ if (packetBuffer != null)
+ {
+ ArrayPool.Shared.Return(packetBuffer, clearArray: true);
+ }
+ }
+ }
+ }
+
+ ///
+ public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) =>
+ WriteAsync(new ReadOnlyMemory(buffer, offset, count), cancellationToken).AsTask();
+
+ ///
+ public override async ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default)
+ {
+ using (TrySNIEventScope.Create(nameof(SslOverTdsStream)))
+ {
+ if (!_encapsulate)
+ {
+ {
+ ValueTask valueTask = _stream.WriteAsync(buffer, cancellationToken);
+ if (!valueTask.IsCompletedSuccessfully)
+ {
+ await valueTask.ConfigureAwait(false);
+ }
+ }
+ Task flushTask = _stream.FlushAsync();
+ if (flushTask.IsCompletedSuccessfully)
+ {
+ await flushTask.ConfigureAwait(false);
+ }
+ return;
+ }
+
+ ReadOnlyMemory remaining = buffer;
+ byte[] packetBuffer = null;
+ try
+ {
+ while (remaining.Length > 0)
+ {
+ int dataLength = Math.Min(PACKET_SIZE_WITHOUT_HEADER, remaining.Length);
+ int packetLength = TdsEnums.HEADER_LEN + dataLength;
+
+ if (packetBuffer == null)
+ {
+ packetBuffer = ArrayPool.Shared.Rent(packetLength);
+ }
+ else if (packetBuffer.Length < packetLength)
+ {
+ ArrayPool.Shared.Return(packetBuffer, clearArray: true);
+ packetBuffer = ArrayPool.Shared.Rent(packetLength);
+ }
+
+ SetupPreLoginPacketHeader(packetBuffer, dataLength, remaining.Length - dataLength);
+
+ remaining.Span.Slice(0, dataLength).CopyTo(packetBuffer.AsSpan(TdsEnums.HEADER_LEN, dataLength));
+
+ {
+ ValueTask packetWriteValueTask = _stream.WriteAsync(new ReadOnlyMemory(packetBuffer, 0, packetLength), cancellationToken);
+ if (!packetWriteValueTask.IsCompletedSuccessfully)
+ {
+ await packetWriteValueTask.ConfigureAwait(false);
+ }
+ }
+
+ await _stream.FlushAsync().ConfigureAwait(false);
+
+ remaining = remaining.Slice(dataLength);
+ }
+ }
+ finally
+ {
+ if (packetBuffer != null)
+ {
+ ArrayPool.Shared.Return(packetBuffer, clearArray: true);
+ }
+ }
+ }
+ }
+
+ #endregion
+
private static void SetupPreLoginPacketHeader(byte[] buffer, int dataLength, int remainingLength)
{
// We can only send 4088 bytes in one packet. Header[1] is set to 1 if this is a
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.unix.cs
similarity index 64%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.unix.cs
index 42bf62c5f5..4060edfb38 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.Unix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.unix.cs
@@ -2,20 +2,23 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NET
+// @TODO: Introduce polymorphism to remove need for this level of indirection
+// @TODO: Also, why do we have any other type besides managed defined here?
+#if NET && _UNIX
namespace Microsoft.Data.SqlClient
{
- // This structure is used for transporting packet handle references between the
- // TdsParserStateObject base class and Managed or Native implementations.
- // It prevents the native IntPtr type from being boxed and prevents the need to cast from
- // object which loses compile time type safety.
- // It carries type information so that assertions about the type of handle can be made in the
- // implemented abstract methods.
- // It is a ref struct so that it can only be used to transport the handles and not store them
-
- // N.B. If you change this type you must also change the version for the other platform
-
+ ///
+ /// This structure is used for transporting packet handle references between the
+ /// TdsParserStateObject base class and Managed or Native implementations. It prevents the
+ /// native IntPtr type from being boxed and prevents the need to cast from object which loses
+ /// compile time type safety. It carries type information so that assertions about the type of
+ /// handle can be made in the implemented abstract methods.
+ ///
+ ///
+ /// It is a ref struct so that it can only be used to transport the handles and not store them.
+ /// If you change this type you must also change the version for the other platform.
+ ///
internal readonly ref struct PacketHandle
{
///
@@ -36,6 +39,7 @@ internal readonly ref struct PacketHandle
///
public const int ManagedPacketType = 3;
+ // @TODO: To auto-properties
public readonly ManagedSni.SniPacket ManagedPacket;
public readonly int Type;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.windows.cs
similarity index 56%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.windows.cs
index b73f063a9c..4e675fc5b0 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netcore.windows.cs
@@ -2,20 +2,24 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+// @TODO: Introduce polymorphism to remove need for this level of indirection
+#if NET && _WINDOWS
+
using System;
namespace Microsoft.Data.SqlClient
{
- // This structure is used for transporting packet handle references between the
- // TdsParserStateObject base class and Managed or Native implementations.
- // It prevents the native IntPtr type from being boxed and prevents the need to cast from
- // object which loses compile time type safety.
- // It carries type information so that assertions about the type of handle can be made in the
- // implemented abstract methods.
- // It is a ref struct so that it can only be used to transport the handles and not store them
-
- // N.B. If you change this type you must also change the version for the other platform
-
+ ///
+ /// This structure is used for transporting packet handle references between the
+ /// TdsParserStateObject base class and Managed or Native implementations. It prevents the
+ /// native IntPtr type from being boxed and prevents the need to cast from object which loses
+ /// compile time type safety. It carries type information so that assertions about the type of
+ /// handle can be made in the implemented abstract methods.
+ ///
+ ///
+ /// It is a ref struct so that it can only be used to transport the handles and not store them.
+ /// If you change this type you must also change the version for the other platform.
+ ///
internal readonly ref struct PacketHandle
{
///
@@ -24,28 +28,26 @@ internal readonly ref struct PacketHandle
/// packet which has been read from the native SNI layer.
///
public const int NativePointerType = 1;
+
///
/// PacketHandle is transporting a native packet. The NativePacket field is valid.
/// A PacketHandle has this type when managed code is directly referencing a packet
/// which is due to be passed to the native SNI layer.
///
public const int NativePacketType = 2;
-
- #if NET
+
///
/// PacketHandle is transporting a managed packet. The ManagedPacket field is valid.
/// A PacketHandle used by the managed SNI layer will always have this type.
///
public const int ManagedPacketType = 3;
+ // @TODO: To auto-properties
public readonly ManagedSni.SniPacket ManagedPacket;
- #endif
-
public readonly SNIPacket NativePacket;
public readonly IntPtr NativePointer;
public readonly int Type;
- #if NET
private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, ManagedSni.SniPacket managedPacket, int type)
{
Type = type;
@@ -53,30 +55,16 @@ private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, ManagedSni.Sn
NativePointer = nativePointer;
NativePacket = nativePacket;
}
- #else
- private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, int type)
- {
- Type = type;
- NativePointer = nativePointer;
- NativePacket = nativePacket;
- }
- #endif
- #if NET
public static PacketHandle FromManagedPacket(ManagedSni.SniPacket managedPacket) =>
- new PacketHandle(default, default, managedPacket, ManagedPacketType);
-
- public static PacketHandle FromNativePointer(IntPtr nativePointer) =>
- new PacketHandle(nativePointer, default, default, NativePointerType);
+ new PacketHandle(nativePointer: IntPtr.Zero, nativePacket: null, managedPacket, ManagedPacketType);
public static PacketHandle FromNativePacket(SNIPacket nativePacket) =>
- new PacketHandle(default, nativePacket, default, NativePacketType);
- #else
- public static PacketHandle FromNativePointer(IntPtr nativePointer) =>
- new PacketHandle(nativePointer, default, NativePointerType);
+ new PacketHandle(nativePointer: IntPtr.Zero, nativePacket, managedPacket: null, NativePacketType);
- public static PacketHandle FromNativePacket(SNIPacket nativePacket) =>
- new PacketHandle(default, nativePacket, NativePacketType);
- #endif
+ public static PacketHandle FromNativePointer(IntPtr nativePointer) =>
+ new PacketHandle(nativePointer, nativePacket: null, managedPacket: null, NativePointerType);
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netfx.cs
new file mode 100644
index 0000000000..ac636f3b86
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/PacketHandle.netfx.cs
@@ -0,0 +1,59 @@
+// 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.
+
+// @TODO: Introduce polymorphism to remove need for this level of indirection
+#if NETFRAMEWORK
+
+using System;
+
+namespace Microsoft.Data.SqlClient
+{
+ ///
+ /// This structure is used for transporting packet handle references between the
+ /// TdsParserStateObject base class and Managed or Native implementations. It prevents the
+ /// native IntPtr type from being boxed and prevents the need to cast from object which loses
+ /// compile time type safety. It carries type information so that assertions about the type of
+ /// handle can be made in the implemented abstract methods.
+ ///
+ ///
+ /// It is a ref struct so that it can only be used to transport the handles and not store them.
+ /// If you change this type you must also change the version for the other platform.
+ ///
+ internal readonly ref struct PacketHandle
+ {
+ ///
+ /// PacketHandle is transporting a native pointer. The NativePointer field is valid.
+ /// A PacketHandle has this type when managed code is referencing a pointer to a
+ /// packet which has been read from the native SNI layer.
+ ///
+ public const int NativePointerType = 1;
+
+ ///
+ /// PacketHandle is transporting a native packet. The NativePacket field is valid.
+ /// A PacketHandle has this type when managed code is directly referencing a packet
+ /// which is due to be passed to the native SNI layer.
+ ///
+ public const int NativePacketType = 2;
+
+ // @TODO: To auto-properties
+ public readonly SNIPacket NativePacket;
+ public readonly IntPtr NativePointer;
+ public readonly int Type;
+
+ private PacketHandle(IntPtr nativePointer, SNIPacket nativePacket, int type)
+ {
+ Type = type;
+ NativePointer = nativePointer;
+ NativePacket = nativePacket;
+ }
+
+ public static PacketHandle FromNativePacket(SNIPacket nativePacket) =>
+ new PacketHandle(nativePointer: IntPtr.Zero, nativePacket, NativePacketType);
+
+ public static PacketHandle FromNativePointer(IntPtr nativePointer) =>
+ new PacketHandle(nativePointer, nativePacket: null, NativePointerType);
+ }
+}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSspiContextProvider.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSspiContextProvider.windows.cs
similarity index 88%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSspiContextProvider.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSspiContextProvider.windows.cs
index 45260bcd93..b6d65d4452 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSspiContextProvider.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NativeSspiContextProvider.windows.cs
@@ -1,4 +1,10 @@
-using System;
+// 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.
+
+#if _WINDOWS
+
+using System;
using System.Buffers;
using System.Diagnostics;
@@ -14,7 +20,7 @@ internal sealed class NativeSspiContextProvider : SspiContextProvider
private static bool s_fSSPILoaded;
// variable to hold max SSPI data size, keep for token from server
- private volatile static uint s_maxSSPILength;
+ private static volatile uint s_maxSSPILength;
private protected override void Initialize()
{
@@ -53,9 +59,10 @@ private void LoadSSPILibrary()
protected override bool GenerateContext(ReadOnlySpan incomingBlob, IBufferWriter outgoingBlobWriter, SspiAuthenticationParameters authParams)
{
-#if NET
+ #if NET
Debug.Assert(_physicalStateObj.SessionHandle.Type == SessionHandle.NativeHandleType);
-#endif
+ #endif
+
SNIHandle handle = _physicalStateObj.SessionHandle.NativeHandle;
// This must start as the length of the input, but will be updated by the call to SNISecGenClientContext to the written length
@@ -79,3 +86,4 @@ protected override bool GenerateContext(ReadOnlySpan incomingBlob, IBuffer
}
}
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NegotiateSspiContextProvider.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NegotiateSspiContextProvider.cs
index b9b6cbf36e..5971d48409 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NegotiateSspiContextProvider.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/NegotiateSspiContextProvider.cs
@@ -1,3 +1,7 @@
+// 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.
+
#if NET
using System;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiAuthenticationParameters.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiAuthenticationParameters.cs
index dce0858360..b82e779463 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiAuthenticationParameters.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiAuthenticationParameters.cs
@@ -1,4 +1,8 @@
-#nullable enable
+// 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.
+
+#nullable enable
namespace Microsoft.Data.SqlClient
{
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiContextProvider.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiContextProvider.cs
index f70e2e8a12..49ceebdadd 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiContextProvider.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SSPI/SspiContextProvider.cs
@@ -1,4 +1,8 @@
-using System;
+// 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 System;
using System.Buffers;
using System.Diagnostics;
using Microsoft.Data.SqlClient.Connection;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.unix.cs
similarity index 51%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.Unix.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.unix.cs
index 8465da3684..8f82506bc5 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.Unix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.unix.cs
@@ -2,23 +2,28 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NET
+// @TODO: Merge with SessionHandle.windows (and/or introduce polymorphism to handle this indirection)
+// @TODO: Also, why do we have native handle type defined in Unix which doesn't ever have a native handle type?
+#if NET && _UNIX
namespace Microsoft.Data.SqlClient
{
- // this structure is used for transporting packet handle references between the TdsParserStateObject
- // base class and Managed or Native implementations.
- // It carries type information so that assertions about the type of handle can be made in the
- // implemented abstract methods
- // it is a ref struct so that it can only be used to transport the handles and not store them
-
- // N.B. If you change this type you must also change the version for the other platform
-
+ ///
+ /// This structure is used for transporting packet handle references between the
+ /// TdsParserStateObject base class and Managed or Native implementations. It carries type
+ /// information so that assertions about the type of handle can be made in the implemented
+ /// abstract methods.
+ ///
+ ///
+ /// It is a ref struct so that it can only be used to transport the handles and not store them.
+ /// If you change this type you must also change the version for the other platform.
+ ///
internal readonly ref struct SessionHandle
{
public const int NativeHandleType = 1;
public const int ManagedHandleType = 2;
+ // @TODO: Auto-properties
public readonly ManagedSni.SniHandle ManagedHandle;
public readonly int Type;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.windows.cs
similarity index 52%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.windows.cs
index b5b2068961..dcac01c534 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netcore.windows.cs
@@ -2,29 +2,31 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+// @TODO: Merge with other implementations (and/or introduce polymorphism to handle this indirection)
+#if NET && _WINDOWS
+
namespace Microsoft.Data.SqlClient
{
- // this structure is used for transporting packet handle references between the TdsParserStateObject
- // base class and Managed or Native implementations.
- // It carries type information so that assertions about the type of handle can be made in the
- // implemented abstract methods
- // it is a ref struct so that it can only be used to transport the handles and not store them
-
- // N.B. If you change this type you must also change the version for the other platform
-
+ ///
+ /// This structure is used for transporting packet handle references between the
+ /// TdsParserStateObject base class and Managed or Native implementations. It carries type
+ /// information so that assertions about the type of handle can be made in the implemented
+ /// abstract methods.
+ ///
+ ///
+ /// It is a ref struct so that it can only be used to transport the handles and not store them.
+ /// If you change this type you must also change the version for the other platform.
+ ///
internal readonly ref struct SessionHandle
{
-#if NET
public const int NativeHandleType = 1;
public const int ManagedHandleType = 2;
+ // @TODO: Make auto-properties
public readonly ManagedSni.SniHandle ManagedHandle;
- public readonly int Type;
-#endif
-
public readonly SNIHandle NativeHandle;
+ public readonly int Type;
-#if NET
public SessionHandle(ManagedSni.SniHandle managedHandle, SNIHandle nativeHandle, int type)
{
Type = type;
@@ -35,19 +37,11 @@ public SessionHandle(ManagedSni.SniHandle managedHandle, SNIHandle nativeHandle,
public bool IsNull => (Type == NativeHandleType) ? NativeHandle is null : ManagedHandle is null;
public static SessionHandle FromManagedSession(ManagedSni.SniHandle managedSessionHandle) =>
- new SessionHandle(managedSessionHandle, default, ManagedHandleType);
+ new SessionHandle(managedSessionHandle, nativeHandle: null, ManagedHandleType);
public static SessionHandle FromNativeHandle(SNIHandle nativeSessionHandle) =>
- new SessionHandle(default, nativeSessionHandle, NativeHandleType);
-#else
- public SessionHandle(SNIHandle nativeHandle)
- {
- NativeHandle = nativeHandle;
- }
-
- public bool IsNull => NativeHandle is null;
-
- public static SessionHandle FromNativeHandle(SNIHandle nativeSessionHandle) => new SessionHandle(nativeSessionHandle);
-#endif
+ new SessionHandle(managedHandle: null, nativeSessionHandle, NativeHandleType);
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netfx.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netfx.cs
new file mode 100644
index 0000000000..16d665aa9f
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SessionHandle.netfx.cs
@@ -0,0 +1,40 @@
+// 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.
+
+// @TODO: Merge with other implementations (and/or introduce polymorphism to handle this indirection)
+#if NETFRAMEWORK
+
+namespace Microsoft.Data.SqlClient
+{
+ ///
+ /// This structure is used for transporting packet handle references between the
+ /// TdsParserStateObject base class and Managed or Native implementations. It carries type
+ /// information so that assertions about the type of handle can be made in the implemented
+ /// abstract methods.
+ ///
+ ///
+ /// It is a ref struct so that it can only be used to transport the handles and not store them
+ /// If you change this type you must also change the version for the other platform.
+ ///
+ internal readonly ref struct SessionHandle
+ {
+ // @TODO: Make internal, auto-property
+ public readonly SNIHandle NativeHandle;
+
+ public SessionHandle(SNIHandle nativeHandle)
+ {
+ NativeHandle = nativeHandle;
+ }
+
+ public bool IsNull
+ {
+ get => NativeHandle is null;
+ }
+
+ public static SessionHandle FromNativeHandle(SNIHandle nativeSessionHandle) =>
+ new SessionHandle(nativeSessionHandle);
+ }
+}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBatchCommand.Net8OrGreater.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBatchCommand.netcore.cs
similarity index 100%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBatchCommand.Net8OrGreater.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBatchCommand.netcore.cs
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.netcore.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.netcore.unix.cs
similarity index 97%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.netcore.Unix.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.netcore.unix.cs
index 7c53b61a78..6ab8567e2a 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.netcore.Unix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.netcore.unix.cs
@@ -2,7 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NET
+// @TODO: See if we can throw this when we would create this object
+#if NET && _UNIX
using System;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.windows.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.windows.cs
index bd8b2391fa..802472f83e 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCngProvider.windows.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using Microsoft.Data.SqlClient.AlwaysEncrypted;
using System;
using System.Diagnostics.CodeAnalysis;
@@ -210,3 +212,5 @@ public override bool VerifyColumnMasterKeyMetadata(string? masterKeyPath, bool a
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.netcore.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.netcore.unix.cs
similarity index 97%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.netcore.Unix.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.netcore.unix.cs
index d28fcf9000..f96841273c 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.netcore.Unix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.netcore.unix.cs
@@ -2,7 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NET
+// @TODO: See if we can throw this when we would create this object
+#if NET && _UNIX
using System;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.windows.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.windows.cs
index ec2b7554a8..33fe10fe66 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlColumnEncryptionCspProvider.windows.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using Microsoft.Data.SqlClient.AlwaysEncrypted;
using Microsoft.Win32;
using System;
@@ -16,7 +18,6 @@ namespace Microsoft.Data.SqlClient
///
public class SqlColumnEncryptionCspProvider : SqlColumnEncryptionKeyStoreProvider
{
-
///
public const string ProviderName = @"MSSQL_CSP_PROVIDER";
@@ -213,3 +214,5 @@ public override bool VerifyColumnMasterKeyMetadata(string? masterKeyPath, bool a
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSafeHandles.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSafeHandles.windows.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSafeHandles.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSafeHandles.windows.cs
index 749fe5a008..4baf3e1b69 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSafeHandles.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserSafeHandles.windows.cs
@@ -2,8 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
-using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Interop.Windows.Sni;
@@ -278,3 +279,5 @@ override protected bool ReleaseHandle()
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.unix.cs
similarity index 97%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Unix.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.unix.cs
index 1f1e45d35f..61817eb0ed 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Unix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.unix.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if NET && _UNIX
+
using Microsoft.Data.SqlClient.ManagedSni;
namespace Microsoft.Data.SqlClient
@@ -30,3 +32,5 @@ internal TdsParserStateObject CreateSessionObject(TdsParser tdsParser, TdsParser
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.windows.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.windows.cs
index 2c8335d91f..eed5187596 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectFactory.windows.cs
@@ -2,8 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
#if NET
-using System;
using Microsoft.Data.SqlClient.ManagedSni;
#endif
@@ -70,3 +71,5 @@ internal TdsParserStateObject CreateSessionObject(TdsParser tdsParser, TdsParser
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectManaged.netcore.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectManaged.netcore.cs
index 0ebc36c06a..cf9924cc24 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectManaged.netcore.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectManaged.netcore.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable enable
+#if NET
using System;
using System.Diagnostics;
@@ -14,6 +14,8 @@
using Microsoft.Data.Common;
using Microsoft.Data.ProviderBase;
+#nullable enable
+
// @TODO: If this is in the manages SNI namespace, it should be in the managed SNI folder
namespace Microsoft.Data.SqlClient.ManagedSni
{
@@ -424,3 +426,5 @@ internal override SspiContextProvider CreateSspiContextProvider()
=> new NegotiateSspiContextProvider();
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.windows.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.windows.cs
index 4efd94e112..1269cf8827 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.windows.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -209,12 +211,10 @@ protected override void RemovePacketFromPendingList(PacketHandle ptr)
_pendingWritePackets.Remove(pointer);
_writePacketCache.Add(recoveredPacket);
}
-#if DEBUG
else
{
Debug.Fail("Removing a packet from the pending list that was never added to it");
}
-#endif
}
}
@@ -281,9 +281,10 @@ internal override uint CheckConnection()
internal override PacketHandle ReadAsync(SessionHandle handle, out uint error)
{
-#if NET
+ #if NET
Debug.Assert(handle.Type == SessionHandle.NativeHandleType, "unexpected handle type when requiring NativePointer");
-#endif
+ #endif
+
IntPtr readPacketPtr = IntPtr.Zero;
error = SniNativeWrapper.SniReadAsync(handle.NativeHandle, ref readPacketPtr);
return PacketHandle.FromNativePointer(readPacketPtr);
@@ -505,3 +506,5 @@ public void Dispose()
}
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.netcore.Unix.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.netcore.unix.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.netcore.Unix.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.netcore.unix.cs
index 9aac2d9d5e..3ba7e55237 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.netcore.Unix.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.netcore.unix.cs
@@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if NET
+#if NET && _UNIX
using System;
using System.IO;
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.windows.cs
similarity index 99%
rename from src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs
rename to src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.windows.cs
index c96635e6c7..9338cf03b1 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.Windows.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlTypes/SqlFileStream.windows.cs
@@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if _WINDOWS
+
using System;
using System.ComponentModel;
using System.Diagnostics;
@@ -102,6 +104,7 @@ public SqlFileStream(
FileOptions options,
long allocationSize)
{
+ // @TODO: Adopt netcore style format
#if NETFRAMEWORK
const string scopeFormat = " {0} access={1} options={2} path='{3}'";
#else
@@ -960,3 +963,5 @@ private void ThrowIfDisposed()
#endregion
}
}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/src/Resources/ILLink.Substitutions.Unix.xml b/src/Microsoft.Data.SqlClient/src/Resources/ILLink.Substitutions.Unix.xml
deleted file mode 100644
index 4e105d25f0..0000000000
--- a/src/Microsoft.Data.SqlClient/src/Resources/ILLink.Substitutions.Unix.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/src/Microsoft.Data.SqlClient/src/Resources/ILLink.Substitutions.Windows.xml b/src/Microsoft.Data.SqlClient/src/Resources/ILLink.Substitutions.xml
similarity index 100%
rename from src/Microsoft.Data.SqlClient/src/Resources/ILLink.Substitutions.Windows.xml
rename to src/Microsoft.Data.SqlClient/src/Resources/ILLink.Substitutions.xml
diff --git a/src/Microsoft.Data.SqlClient/src/System/Diagnostics/CodeAnalysis.cs b/src/Microsoft.Data.SqlClient/src/System/Diagnostics/CodeAnalysis.cs
deleted file mode 100644
index ffb0003f64..0000000000
--- a/src/Microsoft.Data.SqlClient/src/System/Diagnostics/CodeAnalysis.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// 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.
-
-namespace System.Diagnostics.CodeAnalysis
-{
-
-#if NETFRAMEWORK
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
- internal sealed class MemberNotNullAttribute : Attribute
- {
- public MemberNotNullAttribute(string member) => Members = new string[]
- {
- member
- };
-
- public MemberNotNullAttribute(params string[] members) => Members = members;
-
- public string[] Members { get; }
- }
-
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true, Inherited = false)]
- internal sealed class MemberNotNullWhenAttribute : Attribute
- {
- public MemberNotNullWhenAttribute(bool returnValue, string member)
- {
- ReturnValue = returnValue;
- Members = new string[1] { member };
- }
-
- public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
- {
- ReturnValue = returnValue;
- Members = members;
- }
-
- public bool ReturnValue { get; }
-
- public string[] Members { get; }
- }
-
- [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
- internal sealed class NotNullAttribute : Attribute
- {
- }
-#endif
-}
diff --git a/src/Microsoft.Data.SqlClient/src/System/Diagnostics/CodeAnalysis.netfx.cs b/src/Microsoft.Data.SqlClient/src/System/Diagnostics/CodeAnalysis.netfx.cs
new file mode 100644
index 0000000000..1bf90ad001
--- /dev/null
+++ b/src/Microsoft.Data.SqlClient/src/System/Diagnostics/CodeAnalysis.netfx.cs
@@ -0,0 +1,20 @@
+// 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.
+
+#if NETFRAMEWORK
+
+namespace System.Diagnostics.CodeAnalysis
+{
+ // These classes are provided to provide compile-time support for Microsoft.CodeAnalysis
+ // attributes. These attributes are native to netcore and available for netfx as a nuget
+ // package - but only for net472. As such, until net462 support is dropped, these placeholder
+ // classes will need to exist if we want to use them for static analysis.
+
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
+ internal sealed class NotNullAttribute : Attribute
+ {
+ }
+}
+
+#endif
diff --git a/src/Microsoft.Data.SqlClient/tests/Common/Common.csproj b/src/Microsoft.Data.SqlClient/tests/Common/Common.csproj
index 4133622d20..ffcd2869f9 100644
--- a/src/Microsoft.Data.SqlClient/tests/Common/Common.csproj
+++ b/src/Microsoft.Data.SqlClient/tests/Common/Common.csproj
@@ -1,5 +1,4 @@
-
Commonnetfx
@@ -11,6 +10,12 @@
true
+
+
+ $(DefineConstants),_UNIX
+ $(DefineConstants),_WINDOWS
+
+
diff --git a/src/Microsoft.Data.SqlClient/tests/Common/LocalAppContextSwitchesHelper.cs b/src/Microsoft.Data.SqlClient/tests/Common/LocalAppContextSwitchesHelper.cs
index 0f7b994e5e..1798e1fcf4 100644
--- a/src/Microsoft.Data.SqlClient/tests/Common/LocalAppContextSwitchesHelper.cs
+++ b/src/Microsoft.Data.SqlClient/tests/Common/LocalAppContextSwitchesHelper.cs
@@ -33,10 +33,16 @@ public sealed class LocalAppContextSwitchesHelper : IDisposable
private readonly PropertyInfo _truncateScaledDecimalProperty;
private readonly PropertyInfo _ignoreServerProvidedFailoverPartner;
private readonly PropertyInfo _enableUserAgent;
-#if NET
+
+ #if NET
private readonly PropertyInfo _globalizationInvariantModeProperty;
+ #endif
+
+ #if NET && _WINDOWS
private readonly PropertyInfo _useManagedNetworkingProperty;
- #else
+ #endif
+
+ #if NETFRAMEWORK
private readonly PropertyInfo _disableTnirByDefaultProperty;
#endif
@@ -63,12 +69,18 @@ public sealed class LocalAppContextSwitchesHelper : IDisposable
private readonly Tristate _ignoreServerProvidedFailoverPartnerOriginal;
private readonly FieldInfo _enableUserAgentField;
private readonly Tristate _enableUserAgentOriginal;
-#if NET
+
+ #if NET
private readonly FieldInfo _globalizationInvariantModeField;
private readonly Tristate _globalizationInvariantModeOriginal;
+ #endif
+
+ #if NET && _WINDOWS
private readonly FieldInfo _useManagedNetworkingField;
private readonly Tristate _useManagedNetworkingOriginal;
- #else
+ #endif
+
+ #if NETFRAMEWORK
private readonly FieldInfo _disableTnirByDefaultField;
private readonly Tristate _disableTnirByDefaultOriginal;
#endif
@@ -169,15 +181,19 @@ void InitProperty(string name, out PropertyInfo property)
"EnableUserAgent",
out _enableUserAgent);
-#if NET
+ #if NET
InitProperty(
"GlobalizationInvariantMode",
out _globalizationInvariantModeProperty);
-
+ #endif
+
+ #if NET && _WINDOWS
InitProperty(
"UseManagedNetworking",
out _useManagedNetworkingProperty);
- #else
+ #endif
+
+ #if NETFRAMEWORK
InitProperty(
"DisableTnirByDefault",
out _disableTnirByDefaultProperty);
@@ -253,17 +269,21 @@ void InitField(string name, out FieldInfo field, out Tristate value)
out _enableUserAgentField,
out _enableUserAgentOriginal);
-#if NET
+ #if NET
InitField(
"s_globalizationInvariantMode",
out _globalizationInvariantModeField,
out _globalizationInvariantModeOriginal);
-
+ #endif
+
+ #if NET && _WINDOWS
InitField(
"s_useManagedNetworking",
out _useManagedNetworkingField,
out _useManagedNetworkingOriginal);
- #else
+ #endif
+
+ #if NETFRAMEWORK
InitField(
"s_disableTnirByDefault",
out _disableTnirByDefaultField,
@@ -339,15 +359,19 @@ void RestoreField(FieldInfo field, Tristate value)
_enableUserAgentField,
_enableUserAgentOriginal);
-#if NET
+ #if NET
RestoreField(
_globalizationInvariantModeField,
_globalizationInvariantModeOriginal);
-
+ #endif
+
+ #if NET && _WINDOWS
RestoreField(
_useManagedNetworkingField,
_useManagedNetworkingOriginal);
- #else
+ #endif
+
+ #if NETFRAMEWORK
RestoreField(
_disableTnirByDefaultField,
_disableTnirByDefaultOriginal);
@@ -450,7 +474,7 @@ public bool EnableUserAgent
get => (bool)_enableUserAgent.GetValue(null);
}
-#if NET
+ #if NET
///
/// Access the LocalAppContextSwitches.GlobalizationInvariantMode property.
///
@@ -458,7 +482,9 @@ public bool GlobalizationInvariantMode
{
get => (bool)_globalizationInvariantModeProperty.GetValue(null);
}
+ #endif
+ #if NET && _WINDOWS
///
/// Access the LocalAppContextSwitches.UseManagedNetworking property.
///
@@ -466,7 +492,9 @@ public bool UseManagedNetworking
{
get => (bool)_useManagedNetworkingProperty.GetValue(null);
}
- #else
+ #endif
+
+ #if NETFRAMEWORK
///
/// Access the LocalAppContextSwitches.DisableTnirByDefault property.
///
@@ -580,7 +608,7 @@ public Tristate EnableUserAgentField
set => SetValue(_enableUserAgentField, value);
}
-#if NET
+ #if NET
///
/// Get or set the LocalAppContextSwitches.GlobalizationInvariantMode switch value.
///
@@ -589,7 +617,9 @@ public Tristate GlobalizationInvariantModeField
get => GetValue(_globalizationInvariantModeField);
set => SetValue(_globalizationInvariantModeField, value);
}
+ #endif
+ #if NET && _WINDOWS
///
/// Get or set the LocalAppContextSwitches.UseManagedNetworking switch value.
///
@@ -598,7 +628,9 @@ public Tristate UseManagedNetworkingField
get => GetValue(_useManagedNetworkingField);
set => SetValue(_useManagedNetworkingField, value);
}
- #else
+ #endif
+
+ #if NETFRAMEWORK
///
/// Get or set the LocalAppContextSwitches.DisableTnirByDefault switch
/// value.