-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] Make Selenium.WebDriver.Common.Tests compatible with .NET Framework
#16769
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
base: trunk
Are you sure you want to change the base?
[dotnet] Make Selenium.WebDriver.Common.Tests compatible with .NET Framework
#16769
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
| public static Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout) | ||
| { | ||
| // Good enough implementation | ||
| var success = task.Wait(timeout); | ||
| if (!success) | ||
| { | ||
| throw new TimeoutException(); | ||
| } | ||
|
|
||
| return Task.FromResult(task.Result); | ||
| } |
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.
Suggestion: Implement asynchronous wait to prevent deadlocks
| public static Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout) | |
| { | |
| // Good enough implementation | |
| var success = task.Wait(timeout); | |
| if (!success) | |
| { | |
| throw new TimeoutException(); | |
| } | |
| return Task.FromResult(task.Result); | |
| } | |
| public static async Task<T> WaitAsync<T>(this Task<T> task, TimeSpan timeout) | |
| { | |
| var timeoutTask = Task.Delay(timeout); | |
| var completedTask = await Task.WhenAny(task, timeoutTask).ConfigureAwait(false); | |
| if (completedTask == timeoutTask) | |
| { | |
| throw new TimeoutException(); | |
| } | |
| return await task.ConfigureAwait(false); | |
| } |
User description
Contributes to #16115
💥 What does this PR do?
Ensure that we do not use .NET Core only APIs in the test suites.
🔧 Implementation Notes
💡 Additional Considerations
🔄 Types of changes
PR Type
Enhancement
Description
Replace .NET Core-only APIs with .NET Framework compatible alternatives
Add utility extension classes for cross-framework compatibility
Update test code to use reflection and conditional compilation
Fix test assertions for negative zero and datetime precision
Diagram Walkthrough
File Walkthrough
5 files
Replace double.NegativeZero with literalReplace UnsafeAccessor with reflection APIUse extension method for negative checkReplace OperatingSystem with utility wrapperReplace range operator with Substring method1 files
Fix DateTimeOffset constructor and assertion5 files
Add array reverse extension for compatibilityAdd IsNegative extension for double typeAdd cross-framework platform detection utilityAdd process kill extension methodAdd WaitAsync extension for pre-.NET 8