-
Notifications
You must be signed in to change notification settings - Fork 5k
Implement IUtf8SpanParsable
on IPAddress
and IPNetwork
#102144
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
Merged
MihaZupan
merged 45 commits into
dotnet:main
from
edwardneal:issue-81500-ipaddress-ipnetwork
Oct 24, 2024
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
81ab847
Changed IP address parsers to use generics
edwardneal 2bf97eb
Moved generic type definitions to parser classes
edwardneal 223cece
Implemented IUtf8SpanParsable
edwardneal b9e3a62
System.Private.Uri changes
edwardneal 4e580ac
Post-Uri testing, corrected additional uses of IPvXAddressHelper
edwardneal 8ff7241
Added IUtf8SpanParsable unit tests
edwardneal f627e44
Implemented IUtf8SpanParsable on IPNetwork, added tests
edwardneal 1f52945
Brief tidy-up of System.Net.Primitives ref project and csproj
edwardneal 3710a7a
Further cleanup of System.Net.Primitives.Pal.Tests csproj
edwardneal 1f4968c
Further cleanup of System.Net.Primitives.UnitTests.Tests csproj
edwardneal ed8c666
Correctly setting bytesConsumed in IPv4AddressHelper.ParseNonCanonical
edwardneal 3c6e190
Merge branch 'dotnet:main' into issue-81500-ipaddress-ipnetwork
edwardneal ea95067
Changes following API review
edwardneal d478e82
Code review changes (round 1)
edwardneal c42c706
Removed generic type definition from classes
edwardneal 49bc3a5
Replaced ref parameter with out parameter, propagated
edwardneal 3378947
Addressing @jkotas code review comments
edwardneal 66ec8c2
Inlined all constant-value variables
edwardneal afdee99
Swapped CreateChecked to CreateTruncating
edwardneal 043120f
Code review feedback: initial work
edwardneal c593694
Removed unnecessary lastSequence modification
edwardneal 4aff60e
Code review changes
edwardneal 8c41d9b
Optimisations to IPv[4/6]AddressHelper
edwardneal 64c639c
Cleaned up IPAddressParser.Common.cs
edwardneal f290a3a
.sln file cleanup
edwardneal 65027db
Testing micro-optimisations in IPv4 address parser
edwardneal cd73915
Added "in" qualifier to Span/ROS parameters
edwardneal 385ee62
Correcting trailing "in" reference
edwardneal f7d4298
Reverted addition of "in" modifier
edwardneal cb1d208
Code review
edwardneal 0f3bbaf
Additional optimisations post-benchmark
edwardneal 1f8a166
Performance improvement
edwardneal 21f1f86
Changes following code review
edwardneal 70a60a5
Initial response to newest review
edwardneal e0c49c2
Reverted hexadecimal prefix to be case-sensitive
edwardneal 94b2dd1
Flowed Spans through to PInvoke
edwardneal 02a7a84
PInvoke/PAL cleanup
edwardneal c352e01
Added assertion
edwardneal 2da63cb
Replaced usage of if_nametoindex
edwardneal 1ba7107
Moved interface name tests
edwardneal 038d3a6
Corrected PInvoke signatures and Unix InterfaceInfoPal
edwardneal b79a6f5
Continued work with code review feedback & benchmark
edwardneal 827e5f8
Performance optimisations
edwardneal 1b5ad81
Merge remote-tracking branch 'upstream/main' into issue-81500-ipaddre…
edwardneal dfb68d2
Following code review
edwardneal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.ConvertInterfaceLuidToIndex.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class IpHlpApi | ||
{ | ||
[LibraryImport(Libraries.IpHlpApi)] | ||
internal static partial uint ConvertInterfaceLuidToIndex(in ulong interfaceLuid, ref uint ifIndex); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.ConvertInterfaceLuidToName.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class IpHlpApi | ||
{ | ||
[LibraryImport(Libraries.IpHlpApi, StringMarshalling = StringMarshalling.Utf16, EntryPoint = "ConvertInterfaceLuidToNameW")] | ||
internal static unsafe partial uint ConvertInterfaceLuidToName(in ulong interfaceLuid, Span<char> name, int nameLength); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.ConvertInterfaceNameToLuid.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class IpHlpApi | ||
{ | ||
/// <summary> | ||
/// Converts a Unicode network interface name to the locally unique identifier (LUID) for the interface. | ||
/// </summary> | ||
/// <seealso href="https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-convertinterfacenametoluidw"/> | ||
/// <param name="interfaceName">The NULL-terminated Unicode string containing the network interface name.</param> | ||
/// <param name="interfaceLuid">A pointer to the NET_LUID for this interface.</param> | ||
/// <returns></returns> | ||
[LibraryImport(Libraries.IpHlpApi, StringMarshalling = StringMarshalling.Utf16, EntryPoint = "ConvertInterfaceNameToLuidW")] | ||
internal static unsafe partial uint ConvertInterfaceNameToLuid(ReadOnlySpan<char> interfaceName, ref ulong interfaceLuid); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.