Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -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 && _WINDOWS
#if NET

using Microsoft.Win32.SafeHandles;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Microsoft.Data.Common;
using Microsoft.Win32.SafeHandles;

#if !NETFRAMEWORK && _WINDOWS
#if NET
using Interop.Windows.Handles;
#endif

Expand All @@ -19,11 +19,6 @@ internal static class Kernel32
internal const ushort FILE_DEVICE_FILE_SYSTEM = 0x0009;
internal const uint SEM_FAILCRITICALERRORS = 1;

#if _WINDOWS && !NETFRAMEWORK
internal const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
internal const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;
#endif

private const string DllName = "kernel32.dll";

/// <summary><a href="https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/defining-i-o-control-codes">CTL_CODE</a> method.</summary>
Expand Down Expand Up @@ -54,7 +49,7 @@ internal static extern bool DeviceIoControl(
out uint cbBytesReturned,
IntPtr overlapped);

#if NET && _WINDOWS
#if NET
[DllImport(DllName, ExactSpelling = true, SetLastError = true)]
public static extern bool FreeLibrary([In] IntPtr hModule);
#endif
Expand All @@ -71,7 +66,7 @@ internal static extern int GetFullPathName(
IntPtr lpFilePartOrNull);
#endif

#if NET && _WINDOWS
#if NET
[DllImport(DllName, CharSet = CharSet.Ansi, BestFitMapping = false)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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 && _WINDOWS
#if NETFRAMEWORK

using System;
using System.Runtime.InteropServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand All @@ -25,5 +23,3 @@ internal struct AuthProviderInfo
public string serverCertFileName;
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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;

Expand All @@ -18,5 +16,3 @@ internal struct ConsumerInfo
internal IntPtr key;
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand All @@ -14,5 +12,3 @@ internal enum ConsumerNumber
SNI_Consumer_Invalid,
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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;

Expand All @@ -14,5 +12,3 @@ namespace Interop.Windows.Sni

internal delegate IntPtr SqlClientCertificateDelegate(IntPtr pCallbackContext);
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand All @@ -12,5 +10,3 @@ internal enum IoType
WRITE,
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand All @@ -16,5 +14,3 @@ internal enum Prefix
INVALID_PREFIX,
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand All @@ -26,5 +24,3 @@ internal enum Provider
INVALID_PROV,
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand Down Expand Up @@ -49,5 +47,3 @@ internal enum QueryType
#endif
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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;

Expand Down Expand Up @@ -36,5 +34,3 @@ internal unsafe struct SniClientConsumerInfo
public SniDnsCacheInfo DNSCacheInfo;
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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;

Expand All @@ -23,5 +21,3 @@ internal struct SniConsumerInfo
public IntPtr NodeAffinity;
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand All @@ -21,5 +19,3 @@ internal struct SniDnsCacheInfo
public string wszCachedTcpPort;
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand All @@ -23,5 +21,3 @@ internal struct SniError
internal uint lineNumber;
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand Down Expand Up @@ -32,5 +30,3 @@ internal enum SniSslProtocols : uint
SP_PROT_TLS1_3 = SP_PROT_TLS1_3_SERVER | SP_PROT_TLS1_3_CLIENT,
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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 && _WINDOWS
#if NETFRAMEWORK

using System;
using System.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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
Expand All @@ -13,5 +11,3 @@ internal enum TransparentNetworkResolutionMode : byte
ParallelMode
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@
<!-- This file does not support pre-processor directives, so it must be conditionally -->
<!-- included into the build. -->
<EmbeddedResource Include="Resources\ILLink.Substitutions.xml"
Condition="'$(NormalizedTargetOs)' == 'windows_nt' AND '$(TargetFramework)' != 'net462'" />
Condition="'$(NormalizedTargetOs)' == 'windows_nt' AND '$(TargetFramework)' != 'net462'">
<LogicalName>ILLink.Substitutions.xml</LogicalName>
</EmbeddedResource>

<!-- Used by SqlMetaDataFactory to construct its DataSet -->
<EmbeddedResource Include="Resources\Microsoft.Data.SqlClient.SqlMetaData.xml">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
using System.Text;
using System.Threading.Tasks;

#if _WINDOWS
using Interop.Windows.Kernel32;
#endif

namespace Microsoft.Data.Common
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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.

Expand All @@ -9,9 +9,7 @@
#if NET
using System.Threading;
#else
#if _WINDOWS
using Interop.Windows.Kernel32;
#endif
using Microsoft.Data.Common;

using System.Diagnostics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ internal static class LocalAppContextSwitches
private const string UseConnectionPoolV2String =
"Switch.Microsoft.Data.SqlClient.UseConnectionPoolV2";

#if NET && _WINDOWS
#if NET
/// <summary>
/// The name of the app context switch that controls whether to use the
/// managed SNI implementation instead of the native SNI implementation on
Expand Down Expand Up @@ -222,7 +222,7 @@ private enum SwitchValue : byte
/// </summary>
private static SwitchValue s_useConnectionPoolV2 = SwitchValue.None;

#if NET && _WINDOWS
#if NET
/// <summary>
/// The cached value of the UseManagedNetworking switch.
/// </summary>
Expand Down Expand Up @@ -539,7 +539,7 @@ public static bool UseCompatibilityAsyncBehaviour
defaultValue: false,
ref s_useConnectionPoolV2);

#if NET && _WINDOWS
#if NET
/// <summary>
/// When set to true, .NET on Windows will use the managed SNI
/// implementation instead of the native SNI implementation.
Expand Down Expand Up @@ -578,12 +578,6 @@ public static bool UseManagedNetworking
return false;
}
}
#elif NET
/// <summary>
/// .NET Core on Unix does not support native SNI, so this will always be
/// true.
/// </summary>
public static bool UseManagedNetworking => true;
#else
/// <summary>
/// .NET Framework does not support the managed SNI, so this will always be
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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 && _WINDOWS
#if NET

using System;
using System.Runtime.InteropServices;
Expand All @@ -11,6 +11,7 @@
using Interop.Windows.Kernel32;
using Microsoft.Win32;
using Microsoft.Data.SqlClient.Internal;
using Microsoft.Data.Common;

namespace Microsoft.Data.SqlClient.ManagedSni
{
Expand Down Expand Up @@ -44,8 +45,16 @@ [Out] [MarshalAs(UnmanagedType.LPWStr)] StringBuilder sqlConnectionDataSource,

private LocalDB() { }

internal static string GetLocalDBConnectionString(string localDbInstance) =>
Instance.LoadUserInstanceDll() ? Instance.GetConnectionString(localDbInstance) : null;
internal static string GetLocalDBConnectionString(string localDbInstance)
{
// LocalDB is not available for Unix and hence it cannot be supported.
if (!ADP.IsWindows)
{
throw new PlatformNotSupportedException(Strings.LocalDBNotSupported);
}

return Instance.LoadUserInstanceDll() ? Instance.GetConnectionString(localDbInstance) : null;
}

internal static IntPtr GetProcAddress(string functionName) =>
Instance.LoadUserInstanceDll() ? Kernel32.GetProcAddress(LocalDB.Instance._sqlUserInstanceLibraryHandle, functionName) : IntPtr.Zero;
Expand Down
Loading
Loading