Runtime: IPEndPoint should have Parse/TryParse methods

Created on 22 Aug 2017  路  7Comments  路  Source: dotnet/runtime

IPAddress has this, but not IPEndPoint.

area-System.Net enhancement

Most helpful comment

I came here to second this, I was looking at a library we maintain and IPv6 failures (basically splitting on : underneath) and you find examples like: https://stackoverflow.com/questions/2727609/best-way-to-create-ipendpoint-from-string

This really seems like something that should be in the BCL. When it was IPv4, sure, split on the port delimiter and call it a day. But now we have IPv6 and semicolons are everywhere and people are parsing (and allocating arrays and re-joining them) all over the place. It's not good practice, many implementations are error-prone, and won't keep up (just as they haven't with IPv4 -> IPv6). This should be on IPEndPoint for all to use instead.

Note that the ASP.NET Team recognized this need, IPEndPointParser exists, but it's over in Microsoft.AspNetCore.HttpOverrides which is a very odd dependency to take. This should be in System.Net directly.

All 7 comments

What would it parse specifically? Anything in the exact format it renders in ToString?

Yes. Basically, IPAddress:Port.

I came here to second this, I was looking at a library we maintain and IPv6 failures (basically splitting on : underneath) and you find examples like: https://stackoverflow.com/questions/2727609/best-way-to-create-ipendpoint-from-string

This really seems like something that should be in the BCL. When it was IPv4, sure, split on the port delimiter and call it a day. But now we have IPv6 and semicolons are everywhere and people are parsing (and allocating arrays and re-joining them) all over the place. It's not good practice, many implementations are error-prone, and won't keep up (just as they haven't with IPv4 -> IPv6). This should be on IPEndPoint for all to use instead.

Note that the ASP.NET Team recognized this need, IPEndPointParser exists, but it's over in Microsoft.AspNetCore.HttpOverrides which is a very odd dependency to take. This should be in System.Net directly.

Sounds reasonable.

cc @terrajobst this would be a simple API proposal (one method addition) - are we open to such for ns3.0?

I thought an API had to be in at least one platform for awhile before it was in a standard. Has that changed?

Regardless, this actually needs an API proposal, detailing its shape, overloads, etc.

Tracking this with dotnet/corefx#31291

Was this page helpful?
0 / 5 - 0 ratings

Related issues

btecu picture btecu  路  3Comments

matty-hall picture matty-hall  路  3Comments

noahfalk picture noahfalk  路  3Comments

EgorBo picture EgorBo  路  3Comments

nalywa picture nalywa  路  3Comments