Repository navigation
JSON DOM refactor - #41041
JSON DOM refactor#41041
Conversation
| set | ||
| { | ||
| _list[idx] = value ?? new JsonNull(); | ||
| _list[idx] = value ?? JsonNull.s_jsonNullInstance; |
There was a problem hiding this comment.
@ahsonkhan is this right? I get we don't want to extra allocate when possible, but is there ever a case where introducing this into a tree might cause conflicts if you have the same instance more than once in a tree?
There was a problem hiding this comment.
This is really the open issue of "does JsonNode need the ability to move to Parent (or prev/next sibling)?" If no: Cache null/true/false. If yes: new instance every time.
There was a problem hiding this comment.
One of the only issues that I could see is trying to serialize a jsonnode with duplicate references for nulls somehow creating cycles (or confusing the potential preserve-references feature). Otherwise, I don't see where the tree itself would care about duplicate references.
| public void Add(JsonNode value) | ||
| { | ||
| _list.Add(value ?? new JsonNull()); | ||
| _list.Add(value ?? JsonNull.s_jsonNullInstance); |
There was a problem hiding this comment.
Do we plan to do add any checks here and in JsonObject in case the JsonNode value was already part of the same tree which would cause cycles?
| /// </summary> | ||
| public JsonNull() { } | ||
|
|
||
| internal static JsonNull s_jsonNullInstance = new JsonNull(); |
There was a problem hiding this comment.
Given that we are using now an instance in here, should we just move this type to use the singleton pattern instead so users don't allocate when not needed?
Our general stance is "write simple code, and use ThrowHelper when needed". Unless we expect these types to be bottlenecks for significant workloads it's not a desired change. |
|
I think test failures are unrelated to my changes. |
|
Are you sure? They are all failing in Json test. https://dev.azure.com/dnceng/public/_build/results?buildId=360129&view=ms.vss-test-web.build-test-results-tab&runId=10903936&resultId=153392&paneView=debug |
| [Fact] | ||
| public static void TestChangingCurrentCulture() | ||
| { | ||
| CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; |
There was a problem hiding this comment.
Looks like this test is failing on linux. Since you're modifying a static it may be a threading issue. You might want to make this a remote executor test. /cc @tarekgh
There was a problem hiding this comment.
Right, I misinterpreted logs tab information and assumed it should be OK, because I checked it on both architectures locally and in past got unrelated failures.
There was a problem hiding this comment.
IMO don’t test current culture. It is simplest to test the difference between ordinal and ordinal ignorecase
There was a problem hiding this comment.
Ok, sure. I can remove it for now and we can consider adding this back in future.
|
I think it's ready to be merged now. But probably some minor adjustments will need to be done when #41030 is merged. |
|
Thank you for your contribution. As announced in dotnet/coreclr#27549 this repository will be moving to dotnet/runtime on November 13. If you would like to continue working on this PR after this date, the easiest way to move the change to dotnet/runtime is:
|
|
cc @maryamariyan this change was actually supposed to be ported over by either @ahsonkhan or myself but we just haven't had any time to do it. @ahsonkhan and I will sync about this offline and will update the status of what will happen to this PR. |
|
@joperezr sounds good. If you believe that the PR is not planned for approval/merge until Nov 13, you can label it as post-consolidation. |
|
I chatted with @ahsonkhan and looks like we will try to get this finished and in before Nov 13. If anything changes I'll let you know. |
bartonjs
left a comment
There was a problem hiding this comment.
I don't remember what the problems were to say if it solved them; but it seems to all be improvements.
|
Unrelated System.Net.Http.Functional.Tests failure: https://github.com/dotnet/corefx/issues/26539 |
I addressed most review comments from #40673. I am left with changing throwing exceptions to using throwing exception helpers.
addresses: #39922
cc: @bartonjs @ahsonkhan @ericstj @joperezr @terrajobst @JamesNK @stephentoub