IPAddress has this, but not IPEndPoint.
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
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-stringThis 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
IPEndPointfor all to use instead.Note that the ASP.NET Team recognized this need,
IPEndPointParserexists, but it's over inMicrosoft.AspNetCore.HttpOverrideswhich is a very odd dependency to take. This should be inSystem.Netdirectly.