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

[API Proposal]: IPAddress should implement ISpanFormattable/Parsable<IPAddress> #82842

Closed
stephentoub opened this issue Mar 1, 2023 · 5 comments · Fixed by #82913
Closed
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-System.Net
Milestone

Comments

@stephentoub
Copy link
Member

Background and motivation

IPAddress already provides TryFormat/TryParse methods. It should implement the appropriate interfaces to go along with these. Doing that for IPAddress, for example, means the IPAddress's TryFormat will be used as part of string interpolation rather than its ToString() being used.

API Proposal

namespace System.Net

public class IPAddress
+    : ISpanFormattable, ISpanParsable<IPAddress>
{
    // all of the interface members implemented explicitly
}

API Usage

IPAddress address = ...;
string s = $"The address is {address}";

Alternative Designs

No response

Risks

No response

@stephentoub stephentoub added area-System.Net api-ready-for-review API is ready for review, it is NOT ready for implementation labels Mar 1, 2023
@stephentoub stephentoub added this to the 8.0.0 milestone Mar 1, 2023
@ghost
Copy link

ghost commented Mar 1, 2023

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

Issue Details

Background and motivation

IPAddress already provides TryFormat/TryParse methods. It should implement the appropriate interfaces to go along with these. Doing that for IPAddress, for example, means the IPAddress's TryFormat will be used as part of string interpolation rather than its ToString() being used.

API Proposal

namespace System.Net

public class IPAddress
+    : ISpanFormattable, ISpanParsable<IPAddress>
{
    // all of the interface members implemented explicitly
}

API Usage

IPAddress address = ...;
string s = $"The address is {address}";

Alternative Designs

No response

Risks

No response

Author: stephentoub
Assignees: -
Labels:

area-System.Net, api-ready-for-review

Milestone: 8.0.0

@stephentoub
Copy link
Member Author

Implementation:
main...stephentoub:runtime:ipaddressinterfaces

@stephentoub stephentoub added the blocking Marks issues that we want to fast track in order to unblock other important work label Mar 1, 2023
@stephentoub
Copy link
Member Author

cc: @antonfirsov

@antonfirsov
Copy link
Member

@stephentoub thanks for pushing this! Since the implementation looks trivial, I think we should get this done before finishing #82779.

@bartonjs
Copy link
Member

bartonjs commented Mar 2, 2023

Video

Looks good as proposed

namespace System.Net

public class IPAddress
+    : ISpanFormattable, ISpanParsable<IPAddress>
{
    // all of the interface members implemented explicitly
}

@bartonjs bartonjs added api-approved API was approved in API review, it can be implemented and removed blocking Marks issues that we want to fast track in order to unblock other important work api-ready-for-review API is ready for review, it is NOT ready for implementation labels Mar 2, 2023
@stephentoub stephentoub self-assigned this Mar 2, 2023
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Mar 2, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Mar 6, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Apr 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-System.Net
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants