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]: Implement IUtf8SpanParsable<T> on Guid #97378

Closed
neon-sunset opened this issue Jan 23, 2024 · 2 comments
Closed

[API Proposal]: Implement IUtf8SpanParsable<T> on Guid #97378

neon-sunset opened this issue Jan 23, 2024 · 2 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Comments

@neon-sunset
Copy link
Contributor

neon-sunset commented Jan 23, 2024

Background and motivation

Currently, Guid does not implement IUtf8SpanParsable<T>.

It is not uncommon to parse values of such type from UTF-8 bytes sourced from network streams, files and etc. directly, making it a reasonable expectation to be able to do this given it implements IUtf8SpanFormattable for the opposite operation.

API Proposal

namespace System.Collections.Generic;

public partial struct Guid : IUtf8SpanParsable<Guid>
{
    public static Guid Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider);
    public static bool TryParse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider, out Guid result);
}

API Usage

var text = "89042d67-7fd5-4d7c-8baa-7fe672b2f123"u8;
var guid = Guid.Parse(text);

Alternative Designs

Use existing Utf8Parser.TryParse(bytes, out Guid value, out int bytesConsumed).

Risks

N/A

@neon-sunset neon-sunset added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Jan 23, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 23, 2024
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jan 23, 2024
@Rob-Hague
Copy link
Contributor

I think it's (approved and) tracked by #81500 (comment)

@neon-sunset
Copy link
Contributor Author

Right, so there's an umbrella issue for this. Thanks!

@neon-sunset neon-sunset closed this as not planned Won't fix, can't repro, duplicate, stale Jan 23, 2024
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Jan 23, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners
Projects
None yet
Development

No branches or pull requests

2 participants