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

Unobsolete IPAddress.Address, or create a new equivalent property #68619

Open
antonfirsov opened this issue Apr 27, 2022 · 6 comments
Open

Unobsolete IPAddress.Address, or create a new equivalent property #68619

antonfirsov opened this issue Apr 27, 2022 · 6 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net
Milestone

Comments

@antonfirsov
Copy link
Member

Forking #68591 (comment) to a new issue.

IPAddress.Address is the most efficient way to get the IPv4 value, however it doesn't make sense and throws for IPv6, so we made it obsolete.

We should consider unobsoleting it or creating a new, equivalent property with a name that describes the purpose and the limitations better, for example:

public class IPAddress
{
    public long IPv4Value { get; }
}
@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Apr 27, 2022
@ghost
Copy link

ghost commented Apr 27, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Forking #68591 (comment) to a new issue.

IPAddress.Address is the most efficient way to get the IPv4 value, however it doesn't make sense and throws for IPv6, so we made it obsolete.

We should consider unobsoleting it or creating a new, equivalent property with a name that describes the purpose and the limitations better, for example:

public class IPAddress
{
    public long IPv4Value { get; }
}
Author: antonfirsov
Assignees: -
Labels:

area-System.Net, untriaged

Milestone: -

@antonfirsov antonfirsov added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Apr 27, 2022
@karelz karelz added this to the 7.0.0 milestone May 10, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label May 10, 2022
@karelz
Copy link
Member

karelz commented May 10, 2022

Triage: It makes sense -- we should document how it should be used (with IPv4 check).
We should double check with API review team.
We could add analyzer (to check there is IPv4 check) if we think there is problem.

@karelz karelz modified the milestones: 7.0.0, 8.0.0 Jul 19, 2022
@wfurt
Copy link
Member

wfurt commented May 22, 2023

Would it make sense to have something like

public class IPAddress
{
  int128 GetAddress();
}

While this may be slightly less efficient than long it would preserve simplicity of the old interface and it would also work consistently for IPv6.
cc: @stephentoub as he made the original comment.

@antonfirsov
Copy link
Member Author

antonfirsov commented May 22, 2023

@wfurt that is basically #83971, which we decided to close, also implying we would commit to solve #84776 as a prerequisite for such an API to be implemented efficiently. (Otherwise I don't see why would it be better than TryWriteBytes)

@wfurt
Copy link
Member

wfurt commented May 22, 2023

Thanks for the pointer @antonfirsov. That one slipped from my mind. I was fiddling more with IPAddress and IPEndPoint and it would be nice to have the parity. I end up using the TryWriteBytes and it is sufficient but not as slick. Assignments and comparisons all come more complicate not even talking about using Hash.Combine.
I simply used rule to disable the obsolete warning for IPv4 e.g. there was no real functional impact for me - just inconvenience.

Perhaps we should have round of talk with @stephentoub and rest for the team.

@wfurt
Copy link
Member

wfurt commented Jun 12, 2024

triage: not critical for 9.0, moving to future

@wfurt wfurt modified the milestones: 9.0.0, Future Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net
Projects
None yet
Development

No branches or pull requests

3 participants