[dotnet] Make Selenium Manager's AOT safety explicit#14733
[dotnet] Make Selenium Manager's AOT safety explicit#14733nvborisenko merged 1 commit intoSeleniumHQ:trunkfrom
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
nvborisenko
left a comment
There was a problem hiding this comment.
Yeap, this is just a warning, because analyzer cannot understand whether options are "good", which is good. I don't mind to satisfy him. Thank you.
|
It was considered and rejected to tie the "AOT warning" to the serialization instance: dotnet/runtime#108781 If we are to support AOT, we will eventually enable the warnings and these will light up the sky, unless we use this approach. |
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
The
JsonSerializerOptionsinstance passed to theSeleniumManagerResponsedeserialization is AOT-safe, because theTypeResolverwas set to a source-generated instance.However, the JSON de-serialization method cannot know that. For that reason, we can use the de-serialization method that takes a
JsonTypeInfo<T>overload.Motivation and Context
Satisfies AOT analyzer warning

Types of changes
Checklist
PR Type
enhancement
Description
JsonSerializerOptionswithJsonSerializerContext.Default.SeleniumManagerResponseto ensure AOT safety in the deserialization process.SeleniumManagerResponse,LogEntryResponse, andResultResponseto sealed records to enhance performance.JsonSourceGenerationOptionswithPropertyNameCaseInsensitiveset to true for improved JSON property handling.Changes walkthrough 📝
SeleniumManager.cs
Improve AOT safety and performance in SeleniumManagerdotnet/src/webdriver/SeleniumManager.cs
JsonSerializerOptionswithJsonSerializerContextfor AOTsafety.
JsonSourceGenerationOptionsattribute for case insensitivity.