-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsBackground and motivationIPAddress already provides TryFormat/TryParse methods. It should implement the appropriate interfaces to go along with these. Doing that for API Proposalnamespace System.Net
public class IPAddress
+ : ISpanFormattable, ISpanParsable<IPAddress>
{
// all of the interface members implemented explicitly
} API UsageIPAddress address = ...;
string s = $"The address is {address}"; Alternative DesignsNo response RisksNo response
|
Implementation: |
cc: @antonfirsov |
@stephentoub thanks for pushing this! Since the implementation looks trivial, I think we should get this done before finishing #82779. |
Looks good as proposed namespace System.Net
public class IPAddress
+ : ISpanFormattable, ISpanParsable<IPAddress>
{
// all of the interface members implemented explicitly
} |
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 theIPAddress
'sTryFormat
will be used as part of string interpolation rather than itsToString()
being used.API Proposal
namespace System.Net public class IPAddress + : ISpanFormattable, ISpanParsable<IPAddress> { // all of the interface members implemented explicitly }
API Usage
Alternative Designs
No response
Risks
No response
The text was updated successfully, but these errors were encountered: