-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[dotnet] allow asynchronous command execution #13952
Conversation
PR Description updated to latest commit (eca81ec)
|
PR Review 🔍(Review updated until commit c405e23)
Code feedback:
|
PR Code Suggestions ✨No code suggestions found for PR. |
CI Failure Feedback 🧐(Checks updated until commit 0c8c691)
✨ CI feedback usage guide:The CI feedback tool (
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:
where Configuration options
See more information about the |
/help |
PR Agent Walkthrough 🤖Welcome to the PR Agent, an AI-powered tool for automated pull request analysis, feedback, suggestions and more. Here is a list of tools you can use to interact with the PR Agent:
(1) Note that each tool be triggered automatically when a new PR is opened, or called manually by commenting on a PR. (2) Tools marked with [*] require additional parameters to be passed. For example, to invoke the |
Persistent review updated to latest commit c405e23 |
59d6a17
to
01b6f29
Compare
01b6f29
to
49741eb
Compare
@nvborisenko & @YevgeniyShunevych is this good enough to merge for now? |
/// <param name="driverCommandToExecute">Command that needs executing</param> | ||
/// <param name="parameters">Parameters needed for the command</param> | ||
/// <returns>A task object representing the asynchronous operation</returns> | ||
internal Task<Response> InternalExecuteAsync(string driverCommandToExecute, |
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.
If I got the idea of InternalExecuteAsync
right, it is just a
copy of ExecuteAsync
but with internal
access modifier. If so, let's maybe change the access modifier of ExecuteAsync
from protected
to protected internal
, and then InternalExecuteAsync
can be removed.
A
protected internal
member is accessible from the current assembly or from types that are derived from the containing class.
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.
I'm not sure why it's there. If we change it, it should be part of a different PR, though.
|
||
|
||
/// <summary> | ||
/// Executes a command Asynchronously |
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.
/// Executes a command Asynchronously | |
/// Executes a command asynchronously. |
The capital letter fix. Additionally, I would recommend to end all sentences in XML docs (<summary>
, <param>
, etc.) with a period.
} | ||
|
||
/// <summary> | ||
/// Executes a command Asynchronously |
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.
/// Executes a command Asynchronously | |
/// Executes a command asynchronously. |
@@ -184,7 +194,7 @@ public virtual Response Execute(Command commandToExecute) | |||
HttpResponseInfo responseInfo = null; | |||
try | |||
{ | |||
responseInfo = Task.Run(async () => await this.MakeHttpRequest(requestInfo)).GetAwaiter().GetResult(); | |||
responseInfo = await this.MakeHttpRequest(requestInfo); |
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.
I think it also makes sense to rename existing method MakeHttpRequest
to MakeHttpRequestAsync
.
/// <summary> | ||
/// Encapsulates methods for working with asynchronous tasks. | ||
/// </summary> | ||
public static class AsyncHelper |
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.
The AsyncHelper
implementation is similar to https://github.com/aspnet/AspNetIdentity/blob/main/src/Microsoft.AspNet.Identity.Core/AsyncHelper.cs. If you check the differences, this implementation lacks cultures set for async functions. Maybe worth adding as well, or cultures skipped intentionally for some reason? Also I would recommend making AsyncHelper
class internal.
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.
We either need to duplicate the helper class in both webdriver and support packages or make it public in webdriver to access it from support. This approach appears to be what other classes in the repo do.
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.
Duplicate, it is not a criminal.
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.
Agreed, in this case I'm following what appears to be done elsewhere
public static class AsyncHelper | ||
{ | ||
private static readonly TaskFactory _myTaskFactory = new TaskFactory(CancellationToken.None, | ||
TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Default); |
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.
Also wandering should we deny attaching children tasks via TaskCreationOptions
?
Ok, I've redone this code a bit, and it's going to be easier to just create a new PR, so closing this. |
User description
Description
This surfaces the ability to allow the driver to execute commands asynchronously by returning a task object representing the async operation in a way that can be awaited in user code.
Motivation and Context
This is in preparation for implementing an asynchronous solution in .NET.
This PR is to demonstrate the template for the naming conventions we want to use.
The next step would be to change the async method implementation to be able to use WebDriverBiDi if it is enabled, with the current sync operation as the fallback
Types of changes
PR Type
Enhancement
Description
ExecuteAsync
inICommandExecutor
,DriverServiceCommandExecutor
,HttpCommandExecutor
, andWebDriver
to support async operations.BackAsync
inINavigation
andNavigator
for asynchronous navigation.Changes walkthrough 📝
ICommandExecutor.cs
Add asynchronous command execution interface
dotnet/src/webdriver/ICommandExecutor.cs
ExecuteAsync
method to allow asynchronous command execution.INavigation.cs
Introduce asynchronous navigation methods
dotnet/src/webdriver/INavigation.cs
BackAsync
method to navigate back asynchronously.Navigator.cs
Implement async back navigation in Navigator
dotnet/src/webdriver/Navigator.cs
BackAsync
to perform asynchronous back navigation.Back
to useBackAsync
.DriverServiceCommandExecutor.cs
Support async command execution in DriverServiceCommandExecutor
dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs
ExecuteAsync
to handle command execution asynchronously.Execute
to useExecuteAsync
.HttpCommandExecutor.cs
Enhance HttpCommandExecutor with async execution support
dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
ExecuteAsync
for asynchronous HTTP command execution.Execute
to useExecuteAsync
.WebDriver.cs
Extend WebDriver with asynchronous execution capabilities
dotnet/src/webdriver/WebDriver.cs
InternalExecuteAsync
andExecuteAsync
for async commandexecution.
Execute
methods to use their async counterparts.