-
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
Implement IUtf8SpanParsable
on Guid
#105654
base: main
Are you sure you want to change the base?
Conversation
Note regarding the
|
1 similar comment
Note regarding the
|
@dotnet-policy-service agree |
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/GuidTests.cs
Show resolved
Hide resolved
// | ||
|
||
/// <inheritdoc cref="IUtf8SpanParsable{TSelf}.Parse(ReadOnlySpan{byte}, IFormatProvider?)" /> | ||
public static Guid Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider) => Parse(utf8Text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these methods with IFormatProvider
be explicitly implemented? I see that is the case for e.g. IUtf8SpanFormattable
method. C.f. #81500 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I raised this question in my linked API proposal (#105653), but that was closed as already approved, so I guess this is how it's supposed to be?
Sorted methods in ref assembly. Removed unneccesary ToSpan(). Unified DecodeByte logic. Used TrimUtf8() instead of bespoke function.
Update tests to include unicode whitespace characters. Add IFormatProvider overloads to tests.
Tagging subscribers to this area: @dotnet/area-system-runtime |
Part of #81500
API Proposal: #105653
This implements
IUtf8SpanParsable
onGuid
by making the core of the parsing logic generic onTChar : IUtfChar<TChar>
. A small amount of it is duplicated, with a version forchar
andbyte
, because doing so prevented a performance regression forchar
parsing.In addition, it adds a Utf8
Parse
andTryParse
without the unusedIFormatProvider
parameter, to match howISpanParsable
was implemented. I did not add Utf8 overloads forParseExact
, but that can be discussed in the linked API proposal.