diff --git a/src/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 8268964df020..1ebd2872db81 100644 --- a/src/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -54,6 +54,8 @@ + + Common\System\Net\ContextAwareResult.Windows.cs @@ -132,7 +134,7 @@ Interop\Windows\Kernel32\Interop.GetProcAddress.cs - + Interop\Windows\Kernel32\Interop.LoadLibraryEx.cs diff --git a/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.NetCoreApp.cs b/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.NetCoreApp.cs new file mode 100644 index 000000000000..da3d02a19180 --- /dev/null +++ b/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.NetCoreApp.cs @@ -0,0 +1,25 @@ +// 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 Microsoft.Win32.SafeHandles; + +namespace System.Net +{ + internal static partial class NameResolutionPal + { + + private static bool GetAddrInfoExSupportsOverlapped() + { + using (SafeLibraryHandle libHandle = Interop.Kernel32.LoadLibraryExW(Interop.Libraries.Ws2_32, IntPtr.Zero, Interop.Kernel32.LOAD_LIBRARY_SEARCH_SYSTEM32)) + { + if (libHandle.IsInvalid) + return false; + + // We can't just check that 'GetAddrInfoEx' exists, because it existed before supporting overlapped. + // The existance of 'GetAddrInfoExCancel' indicates that overlapped is supported. + return Interop.Kernel32.GetProcAddress(libHandle, Interop.Winsock.GetAddrInfoExCancelFunctionName) != IntPtr.Zero; + } + } + } +} diff --git a/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.Uap.cs b/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.Uap.cs new file mode 100644 index 000000000000..dbe26d12a70d --- /dev/null +++ b/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.Uap.cs @@ -0,0 +1,15 @@ +// 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.Net +{ + internal static partial class NameResolutionPal + { + + private static bool GetAddrInfoExSupportsOverlapped() + { + return false; + } + } +} diff --git a/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.cs b/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.cs index 33538ac298d8..ed6216eca94c 100644 --- a/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.cs +++ b/src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.cs @@ -13,7 +13,7 @@ namespace System.Net { - internal static class NameResolutionPal + internal static partial class NameResolutionPal { // // used by GetHostName() to preallocate a buffer for the call to gethostname. @@ -339,19 +339,6 @@ public static void EnsureSocketsAreInitialized() } } - private static bool GetAddrInfoExSupportsOverlapped() - { - using (SafeLibraryHandle libHandle = Interop.Kernel32.LoadLibraryExW(Interop.Libraries.Ws2_32, IntPtr.Zero, Interop.Kernel32.LOAD_LIBRARY_SEARCH_SYSTEM32)) - { - if (libHandle.IsInvalid) - return false; - - // We can't just check that 'GetAddrInfoEx' exists, because it existed before supporting overlapped. - // The existance of 'GetAddrInfoExCancel' indicates that overlapped is supported. - return Interop.Kernel32.GetProcAddress(libHandle, Interop.Winsock.GetAddrInfoExCancelFunctionName) != IntPtr.Zero; - } - } - public static unsafe void GetAddrInfoAsync(DnsResolveAsyncResult asyncResult) { GetAddrInfoExContext* context = GetAddrInfoExContext.AllocateContext();