Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 0f0713f

Browse files
clean GetHostByAddr Windows
1 parent a7c62d7 commit 0f0713f

File tree

5 files changed

+3
-66
lines changed

5 files changed

+3
-66
lines changed

src/Common/src/Interop/Windows/Winsock/Interop.gethostbyaddr.cs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/System.Net.NameResolution/src/System.Net.NameResolution.csproj

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@
9494
</Compile>
9595
<Compile Include="$(CommonPath)\Interop\Windows\Winsock\Interop.closesocket.cs">
9696
<Link>Interop\Windows\Winsock\Interop.closesocket.cs</Link>
97-
</Compile>
98-
<Compile Include="$(CommonPath)\Interop\Windows\Winsock\Interop.gethostbyaddr.cs">
99-
<Link>Interop\Windows\Winsock\Interop.gethostbyaddr.cs</Link>
100-
</Compile>
97+
</Compile>
10198
<Compile Include="$(CommonPath)\Interop\Windows\Winsock\Interop.gethostname.cs">
10299
<Link>Interop\Windows\Winsock\Interop.gethostname.cs</Link>
103100
</Compile>
@@ -212,4 +209,4 @@
212209
<Reference Include="System.Threading.Tasks" />
213210
</ItemGroup>
214211
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
215-
</Project>
212+
</Project>

src/System.Net.NameResolution/src/System/Net/NameResolutionPal.Windows.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -156,34 +156,6 @@ private static IPHostEntry NativeToHostEntry(IntPtr nativePointer)
156156
return HostEntry;
157157
} // NativeToHostEntry
158158

159-
public static IPHostEntry GetHostByAddr(IPAddress address)
160-
{
161-
// TODO #2891: Optimize this (or decide if this legacy code can be removed):
162-
#pragma warning disable CS0618 // Address is marked obsolete
163-
int addressAsInt = unchecked((int)address.Address);
164-
#pragma warning restore CS0618
165-
166-
#if BIGENDIAN
167-
// TODO #2891: above code needs testing for BIGENDIAN.
168-
169-
addressAsInt = (int)(((uint)addressAsInt << 24) | (((uint)addressAsInt & 0x0000FF00) << 8) |
170-
(((uint)addressAsInt >> 8) & 0x0000FF00) | ((uint)addressAsInt >> 24));
171-
#endif
172-
173-
IntPtr nativePointer =
174-
Interop.Winsock.gethostbyaddr(
175-
ref addressAsInt,
176-
sizeof(int),
177-
ProtocolFamily.InterNetwork);
178-
179-
if (nativePointer != IntPtr.Zero)
180-
{
181-
return NativeToHostEntry(nativePointer);
182-
}
183-
184-
throw new SocketException();
185-
}
186-
187159
public static unsafe SocketError TryGetAddrInfo(string name, out IPHostEntry hostinfo, out int nativeErrorCode)
188160
{
189161
//

src/System.Net.NameResolution/tests/PalTests/NameResolutionPalTests.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ public void HostName_NotNull()
2222
Assert.NotNull(NameResolutionPal.GetHostName());
2323
}
2424

25-
[Fact]
26-
public void GetHostByAddr_LocalHost()
27-
{
28-
Assert.NotNull(NameResolutionPal.GetHostByAddr(new IPAddress(0x0100007f)));
29-
}
30-
3125
[Fact]
3226
public void TryGetAddrInfo_LocalHost()
3327
{

src/System.Net.NameResolution/tests/PalTests/System.Net.NameResolution.Pal.Tests.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@
9595
</Compile>
9696
<Compile Include="$(CommonPath)\Interop\Windows\Winsock\Interop.closesocket.cs">
9797
<Link>Interop\Windows\Winsock\Interop.closesocket.cs</Link>
98-
</Compile>
99-
<Compile Include="$(CommonPath)\Interop\Windows\Winsock\Interop.gethostbyaddr.cs">
100-
<Link>Interop\Windows\Winsock\Interop.gethostbyaddr.cs</Link>
10198
</Compile>
10299
<Compile Include="$(CommonPath)\Interop\Windows\Winsock\Interop.gethostname.cs">
103100
<Link>Interop\Windows\Winsock\Interop.gethostname.cs</Link>
@@ -193,4 +190,4 @@
193190
</Compile>
194191
</ItemGroup>
195192
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
196-
</Project>
193+
</Project>

0 commit comments

Comments
 (0)