[dotnet] Lazy-load Selenium manager binary location#14639
[dotnet] Lazy-load Selenium manager binary location#14639nvborisenko merged 8 commits 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.
Thank you! It can be even simplified to avoid cunning logic, please see inner comment.
|
Thanks for the feedback, the PR has been updated |
|
Thank you @nvborisenko ! I dug into the record syntax that worked, and you were right, it was working. There may be some special support for records. However, the moment I added I'm not familiar with the STJ esoterica here, but it looks like what we have now works. Maybe once v9 comes out, the internal serialization options could enable the feature flags I linked and prevent null reference exceptions even further. |


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 location of the selenium manager binary is calculated when it is first accessed.
Motivation and Context
I ran into this while working on #14480
It is considered bad practice for static constructors to throw exceptions. If an exception is throws, the type is rendered unusable for the rest of the application lifecycle. The stack-trace of the exception is also much harder to follow, and the debugging experience is worsened. The fact that it throws
TypeInitializationExceptionthrew me off initially, because I was testing AOT at the time.Exceptions are expected on this flow, in exceptional cases, they are even thrown directly. With this change, the Stack trace changes:
Before:

After:

Types of changes
Checklist
PR Type
Enhancement
Description
GetBinaryFullPathto determine the binary path dynamically.Changes walkthrough 📝
SeleniumManager.cs
Implement lazy-loading for Selenium Manager binary pathdotnet/src/webdriver/SeleniumManager.cs