Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GeneratedDllImport in System.Net.NameResolution #54191

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ internal unsafe struct HostEntry
internal int IPAddressCount; // Number of IP addresses in the list
}

[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetHostEntryForName")]
internal static extern unsafe int GetHostEntryForName(string address, AddressFamily family, HostEntry* entry);
[GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetHostEntryForName", CharSet = CharSet.Ansi)]
internal static unsafe partial int GetHostEntryForName(string address, AddressFamily family, HostEntry* entry);

[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FreeHostEntry")]
internal static extern unsafe void FreeHostEntry(HostEntry* entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ internal static partial class Winsock

internal const int NS_ALL = 0;

[DllImport(Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern unsafe int GetAddrInfoExW(
[In] string pName,
[In] string? pServiceName,
[In] int dwNamespace,
[In] IntPtr lpNspId,
[In] AddressInfoEx* pHints,
[Out] AddressInfoEx** ppResult,
[In] IntPtr timeout,
[In] NativeOverlapped* lpOverlapped,
[In] delegate* unmanaged<int, int, NativeOverlapped*, void> lpCompletionRoutine,
[Out] IntPtr* lpNameHandle);
[GeneratedDllImport(Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
internal static unsafe partial int GetAddrInfoExW(
string pName,
string? pServiceName,
int dwNamespace,
IntPtr lpNspId,
AddressInfoEx* pHints,
AddressInfoEx** ppResult,
IntPtr timeout,
NativeOverlapped* lpOverlapped,
delegate* unmanaged<int, int, NativeOverlapped*, void> lpCompletionRoutine,
IntPtr* lpNameHandle);

[DllImport(Libraries.Ws2_32, ExactSpelling = true)]
internal static extern unsafe int GetAddrInfoExCancel([In] IntPtr* lpHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ internal static partial class Interop
{
internal static partial class Winsock
{
[DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, BestFitMapping = false, ThrowOnUnmappableChar = true, SetLastError = true)]
internal static extern unsafe int GetAddrInfoW(
[In] string pNameName,
[In] string? pServiceName,
[In] AddressInfo* pHints,
[Out] AddressInfo** ppResult);
[GeneratedDllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, CharSet = CharSet.Unicode, SetLastError = true)]
internal static unsafe partial int GetAddrInfoW(
string pNameName,
string? pServiceName,
AddressInfo* pHints,
AddressInfo** ppResult);

[DllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)]
internal static extern unsafe void FreeAddrInfoW(AddressInfo* info);
[GeneratedDllImport(Interop.Libraries.Ws2_32, ExactSpelling = true, SetLastError = true)]
internal static unsafe partial void FreeAddrInfoW(AddressInfo* info);

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
internal unsafe struct AddressInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ internal enum NameInfoFlags
NI_DGRAM = 0x10, /* Service is a datagram service */
}

[DllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, BestFitMapping = false, ThrowOnUnmappableChar = true, SetLastError = true)]
internal static extern unsafe SocketError GetNameInfoW(
[GeneratedDllImport(Interop.Libraries.Ws2_32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static unsafe partial SocketError GetNameInfoW(
byte* pSockaddr,
int SockaddrLength,
char* pNodeBuffer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Winsock
{
[DllImport(Interop.Libraries.Ws2_32, SetLastError = true)]
internal static extern unsafe SocketError gethostname(byte* name, int namelen);
[GeneratedDllImport(Interop.Libraries.Ws2_32, SetLastError = true)]
internal static unsafe partial SocketError gethostname(byte* name, int namelen);
}
}