diff --git a/dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs b/dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs
index 2a374d5f5eb14..b9bb4efcf0084 100644
--- a/dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs
+++ b/dotnet/src/webdriver/Remote/DriverServiceCommandExecutor.cs
@@ -20,6 +20,8 @@
using System;
using System.Threading.Tasks;
+#nullable enable
+
namespace OpenQA.Selenium.Remote
{
///
@@ -27,8 +29,7 @@ namespace OpenQA.Selenium.Remote
///
public class DriverServiceCommandExecutor : ICommandExecutor
{
- private DriverService service;
- private HttpCommandExecutor internalExecutor;
+ private readonly DriverService service;
private bool isDisposed;
///
@@ -36,6 +37,7 @@ public class DriverServiceCommandExecutor : ICommandExecutor
///
/// The that drives the browser.
/// The maximum amount of time to wait for each command.
+ /// If is .
public DriverServiceCommandExecutor(DriverService driverService, TimeSpan commandTimeout)
: this(driverService, commandTimeout, true)
{
@@ -48,10 +50,11 @@ public DriverServiceCommandExecutor(DriverService driverService, TimeSpan comman
/// The maximum amount of time to wait for each command.
/// if the KeepAlive header should be sent
/// with HTTP requests; otherwise, .
+ /// If is .
public DriverServiceCommandExecutor(DriverService driverService, TimeSpan commandTimeout, bool enableKeepAlive)
{
- this.service = driverService;
- this.internalExecutor = new HttpCommandExecutor(driverService.ServiceUrl, commandTimeout, enableKeepAlive);
+ this.service = driverService ?? throw new ArgumentNullException(nameof(driverService));
+ this.HttpExecutor = new HttpCommandExecutor(driverService.ServiceUrl, commandTimeout, enableKeepAlive);
}
///
@@ -60,10 +63,11 @@ public DriverServiceCommandExecutor(DriverService driverService, TimeSpan comman
/// The that drives the browser.
/// The object used to execute commands,
/// communicating with the service via HTTP.
+ /// If or are .
public DriverServiceCommandExecutor(DriverService service, HttpCommandExecutor commandExecutor)
{
- this.service = service;
- this.internalExecutor = commandExecutor;
+ this.service = service ?? throw new ArgumentNullException(nameof(service));
+ this.HttpExecutor = commandExecutor ?? throw new ArgumentNullException(nameof(commandExecutor));
}
///
@@ -71,22 +75,19 @@ public DriverServiceCommandExecutor(DriverService service, HttpCommandExecutor c
///
//public CommandInfoRepository CommandInfoRepository
//{
- // get { return this.internalExecutor.CommandInfoRepository; }
+ // get { return this.HttpExecutor.CommandInfoRepository; }
//}
public bool TryAddCommand(string commandName, CommandInfo info)
{
- return this.internalExecutor.TryAddCommand(commandName, info);
+ return this.HttpExecutor.TryAddCommand(commandName, info);
}
///
/// Gets the that sends commands to the remote
/// end WebDriver implementation.
///
- public HttpCommandExecutor HttpExecutor
- {
- get { return this.internalExecutor; }
- }
+ public HttpCommandExecutor HttpExecutor { get; }
///
/// Executes a command
@@ -110,7 +111,7 @@ public async Task ExecuteAsync(Command commandToExecute)
throw new ArgumentNullException(nameof(commandToExecute), "Command to execute cannot be null");
}
- Response toReturn = null;
+ Response toReturn;
if (commandToExecute.Name == DriverCommand.NewSession)
{
this.service.Start();
@@ -120,7 +121,7 @@ public async Task ExecuteAsync(Command commandToExecute)
// command, so that we can get the finally block.
try
{
- toReturn = await this.internalExecutor.ExecuteAsync(commandToExecute).ConfigureAwait(false);
+ toReturn = await this.HttpExecutor.ExecuteAsync(commandToExecute).ConfigureAwait(false);
}
finally
{
@@ -139,6 +140,7 @@ public async Task ExecuteAsync(Command commandToExecute)
public void Dispose()
{
this.Dispose(true);
+ GC.SuppressFinalize(this);
}
///
@@ -153,7 +155,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
- this.internalExecutor.Dispose();
+ this.HttpExecutor.Dispose();
this.service.Dispose();
}
diff --git a/dotnet/src/webdriver/Remote/ICommandServer.cs b/dotnet/src/webdriver/Remote/ICommandServer.cs
index 395616482f7d5..f70d536dfd042 100644
--- a/dotnet/src/webdriver/Remote/ICommandServer.cs
+++ b/dotnet/src/webdriver/Remote/ICommandServer.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.Remote
{
///