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

Add IPAddress.IsValid #111433

Merged
merged 3 commits into from
Jan 15, 2025
Merged

Add IPAddress.IsValid #111433

merged 3 commits into from
Jan 15, 2025

Conversation

MihaZupan
Copy link
Member

Closes #111282

namespace System.Net;

public partial class IPAddress
{
+   public static bool IsValid(ReadOnlySpan<char> ipSpan);
+   public static bool IsValidUtf8(ReadOnlySpan<byte> utf8Text);
}

@MihaZupan MihaZupan added this to the 10.0.0 milestone Jan 14, 2025
@MihaZupan MihaZupan requested a review from a team January 14, 2025 19:42
@MihaZupan MihaZupan self-assigned this Jan 14, 2025
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

1 similar comment
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

{
int end = ipSpan.Length;
long address = IPv4AddressHelper.ParseNonCanonical(ipStringPtr, 0, ref end, notImplicitFile: true);
return address != IPv4AddressHelper.Invalid && end == ipSpan.Length;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What address does IPv4AddressHelper.Invalid represent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a -1 sentinel value

@MihaZupan
Copy link
Member Author

/ba-g build failure is dotnet/dnceng#3008

@MihaZupan MihaZupan merged commit 8104cb1 into dotnet:main Jan 15, 2025
78 of 82 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: IPAddress.IsValid
2 participants