Repository navigation
Formatting and parsing changes to JsonString - #41940
Conversation
1936ef4 to
793cdc9
Compare
ahsonkhan
left a comment
There was a problem hiding this comment.
Some nits, but otherwise looks good.
|
Looks like replacing |
|
/azp run |
|
Commenter does not have sufficient privileges for PR 41940 in repo dotnet/corefx |
|
Looks like unrelated/intermittent infra failure. I have re-run the leg. allConfigurations-Windows_NT-Debug-x64-Windows.10.Amd64.ClientRS5.Open @dotnet/dnceng |
There's not much we can do here. The machine in question only lived for about an hour and only ran 17 tests. It even ran (and passed) tests from your same run seconds after this one: https://helix.dot.net/api/2019-06-17/jobs/5d4f0f39-bc52-4365-af19-e011ec1f7502/workitems/System.Threading.AccessControl/console ... so the conclusion I'd draw here is that there was a few-seconds DNS burp with that storage account, leading to the test failing. I'd recommend adding a retry or two here given when these tests run on a scaled out scaleset there's a bunch of fast-network machines all trying to restore from this feed at once. |
This looks like a point in time network failure. |
not a network failure, an Azure storage service failure IMO. |
layomia
left a comment
There was a problem hiding this comment.
Please update the JsonStringTests as well.
I'll update the DateTime(Offset) length constants in a follow up.
Otherwise, LGTM.
| return false; | ||
| } | ||
|
|
||
| Debug.Assert(JsonReaderHelper.GetUtf8ByteCount(source) <= JsonConstants.StackallocThreshold); |
There was a problem hiding this comment.
What guarantees this? What if the source is erroneously made up of MaximumEscapedDateTimeOffsetParseLength Unicode characters?
There was a problem hiding this comment.
The IsValidDateTimeOffsetParseLength check above (#41940 (comment)):
In fact, the above check using
IsValidDateTimeOffsetParseLengthguarantees its between 10 and 6*(33+16-7), i.e. 252.
JsonConstants.StackallocThreshold is 256 😄
There was a problem hiding this comment.
Ah, I see what you mean now. If the chars in the span expands to more UTF8 bytes?
There was a problem hiding this comment.
Good point. We should add a test case for that to make sure subsequent changes don't fall into the same issue.
That said, instead of calling JsonReaderHelper.GetUtf8ByteCount, can we just assume the worst case, and do:
int length = source.Length * JsonConstants.MaxExpansionFactorWhileTranscoding;In most cases, the length will still be less than 256, and we avoid the double read over the source span.
…Count" This reverts commit 0d29b64.
|
Thanks. |
* Pull duplicated code into JsonWriterHelper * Add helpers for parsing and formatting ISO dates * Update tests to expect new format * Use new helpers in JsonString methods * Rename methods * Check for valid parse length * Use AsSpan extension to work around missing implicit operators on netfx * More netfx workarounds * Use constant for stackalloc length * Add back temp span to avoid writing too much when trimming * Move IsValidDateTimeOffsetParseLength to JsonHelpers * Always use StackallocThreshold instead of calling GetUtf8ByteCount * Remove redundant length checks done by IsValidDateTimeOffsetParseLength * Adapt test pattern from Utf8JsonWriterTests * Revert "Always use StackallocThreshold instead of calling GetUtf8ByteCount" This reverts commit dotnet/corefx@0d29b64. Commit migrated from dotnet/corefx@21fd4d2
This consolidates parsing and formatting between
Json[Reader|Writer]andJsonStringand fixes some bugs in the process.Fixes #41706
Fixes #41779