From c145c8b269c464b0b90cc6c81971511962c3b2db Mon Sep 17 00:00:00 2001 From: wfurt Date: Thu, 12 May 2022 11:23:30 -0700 Subject: [PATCH] remove internal socket exception from NameResolution --- .../src/System.Net.NameResolution.csproj | 6 ------ .../System.Net.NameResolution/src/System/Net/Dns.cs | 11 +++++++++-- .../tests/PalTests/NameResolutionPalTests.cs | 6 +++--- .../System.Net.NameResolution.Pal.Tests.csproj | 8 ++------ 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj index 6500b0152dbae1..6d7ee08de0bc56 100644 --- a/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj +++ b/src/libraries/System.Net.NameResolution/src/System.Net.NameResolution.csproj @@ -41,8 +41,6 @@ - - - RunAsync(Func func, return task; } + + private static Exception CreateException(SocketError error, int nativeError) + { + SocketException e = new SocketException((int)error); + e.HResult = nativeError; + return e; + } } } diff --git a/src/libraries/System.Net.NameResolution/tests/PalTests/NameResolutionPalTests.cs b/src/libraries/System.Net.NameResolution/tests/PalTests/NameResolutionPalTests.cs index d2c0b1fc229c65..030f03c01eddf7 100644 --- a/src/libraries/System.Net.NameResolution/tests/PalTests/NameResolutionPalTests.cs +++ b/src/libraries/System.Net.NameResolution/tests/PalTests/NameResolutionPalTests.cs @@ -343,7 +343,7 @@ public async Task GetAddrInfoAsync_EmptyHost(bool justAddresses) if (error == SocketError.HostNotFound && !OperatingSystem.IsWindows()) { - // On Unix, we are not guaranteed to be able to resove the local host. The ability to do so depends on the + // On Unix, we are not guaranteed to be able to resolve the local host. The ability to do so depends on the // machine configurations, which varies by distro and is often inconsistent. return; } @@ -393,7 +393,7 @@ public async Task GetAddrInfoAsync_HostName(bool justAddresses) if (error == SocketError.HostNotFound && !OperatingSystem.IsWindows()) { - // On Unix, we are not guaranteed to be able to resove the local host. The ability to do so depends on the + // On Unix, we are not guaranteed to be able to resolve the local host. The ability to do so depends on the // machine configurations, which varies by distro and is often inconsistent. return; } @@ -463,7 +463,7 @@ public async Task GetAddrInfoAsync_UnknownHost(bool justAddresses) const string hostName = "test.123"; - SocketException socketException = await Assert.ThrowsAnyAsync(() => NameResolutionPal.GetAddrInfoAsync(hostName, justAddresses, AddressFamily.Unspecified, CancellationToken.None)).ConfigureAwait(false); + SocketException socketException = await Assert.ThrowsAsync(() => NameResolutionPal.GetAddrInfoAsync(hostName, justAddresses, AddressFamily.Unspecified, CancellationToken.None)).ConfigureAwait(false); SocketError socketError = socketException.SocketErrorCode; Assert.Equal(SocketError.HostNotFound, socketError); diff --git a/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj b/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj index ea167e20906640..eddfcc3175c5b3 100644 --- a/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj +++ b/src/libraries/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj @@ -25,6 +25,8 @@ Link="Common\System\Net\Sockets\ProtocolType.cs" /> + - @@ -81,10 +81,6 @@ Link="Common\System\Net\Internals\Interop.CheckedAccess.cs" /> - -