Fix for arrays with empty elements - #3811
Conversation
|
✅ Build CefSharp 94.0.50-CI4226 completed (commit 1dd7737434 by @Romout) |
Unit test will need to be added, https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Test/OffScreen/OffScreenBrowserBasicFacts.cs#L139 Can be used as a rough guide. |
|
Looking at the actual code now and the history would suggest the section is basically unchanged since 2015. So the questions I have are was there a reason we used keys to begin with? If yes is that reason still valid? A straight index would have made more sense (I didn't write the code, though I likely reviewed it all those years ago). I'd be inclined to simplify the code as below: else if (obj->IsArray())
{
int arrLength = obj->GetArrayLength();
auto array = CefListValue::Create();
for (int i = 0; i < arrLength; i++)
{
SerializeV8Object(obj->GetValue(i), array, i, callbackRegistry, seen);
}
list->SetList(index, array);
}I did test your code and it differs slightly in it's output when I compare to JSON.stringify() for one edge case (at least that's all I found in the 2 mins of testing). As above test cases will be required before any chance can be merged. |
|
Hm, I like your version much more. You are right that keys are not even required if GetValue returns null if there isn't a value. |
… added a unit-test
|
✅ Build CefSharp 94.0.50-CI4228 completed (commit c97fd75e0e by @Romout) |
|
Test case rewritten to use |
Fixes:
Resolves #3808
Summary: [summary of the change and which issue is fixed here]
Changes: [specify the structures changed]
-No structural changes - use HasValue to check if an element is empty
How Has This Been Tested?
Used WinForms example with several inputs to try and break it but - it works.
Types of changes
Checklist: