-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] Add SystemClock singleton
#15285
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:
|
|
|
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.
Thanks, micro-optimizations are always good, even if it is nano :) I concern this approach will not work if in future we will add parameter in ctor. But I cannot image which one might be added.
|
If we add a parameter in the constructor, then users who use The only reason users may be forced to care about the For that reason, I opened #15314 👀 |
* [dotnet] Add SystemClock singleton * Fix copyright comment * Fix support UI test build
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.
Add
SystemClocksingletonMotivation and Context
This minimizes an allocation when using the
WebDriverWaittype, and adjacent types like components and waitsTypes of changes
Checklist
PR Type
Enhancement, Tests
Description
Introduced a singleton
SystemClock.Instanceto minimize allocations.Updated various classes to use
SystemClock.Instanceinstead of creating new instances.Refactored
FakeClocktoHandCrankClockwith improved naming and functionality.Adjusted related tests to align with the new
SystemClock.InstanceandHandCrankClock.Changes walkthrough 📝
PopupWindowFinder.cs
Use `SystemClock.Instance` in `PopupWindowFinder`dotnet/src/support/UI/PopupWindowFinder.cs
new SystemClock()withSystemClock.Instance.WebDriverWaitinitialization.SlowLoadableComponent{T}.cs
Use `SystemClock.Instance` in `SlowLoadableComponent`dotnet/src/support/UI/SlowLoadableComponent{T}.cs
new SystemClock()withSystemClock.Instance.DefaultWait{T}.cs
Use `SystemClock.Instance` in `DefaultWait`dotnet/src/webdriver/Support/DefaultWait{T}.cs
new SystemClock()withSystemClock.Instance.SystemClock.cs
Introduce singleton instance for `SystemClock`dotnet/src/webdriver/Support/SystemClock.cs
SystemClock.Instanceas a singleton instance.WebDriverWait.cs
Use `SystemClock.Instance` in `WebDriverWait`dotnet/src/webdriver/Support/WebDriverWait.cs
new SystemClock()withSystemClock.Instance.HandCrankClock.cs
Refactor `FakeClock` to `HandCrankClock`dotnet/test/support/UI/HandCrankClock.cs
FakeClocktoHandCrankClock.SlowLoadableComponentTest.cs
Update tests for `SystemClock` and `HandCrankClock`dotnet/test/support/UI/SlowLoadableComponentTest.cs
SystemClock.Instance.FakeClockwithHandCrankClock.