-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] Switch DevTools response JSON parsing to JsonElement
#14990
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
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
I still don't see how, can you please elaborate more?
|
This PR is a first step towards handling the invalid JSON which CDP sometimes returns. |
When I was migrating from |
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.
Thx @RenderMichael for your contribution!
User description
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
Switches JSON response parsing in DevTools from mutable
JsonNode
to immutableJsonElement
.Motivation and Context
In general,
JsonElement
is preferred if the JSON is not being mutated. But the true motivation is from #14972.JsonElement
is a lot more forgiving of imperfect json (it allows multiple properties with the same name, it doesn't throw exceptions on invalid UTF-16 before the deserialization converters apply, etc).This will allow us to Eventually fortify the code against invalid JSON, which is the root cause of #14903.
Types of changes
Checklist
PR Type
Bug fix, Enhancement
Description
JsonNode
to immutableJsonElement
across multiple filesJsonElement
which is more forgiving of imperfect JSONChanges walkthrough 📝
DevToolsCommandData.cs
Switch Result property to JsonElement type
dotnet/src/webdriver/DevTools/DevToolsCommandData.cs
Result
property type fromJsonNode
toJsonElement
DevToolsSession.cs
Refactor JSON handling to use JsonElement
dotnet/src/webdriver/DevTools/DevToolsSession.cs
JsonElement
instead ofJsonNode
DevToolsSessionEventReceivedEventArgs.cs
Update EventData to use JsonElement
dotnet/src/webdriver/DevTools/DevToolsSessionEventReceivedEventArgs.cs
EventData
property type fromJsonNode
toJsonElement
IDevToolsSession.cs
Update SendCommand return type to JsonElement
dotnet/src/webdriver/DevTools/IDevToolsSession.cs
SendCommand
fromJsonNode
toJsonElement?