Uh oh!
There was an error while loading. Please reload this page.
Implement IUtf8SpanFormattable on DateTime, DateTimeOffset, DateOnly, TimeOnly, TimeSpan, Char, Rune - #84469
Conversation
… TimeOnly, TimeSpan, Char, Rune
ghost
commented
Apr 7, 2023
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
ghost
commented
Apr 7, 2023
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsContributes to #81500 (Note that we have a fair amount of code duplication between various formatters (like the DateTimeFormat helper updated in this PR), FormattingHelpers used by Utf8Formatter, and Number.Formatting.cs used by formatting for our primitives. I've done a little consolidation in this PR, but there's a lot more than can / should be done. We're also inconsistent as to whether we're working in terms of spans, refs, or pointers, which leads to more duplication. That can also be consolidated further subsequently.)
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Also dedup Utf8Formatter for TimeSpan with TimeSpan's new IUtf8SpanFormattable implementation and a little more cleanup. And fix parameter name of TryFormat to match approved name.
stephentoub
commented
Apr 9, 2023
privateDateTime_dt=newDateTime(2023,04,06,10,37,12,DateTimeKind.Utc);privateTimeSpan_ts=TimeSpan.FromSeconds(12345.6789);privatechar[]_chars=newchar[100];privatebyte[]_bytes=newbyte[100];[Benchmark]publicboolDT_Char_R()=>_dt.TryFormat(_chars,out_,"r");[Benchmark]publicboolDT_Char_O()=>_dt.TryFormat(_chars,out_,"o");[Benchmark]publicboolDT_Char_Rfc1123()=>_dt.TryFormat(_chars,out_,DateTimeFormatInfo.InvariantInfo.RFC1123Pattern);[Benchmark]publicboolTS_Char_C()=>_ts.TryFormat(_chars,out_,"c");[Benchmark]publicboolTS_Char_G()=>_ts.TryFormat(_chars,out_,"G");[Benchmark]publicboolUTF8Formatter_DT_R()=>Utf8Formatter.TryFormat(_dt,_bytes,out_,newStandardFormat('R'));[Benchmark]publicboolUTF8Formatter_DT_O()=>Utf8Formatter.TryFormat(_dt,_bytes,out_,newStandardFormat('O'));[Benchmark]publicboolUTF8Formatter_TS_C()=>Utf8Formatter.TryFormat(_ts,_bytes,out_,default);[Benchmark]publicboolUTF8Formatter_TS_G()=>Utf8Formatter.TryFormat(_ts,_bytes,out_,newStandardFormat('G'));
|
Contributes to #81500
(Note that we have a fair amount of code duplication between various formatters (like the DateTimeFormat helper updated in this PR), FormattingHelpers used by Utf8Formatter, and Number.Formatting.cs used by formatting for our primitives. I've done a little consolidation in this PR, but there's a lot more than can / should be done. We're also inconsistent as to whether we're working in terms of spans, refs, or pointers, which leads to more duplication. That can also be consolidated further subsequently.)