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 0a0f573333..57497fd2b0 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj
@@ -726,6 +726,9 @@
Common\Interop\Windows\Kernel32\Interop.IoControlTransferType.cs
+
+ Common\Interop\Windows\kernel32\Interop.LoadLibraryEx.cs
+
Common\Interop\Windows\NtDll\Interop.FILE_FULL_EA_INFORMATION.cs
@@ -826,16 +829,25 @@
Microsoft\Data\Sql\SqlDataSourceEnumerator.Windows.cs
+
+ Microsoft\Data\SqlClient\SSPI\NativeSSPIContextProvider.cs
+
Microsoft\Data\SqlClient\TdsParserSafeHandles.Windows.cs
+
+
+
+
+
+
@@ -894,31 +906,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
- Common\Interop\Windows\kernel32\Interop.LoadLibraryEx.cs
-
-
- Microsoft\Data\SqlClient\SSPI\NativeSSPIContextProvider.cs
-
-
-
-
-
-
-
-
@@ -947,10 +934,6 @@
-
-
-
-
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/LocalDBAPI.uap.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/LocalDBAPI.uap.cs
deleted file mode 100644
index 9ed10f0fcc..0000000000
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/LocalDBAPI.uap.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.
-
-using System;
-
-namespace System.Data
-{
- internal static partial class LocalDBAPI
- {
- private static IntPtr LoadProcAddress() =>
- throw new PlatformNotSupportedException(Strings.LocalDBNotSupported); // No Registry support on UAP
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/LocalDB.uap.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/LocalDB.uap.cs
deleted file mode 100644
index e764375802..0000000000
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SNI/LocalDB.uap.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.SNI
-{
- internal class LocalDB
- {
- internal static string GetLocalDBConnectionString(string localDbInstance)
- {
- throw new PlatformNotSupportedException(Strings.LocalDBNotSupported); // No Registry support on UAP
- }
- }
-}
diff --git a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
index 0d3c0a01b5..84b3978bdf 100644
--- a/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
+++ b/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.cs
@@ -1509,9 +1509,7 @@ internal SqlError ProcessSNIError(TdsParserStateObject stateObj)
SqlClientEventSource.Log.TryAdvancedTraceEvent(" Empty error message received from SNI. Error Message = {0}", details.errorMessage);
}
- string sniContextEnumName = TdsEnums.GetSniContextEnumName(stateObj.SniContext);
-
- string sqlContextInfo = StringsHelper.GetResourceString(sniContextEnumName);
+ string sqlContextInfo = StringsHelper.GetResourceString(stateObj.SniContext.ToString());
string providerRid = string.Format("SNI_PN{0}", details.provider);
string providerName = StringsHelper.GetResourceString(providerRid);
Debug.Assert(!string.IsNullOrEmpty(providerName), $"invalid providerResourceId '{providerRid}'");
diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs
index c483d8a0f8..8c7119a695 100644
--- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs
+++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsEnums.cs
@@ -3,11 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
using System.Data;
-using System.Diagnostics;
-using Microsoft.Data.Common;
namespace Microsoft.Data.SqlClient
{
@@ -998,47 +994,6 @@ internal enum FedAuthInfoId : byte
internal const byte DATA_CLASSIFICATION_VERSION_WITHOUT_RANK_SUPPORT = 0x01;
internal const byte DATA_CLASSIFICATION_VERSION_MAX_SUPPORTED = 0x02;
- // Needed for UapAot, since we cannot use Enum.GetName() on SniContext.
- // Enum.GetName() uses reflection, which is blocked on UapAot for internal types
- // like SniContext.
- internal static string GetSniContextEnumName(SniContext sniContext)
- {
- switch (sniContext)
- {
- case SniContext.Undefined:
- return "Undefined";
- case SniContext.Snix_Connect:
- return "Snix_Connect";
- case SniContext.Snix_PreLoginBeforeSuccessfulWrite:
- return "Snix_PreLoginBeforeSuccessfulWrite";
- case SniContext.Snix_PreLogin:
- return "Snix_PreLogin";
- case SniContext.Snix_LoginSspi:
- return "Snix_LoginSspi";
- case SniContext.Snix_ProcessSspi:
- return "Snix_ProcessSspi";
- case SniContext.Snix_Login:
- return "Snix_Login";
- case SniContext.Snix_EnableMars:
- return "Snix_EnableMars";
- case SniContext.Snix_AutoEnlist:
- return "Snix_AutoEnlist";
- case SniContext.Snix_GetMarsSession:
- return "Snix_GetMarsSession";
- case SniContext.Snix_Execute:
- return "Snix_Execute";
- case SniContext.Snix_Read:
- return "Snix_Read";
- case SniContext.Snix_Close:
- return "Snix_Close";
- case SniContext.Snix_SendRows:
- return "Snix_SendRows";
- default:
- Debug.Fail($"Received unknown SniContext enum. Value: {sniContext}");
- return null;
- }
- }
-
// TCE Related constants
internal const byte MAX_SUPPORTED_TCE_VERSION = 0x03; // max version
internal const byte MIN_TCE_VERSION_WITH_ENCLAVE_SUPPORT = 0x02; // min version with enclave support
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
index 62d4f641ea..e88a72104c 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs
@@ -11,19 +11,19 @@
using System.IO;
using System.Linq;
using System.Net;
+using System.Net.NetworkInformation;
using System.Net.Sockets;
+using System.Runtime.InteropServices;
using System.Security;
+using System.Security.Principal;
+using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Azure.Core;
+using Azure.Identity;
using Microsoft.Data.SqlClient.TestUtilities;
using Microsoft.Identity.Client;
using Xunit;
-using System.Net.NetworkInformation;
-using System.Text;
-using System.Security.Principal;
-using System.Runtime.InteropServices;
-using Azure.Identity;
-using Azure.Core;
namespace Microsoft.Data.SqlClient.ManualTesting.Tests
{
@@ -77,10 +77,6 @@ public static class DataTestUtility
public const string AKVEventSourceName = "Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.EventSource";
private const string ManagedNetworkingAppContextSwitch = "Switch.Microsoft.Data.SqlClient.UseManagedNetworkingOnWindows";
- // uap constant
- const long APPMODEL_ERROR_NO_PACKAGE = 15700L;
- public static readonly bool IsRunningAsUWPApp = RunningAsUWPApp();
-
private static Dictionary AvailableDatabases;
private static BaseEventListener TraceListener;
@@ -676,10 +672,6 @@ public static string GetUserIdentityAccessToken()
public static bool IsAccessTokenSetup() => !string.IsNullOrEmpty(GetAccessToken());
- public static bool IsSystemIdentityTokenSetup() => !string.IsNullOrEmpty(GetSystemIdentityAccessToken());
-
- public static bool IsUserIdentityTokenSetup() => !string.IsNullOrEmpty(GetUserIdentityAccessToken());
-
public static bool IsFileStreamSetup() => !string.IsNullOrEmpty(FileStreamDirectory) && IsNotAzureServer() && IsNotAzureSynapse();
private static bool CheckException(Exception ex, string exceptionMessage, bool innerExceptionMustBeNull) where TException : Exception
@@ -780,58 +772,6 @@ public static TException ExpectFailure(Action actionThatFails, strin
}
}
- public static TException ExpectFailure(Action actionThatFails, string exceptionMessage = null, string innerExceptionMessage = null, bool innerInnerExceptionMustBeNull = false) where TException : Exception where TInnerException : Exception
- {
- try
- {
- actionThatFails();
- Assert.Fail("ERROR: Did not get expected exception");
- return null;
- }
- catch (Exception ex)
- {
- if ((CheckException(ex, exceptionMessage, false)) && (CheckException(ex.InnerException, innerExceptionMessage, innerInnerExceptionMustBeNull)))
- {
- return (ex as TException);
- }
- else
- {
- throw;
- }
- }
- }
-
- public static TException ExpectFailure(Action actionThatFails, string exceptionMessage = null, string innerExceptionMessage = null, string innerInnerExceptionMessage = null, bool innerInnerInnerExceptionMustBeNull = false) where TException : Exception where TInnerException : Exception where TInnerInnerException : Exception
- {
- try
- {
- actionThatFails();
- Assert.Fail("ERROR: Did not get expected exception");
- return null;
- }
- catch (Exception ex)
- {
- if ((CheckException(ex, exceptionMessage, false)) && (CheckException(ex.InnerException, innerExceptionMessage, false)) && (CheckException(ex.InnerException.InnerException, innerInnerExceptionMessage, innerInnerInnerExceptionMustBeNull)))
- {
- return (ex as TException);
- }
- else
- {
- throw;
- }
- }
- }
-
- public static void ExpectAsyncFailure(Func actionThatFails, string exceptionMessage = null, bool innerExceptionMustBeNull = false) where TException : Exception
- {
- ExpectFailure(() => actionThatFails().Wait(), null, exceptionMessage, innerExceptionMustBeNull);
- }
-
- public static void ExpectAsyncFailure(Func actionThatFails, string exceptionMessage = null, string innerExceptionMessage = null, bool innerInnerExceptionMustBeNull = false) where TException : Exception where TInnerException : Exception
- {
- ExpectFailure(() => actionThatFails().Wait(), null, exceptionMessage, innerExceptionMessage, innerInnerExceptionMustBeNull);
- }
-
public static string GenerateObjectName()
{
return string.Format("TEST_{0}{1}{2}", Environment.GetEnvironmentVariable("ComputerName"), Environment.TickCount, Guid.NewGuid()).Replace('-', '_');
@@ -1093,44 +1033,5 @@ public static string GetMachineFQDN(string hostname)
}
return fqdn.ToString();
}
-
- public static bool IsNotLocalhost()
- {
- // get the tcp connection string
- SqlConnectionStringBuilder builder = new(DataTestUtility.TCPConnectionString);
-
- string hostname = "";
-
- // parse the datasource
- ParseDataSource(builder.DataSource, out hostname, out _, out _);
-
- // hostname must not be localhost, ., 127.0.0.1 nor ::1
- return !(new string[] { "localhost", ".", "127.0.0.1", "::1" }).Contains(hostname.ToLowerInvariant());
-
- }
-
- private static bool RunningAsUWPApp()
- {
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- return false;
- }
- else
- {
- [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder packageFullName);
-
- {
- int length = 0;
- StringBuilder sb = new(0);
- _ = GetCurrentPackageFullName(ref length, sb);
-
- sb = new StringBuilder(length);
- int result = GetCurrentPackageFullName(ref length, sb);
-
- return result != APPMODEL_ERROR_NO_PACKAGE;
- }
- }
- }
}
}
diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs
index 9b8e7476e4..b1ba557562 100644
--- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs
+++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ExceptionTest/ConnectionExceptionTest.cs
@@ -176,25 +176,6 @@ public void NamedPipeInvalidConnStringTest()
OpenBadConnection(builder.ConnectionString, invalidConnStringError);
}
- [ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.IsRunningAsUWPApp))]
- public static void LocalDBNotSupportedOnUapTest()
- {
- SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(@$"server=(localdb)\{DataTestUtility.LocalDbAppName}")
- {
- IntegratedSecurity = true,
- ConnectTimeout = 2
- };
-
- Assert.Throws(() =>
- {
- using (SqlConnection conn = new SqlConnection(builder.ConnectionString))
- {
- conn.Open();
- }
- });
- }
-
-
private void GenerateConnectionException(string connectionString)
{
using (SqlConnection sqlConnection = new SqlConnection(connectionString))