-
Notifications
You must be signed in to change notification settings - Fork 494
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
[Internal] JsonObjectState: Refactors to allow dynamically increasing JsonMaxNestingDepth #4542
base: master
Are you sure you want to change the base?
Conversation
…mum nesting depth. This will allow serialization/deserialization of Json with deeply nested objects or arrays. This is needed because distribution plans may contain expressions that are deeply nested beyond the current limit.
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.
All good!
Debug.Assert(this.jsonMaxNestingDepth < (1 << 15), "JsonMaxNestingDepth must be less than 2^15"); | ||
|
||
byte[] newNestingStackBitmap = new byte[newJsonMaxNestingDepth / 8]; | ||
Array.Copy(this.nestingStackBitmap, newNestingStackBitmap, Math.Min(this.nestingStackBitmap.Length, newNestingStackBitmap.Length)); |
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.
Please consider using Array.Resize
@@ -168,5 +168,35 @@ public void TestUnknownStruct() | |||
DateTime value = DateTime.MinValue; | |||
ReadOnlyMemory<byte> result = JsonSerializer.Serialize(value); | |||
} | |||
|
|||
[TestMethod] | |||
public void TestMaxNestingDepethResize() |
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.
@sc978345 can you please take a look at the comments and address them? |
Description
This PR modifies Json object state to support dynamically increasing the maximum nesting depth. This will allow serialization/deserialization of Json with deeply nested objects or arrays. This is needed because distribution plans may contain expressions that are deeply nested beyond the current limit.
Previously, there was a hardcoded limit of 256 for JsonMaxNestingDepth. With this change, if the limit is reached, JsonObjectState will dynamically increase the value until the supported limit of 2^15 (32k) is reached
Type of change