Conversation
|
Tagging subscribers to this area: @karelz, @dotnet/ncl |
There was a problem hiding this comment.
Pull request overview
This PR streamlines Windows SystemIPGlobalProperties TCP/UDP enumeration by reducing managed allocations and shifting more filtering/shape-matching into the native interop layer.
Changes:
- Switch TCP/UDP enumeration to
GetExtendedTcpTable/GetExtendedUdpTable, using native table-class filtering for listener queries. - Reshape
IpHlpApiinterop table/row structs to more closely match native layouts and exposeLocalEndPoint/RemoteEndPointhelpers. - Replace byte-slicing parsing with typed span enumeration over table entries.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemTcpConnection.cs | Simplifies connection info construction by consuming new interop State/endpoint helpers. |
| src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs | Reworks TCP/UDP enumeration to use extended tables, native filtering, and span-based iteration. |
| src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs | Updates interop struct layouts and adds endpoint helper properties; removes unused legacy P/Invokes. |
Comments suppressed due to low confidence (1)
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs:198
- The comment for GetActiveUdpListeners is now inaccurate: the IPv4 path was switched from GetUdpTable to GetExtendedUdpTable. Please update the comment to reference the correct native API.
/// Gets the active UDP listeners. Uses the native GetUdpTable API.
public override unsafe IPEndPoint[] GetActiveUdpListeners()
{
.../System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs
Show resolved
Hide resolved
.../System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs
Show resolved
Hide resolved
.../System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs
Outdated
Show resolved
Hide resolved
.../System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs
Outdated
Show resolved
Hide resolved
.../System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs
Outdated
Show resolved
Hide resolved
.../System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs
Show resolved
Hide resolved
.../System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs
Show resolved
Hide resolved
🤖 Copilot Code Review — PR #125002Holistic AssessmentMotivation: Well-justified. The old code had unnecessary intermediate allocations (a full Approach: Clean and correct. Consolidating onto Summary: ✅ LGTM. This is a well-executed refactoring that reduces allocations, eliminates dead code, and modernizes the interop layer. Struct layouts were verified against the Windows API, port endianness conversion is correct, and the filtering logic preserves existing behavior. Two minor suggestions below. Detailed Findings✅ Struct Layout Correctness — All struct sizes match the Windows APIVerified all four row struct sizes against the Windows API definitions:
No padding concerns: all table structs have ✅ Port Endianness Conversion — Verified correctThe new MihaZupan's endianness question is addressed by pentp's response — this is Windows-only code, and Windows only runs on little-endian architectures. ✅ Filtering Logic — Correct and more efficient
✅ No Public API Changes — All modifications are internalNo ref assembly changes. All renamed fields, new properties, and removed P/Invokes are 💡 Minor Optimization Opportunity —
|
|
Regarding |
GetActiveTcpConnections/GetActiveTcpListeners.