diff --git a/dotnet/src/webdriver/DevTools/Network.cs b/dotnet/src/webdriver/DevTools/Network.cs index 64f3cce08750a..5b6b021e6596c 100644 --- a/dotnet/src/webdriver/DevTools/Network.cs +++ b/dotnet/src/webdriver/DevTools/Network.cs @@ -17,9 +17,12 @@ // under the License. // +using System; using System.Linq; using System.Threading.Tasks; +#nullable enable + namespace OpenQA.Selenium.DevTools { /// @@ -30,17 +33,17 @@ public abstract class Network /// /// Occurs when a network request requires authorization. /// - public event AsyncEventHandler AuthRequired; + public event AsyncEventHandler? AuthRequired; /// /// Occurs when a network request is intercepted. /// - public event AsyncEventHandler RequestPaused; + public event AsyncEventHandler? RequestPaused; /// /// Occurs when a network response is received. /// - public event AsyncEventHandler ResponsePaused; + public event AsyncEventHandler? ResponsePaused; /// /// Asynchronously disables network caching. @@ -61,7 +64,7 @@ public abstract class Network public abstract Task EnableNetwork(); /// - /// Asynchronously diables the fetch domain. + /// Asynchronously disables the fetch domain. /// /// A task that represents the asynchronous operation. public abstract Task DisableNetwork(); @@ -79,7 +82,7 @@ public abstract class Network /// A task that represents the asynchronous operation. public async Task SetUserAgentOverride(string userAgent) { - await SetUserAgentOverride(new UserAgent() { UserAgentString = userAgent }).ConfigureAwait(false); + await SetUserAgentOverride(new UserAgent(userAgent)).ConfigureAwait(false); } /// @@ -87,10 +90,11 @@ public async Task SetUserAgentOverride(string userAgent) /// /// A object containing the user agent values to override. /// A task that represents the asynchronous operation. + /// If is null. public abstract Task SetUserAgentOverride(UserAgent userAgent); /// - /// Asynchronously diables the fetch domain. + /// Asynchronously disables the fetch domain. /// /// A task that represents the asynchronous operation. public abstract Task DisableFetch(); @@ -100,6 +104,7 @@ public async Task SetUserAgentOverride(string userAgent) /// /// The of the request. /// A task that represents the asynchronous operation. + /// If is . public abstract Task ContinueRequest(HttpRequestData requestData); /// @@ -108,13 +113,15 @@ public async Task SetUserAgentOverride(string userAgent) /// The of the request. /// The with which to respond to the request /// A task that represents the asynchronous operation. + /// If or are . public abstract Task ContinueRequestWithResponse(HttpRequestData requestData, HttpResponseData responseData); /// - /// Asynchronously contines an intercepted network request without modification. + /// Asynchronously continues an intercepted network request without modification. /// /// The of the network request. /// A task that represents the asynchronous operation. + /// If is . public abstract Task ContinueRequestWithoutModification(HttpRequestData requestData); /// @@ -124,7 +131,7 @@ public async Task SetUserAgentOverride(string userAgent) /// The user name with which to authenticate. /// The password with which to authenticate. /// A task that represents the asynchronous operation. - public abstract Task ContinueWithAuth(string requestId, string userName, string password); + public abstract Task ContinueWithAuth(string requestId, string? userName, string? password); /// /// Asynchronously cancels authorization of an intercepted network request. @@ -138,6 +145,7 @@ public async Task SetUserAgentOverride(string userAgent) /// /// The object to which to add the response body. /// A task that represents the asynchronous operation. + /// If is . public abstract Task AddResponseBody(HttpResponseData responseData); /// @@ -145,6 +153,7 @@ public async Task SetUserAgentOverride(string userAgent) /// /// The of the network response. /// A task that represents the asynchronous operation. + /// If is . public abstract Task ContinueResponseWithoutModification(HttpResponseData responseData); /// @@ -200,7 +209,7 @@ protected virtual void OnResponsePaused(ResponsePausedEventArgs e) /// A task that represents the asynchronous operation. /// - /// Am asynchrounous delegate for handling network events. + /// Am asynchronous delegate for handling network events. /// /// The type of event args the event raises. /// The sender of the event. diff --git a/dotnet/src/webdriver/DevTools/v130/V130Network.cs b/dotnet/src/webdriver/DevTools/v130/V130Network.cs index 74be92a081246..8d8d7396776f5 100644 --- a/dotnet/src/webdriver/DevTools/v130/V130Network.cs +++ b/dotnet/src/webdriver/DevTools/v130/V130Network.cs @@ -24,6 +24,8 @@ using System.Text; using System.Threading.Tasks; +#nullable enable + namespace OpenQA.Selenium.DevTools.V130 { /// @@ -39,10 +41,11 @@ public class V130Network : DevTools.Network /// /// The adapter for the Network domain. /// The adapter for the Fetch domain. + /// If or are . public V130Network(NetworkAdapter network, FetchAdapter fetch) { - this.network = network; - this.fetch = fetch; + this.network = network ?? throw new ArgumentNullException(nameof(network)); + this.fetch = fetch ?? throw new ArgumentNullException(nameof(fetch)); fetch.AuthRequired += OnFetchAuthRequired; fetch.RequestPaused += OnFetchRequestPaused; } @@ -101,7 +104,7 @@ await fetch.Enable(new Fetch.EnableCommandSettings() } /// - /// Asynchronously diables the fetch domain. + /// Asynchronously disables the fetch domain. /// /// A task that represents the asynchronous operation. public override async Task DisableFetch() @@ -114,8 +117,14 @@ public override async Task DisableFetch() /// /// A object containing the user agent values to override. /// A task that represents the asynchronous operation. + /// If is null. public override async Task SetUserAgentOverride(UserAgent userAgent) { + if (userAgent is null) + { + throw new ArgumentNullException(nameof(userAgent)); + } + await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() { UserAgent = userAgent.UserAgentString, @@ -129,8 +138,14 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() /// /// The of the request. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueRequest(HttpRequestData requestData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + var commandSettings = new ContinueRequestCommandSettings() { RequestId = requestData.RequestId, @@ -163,8 +178,19 @@ public override async Task ContinueRequest(HttpRequestData requestData) /// The of the request. /// The with which to respond to the request /// A task that represents the asynchronous operation. + /// If or are . public override async Task ContinueRequestWithResponse(HttpRequestData requestData, HttpResponseData responseData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + var commandSettings = new FulfillRequestCommandSettings() { RequestId = requestData.RequestId, @@ -196,12 +222,18 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa } /// - /// Asynchronously contines an intercepted network call without modification. + /// Asynchronously continues an intercepted network call without modification. /// /// The of the network call. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueRequestWithoutModification(HttpRequestData requestData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }).ConfigureAwait(false); } @@ -212,7 +244,7 @@ public override async Task ContinueRequestWithoutModification(HttpRequestData re /// The user name with which to authenticate. /// The password with which to authenticate. /// A task that represents the asynchronous operation. - public override async Task ContinueWithAuth(string requestId, string userName, string password) + public override async Task ContinueWithAuth(string requestId, string? userName, string? password) { await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() { @@ -248,8 +280,14 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() /// /// The object to which to add the response body. /// A task that represents the asynchronous operation. + /// If is . public override async Task AddResponseBody(HttpResponseData responseData) { + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + // If the response is a redirect, retrieving the body will throw an error in CDP. if (responseData.StatusCode < 300 || responseData.StatusCode > 399) { @@ -273,12 +311,18 @@ public override async Task AddResponseBody(HttpResponseData responseData) /// /// The of the network response. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueResponseWithoutModification(HttpResponseData responseData) { + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + await fetch.ContinueResponse(new ContinueResponseCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); } - private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) + private void OnFetchAuthRequired(object? sender, Fetch.AuthRequiredEventArgs e) { AuthRequiredEventArgs wrapped = new AuthRequiredEventArgs ( @@ -289,7 +333,7 @@ private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) this.OnAuthRequired(wrapped); } - private void OnFetchRequestPaused(object sender, Fetch.RequestPausedEventArgs e) + private void OnFetchRequestPaused(object? sender, Fetch.RequestPausedEventArgs e) { if (e.ResponseErrorReason == null && e.ResponseStatusCode == null) { diff --git a/dotnet/src/webdriver/DevTools/v131/V131Network.cs b/dotnet/src/webdriver/DevTools/v131/V131Network.cs index c8887543338be..a8c5e2447c9b8 100644 --- a/dotnet/src/webdriver/DevTools/v131/V131Network.cs +++ b/dotnet/src/webdriver/DevTools/v131/V131Network.cs @@ -24,6 +24,8 @@ using System.Text; using System.Threading.Tasks; +#nullable enable + namespace OpenQA.Selenium.DevTools.V131 { /// @@ -39,10 +41,11 @@ public class V131Network : DevTools.Network /// /// The adapter for the Network domain. /// The adapter for the Fetch domain. + /// If or are . public V131Network(NetworkAdapter network, FetchAdapter fetch) { - this.network = network; - this.fetch = fetch; + this.network = network ?? throw new ArgumentNullException(nameof(network)); + this.fetch = fetch ?? throw new ArgumentNullException(nameof(fetch)); fetch.AuthRequired += OnFetchAuthRequired; fetch.RequestPaused += OnFetchRequestPaused; } @@ -101,7 +104,7 @@ await fetch.Enable(new Fetch.EnableCommandSettings() } /// - /// Asynchronously diables the fetch domain. + /// Asynchronously disables the fetch domain. /// /// A task that represents the asynchronous operation. public override async Task DisableFetch() @@ -114,8 +117,14 @@ public override async Task DisableFetch() /// /// A object containing the user agent values to override. /// A task that represents the asynchronous operation. + /// If is null. public override async Task SetUserAgentOverride(UserAgent userAgent) { + if (userAgent is null) + { + throw new ArgumentNullException(nameof(userAgent)); + } + await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() { UserAgent = userAgent.UserAgentString, @@ -129,8 +138,14 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() /// /// The of the request. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueRequest(HttpRequestData requestData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + var commandSettings = new ContinueRequestCommandSettings() { RequestId = requestData.RequestId, @@ -163,8 +178,19 @@ public override async Task ContinueRequest(HttpRequestData requestData) /// The of the request. /// The with which to respond to the request /// A task that represents the asynchronous operation. + /// If or are . public override async Task ContinueRequestWithResponse(HttpRequestData requestData, HttpResponseData responseData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + var commandSettings = new FulfillRequestCommandSettings() { RequestId = requestData.RequestId, @@ -196,12 +222,18 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa } /// - /// Asynchronously contines an intercepted network call without modification. + /// Asynchronously continues an intercepted network call without modification. /// /// The of the network call. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueRequestWithoutModification(HttpRequestData requestData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }).ConfigureAwait(false); } @@ -212,7 +244,7 @@ public override async Task ContinueRequestWithoutModification(HttpRequestData re /// The user name with which to authenticate. /// The password with which to authenticate. /// A task that represents the asynchronous operation. - public override async Task ContinueWithAuth(string requestId, string userName, string password) + public override async Task ContinueWithAuth(string requestId, string? userName, string? password) { await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() { @@ -248,8 +280,14 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() /// /// The object to which to add the response body. /// A task that represents the asynchronous operation. + /// If is . public override async Task AddResponseBody(HttpResponseData responseData) { + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + // If the response is a redirect, retrieving the body will throw an error in CDP. if (responseData.StatusCode < 300 || responseData.StatusCode > 399) { @@ -273,12 +311,18 @@ public override async Task AddResponseBody(HttpResponseData responseData) /// /// The of the network response. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueResponseWithoutModification(HttpResponseData responseData) { + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + await fetch.ContinueResponse(new ContinueResponseCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); } - private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) + private void OnFetchAuthRequired(object? sender, Fetch.AuthRequiredEventArgs e) { AuthRequiredEventArgs wrapped = new AuthRequiredEventArgs ( @@ -289,7 +333,7 @@ private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) this.OnAuthRequired(wrapped); } - private void OnFetchRequestPaused(object sender, Fetch.RequestPausedEventArgs e) + private void OnFetchRequestPaused(object? sender, Fetch.RequestPausedEventArgs e) { if (e.ResponseErrorReason == null && e.ResponseStatusCode == null) { diff --git a/dotnet/src/webdriver/DevTools/v132/V132Network.cs b/dotnet/src/webdriver/DevTools/v132/V132Network.cs index 6acaf24d58472..629a91a018cfb 100644 --- a/dotnet/src/webdriver/DevTools/v132/V132Network.cs +++ b/dotnet/src/webdriver/DevTools/v132/V132Network.cs @@ -24,6 +24,8 @@ using System.Text; using System.Threading.Tasks; +#nullable enable + namespace OpenQA.Selenium.DevTools.V132 { /// @@ -39,10 +41,11 @@ public class V132Network : DevTools.Network /// /// The adapter for the Network domain. /// The adapter for the Fetch domain. + /// If or are . public V132Network(NetworkAdapter network, FetchAdapter fetch) { - this.network = network; - this.fetch = fetch; + this.network = network ?? throw new ArgumentNullException(nameof(network)); + this.fetch = fetch ?? throw new ArgumentNullException(nameof(fetch)); fetch.AuthRequired += OnFetchAuthRequired; fetch.RequestPaused += OnFetchRequestPaused; } @@ -101,7 +104,7 @@ await fetch.Enable(new Fetch.EnableCommandSettings() } /// - /// Asynchronously diables the fetch domain. + /// Asynchronously disables the fetch domain. /// /// A task that represents the asynchronous operation. public override async Task DisableFetch() @@ -114,8 +117,14 @@ public override async Task DisableFetch() /// /// A object containing the user agent values to override. /// A task that represents the asynchronous operation. + /// If is null. public override async Task SetUserAgentOverride(UserAgent userAgent) { + if (userAgent is null) + { + throw new ArgumentNullException(nameof(userAgent)); + } + await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() { UserAgent = userAgent.UserAgentString, @@ -129,8 +138,14 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() /// /// The of the request. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueRequest(HttpRequestData requestData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + var commandSettings = new ContinueRequestCommandSettings() { RequestId = requestData.RequestId, @@ -163,8 +178,19 @@ public override async Task ContinueRequest(HttpRequestData requestData) /// The of the request. /// The with which to respond to the request /// A task that represents the asynchronous operation. + /// If or are . public override async Task ContinueRequestWithResponse(HttpRequestData requestData, HttpResponseData responseData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + var commandSettings = new FulfillRequestCommandSettings() { RequestId = requestData.RequestId, @@ -196,12 +222,18 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa } /// - /// Asynchronously contines an intercepted network call without modification. + /// Asynchronously continues an intercepted network call without modification. /// /// The of the network call. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueRequestWithoutModification(HttpRequestData requestData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }).ConfigureAwait(false); } @@ -212,7 +244,7 @@ public override async Task ContinueRequestWithoutModification(HttpRequestData re /// The user name with which to authenticate. /// The password with which to authenticate. /// A task that represents the asynchronous operation. - public override async Task ContinueWithAuth(string requestId, string userName, string password) + public override async Task ContinueWithAuth(string requestId, string? userName, string? password) { await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() { @@ -248,8 +280,14 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() /// /// The object to which to add the response body. /// A task that represents the asynchronous operation. + /// If is . public override async Task AddResponseBody(HttpResponseData responseData) { + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + // If the response is a redirect, retrieving the body will throw an error in CDP. if (responseData.StatusCode < 300 || responseData.StatusCode > 399) { @@ -273,12 +311,18 @@ public override async Task AddResponseBody(HttpResponseData responseData) /// /// The of the network response. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueResponseWithoutModification(HttpResponseData responseData) { + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + await fetch.ContinueResponse(new ContinueResponseCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); } - private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) + private void OnFetchAuthRequired(object? sender, Fetch.AuthRequiredEventArgs e) { AuthRequiredEventArgs wrapped = new AuthRequiredEventArgs ( @@ -289,7 +333,7 @@ private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) this.OnAuthRequired(wrapped); } - private void OnFetchRequestPaused(object sender, Fetch.RequestPausedEventArgs e) + private void OnFetchRequestPaused(object? sender, Fetch.RequestPausedEventArgs e) { if (e.ResponseErrorReason == null && e.ResponseStatusCode == null) { diff --git a/dotnet/src/webdriver/DevTools/v85/V85Network.cs b/dotnet/src/webdriver/DevTools/v85/V85Network.cs index f660049cf2548..8a2e38ff471a5 100644 --- a/dotnet/src/webdriver/DevTools/v85/V85Network.cs +++ b/dotnet/src/webdriver/DevTools/v85/V85Network.cs @@ -24,6 +24,8 @@ using System.Text; using System.Threading.Tasks; +#nullable enable + namespace OpenQA.Selenium.DevTools.V85 { /// @@ -39,10 +41,11 @@ public class V85Network : DevTools.Network /// /// The adapter for the Network domain. /// The adapter for the Fetch domain. + /// If or are . public V85Network(NetworkAdapter network, FetchAdapter fetch) { - this.network = network; - this.fetch = fetch; + this.network = network ?? throw new ArgumentNullException(nameof(network)); + this.fetch = fetch ?? throw new ArgumentNullException(nameof(fetch)); fetch.AuthRequired += OnFetchAuthRequired; fetch.RequestPaused += OnFetchRequestPaused; } @@ -66,7 +69,7 @@ public override async Task EnableNetworkCaching() } /// - /// Asynchronously ensables the Network domain.. + /// Asynchronously enables the Network domain.. /// /// A task that represents the asynchronous operation. public override async Task EnableNetwork() @@ -101,7 +104,7 @@ await fetch.Enable(new Fetch.EnableCommandSettings() } /// - /// Asynchronously diables the fetch domain. + /// Asynchronously disables the fetch domain. /// /// A task that represents the asynchronous operation. public override async Task DisableFetch() @@ -114,8 +117,14 @@ public override async Task DisableFetch() /// /// A object containing the user agent values to override. /// A task that represents the asynchronous operation. + /// If is null. public override async Task SetUserAgentOverride(UserAgent userAgent) { + if (userAgent is null) + { + throw new ArgumentNullException(nameof(userAgent)); + } + await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() { UserAgent = userAgent.UserAgentString, @@ -129,8 +138,14 @@ await network.SetUserAgentOverride(new SetUserAgentOverrideCommandSettings() /// /// The of the request. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueRequest(HttpRequestData requestData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + var commandSettings = new ContinueRequestCommandSettings() { RequestId = requestData.RequestId, @@ -163,8 +178,19 @@ public override async Task ContinueRequest(HttpRequestData requestData) /// The of the request. /// The with which to respond to the request /// A task that represents the asynchronous operation. + /// If or are . public override async Task ContinueRequestWithResponse(HttpRequestData requestData, HttpResponseData responseData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + var commandSettings = new FulfillRequestCommandSettings() { RequestId = requestData.RequestId, @@ -196,12 +222,18 @@ public override async Task ContinueRequestWithResponse(HttpRequestData requestDa } /// - /// Asynchronously contines an intercepted network call without modification. + /// Asynchronously continues an intercepted network call without modification. /// /// The of the network call. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueRequestWithoutModification(HttpRequestData requestData) { + if (requestData is null) + { + throw new ArgumentNullException(nameof(requestData)); + } + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = requestData.RequestId }).ConfigureAwait(false); } @@ -212,7 +244,7 @@ public override async Task ContinueRequestWithoutModification(HttpRequestData re /// The user name with which to authenticate. /// The password with which to authenticate. /// A task that represents the asynchronous operation. - public override async Task ContinueWithAuth(string requestId, string userName, string password) + public override async Task ContinueWithAuth(string requestId, string? userName, string? password) { await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() { @@ -248,8 +280,14 @@ await fetch.ContinueWithAuth(new ContinueWithAuthCommandSettings() /// /// The object to which to add the response body. /// A task that represents the asynchronous operation. + /// If is . public override async Task AddResponseBody(HttpResponseData responseData) { + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + // If the response is a redirect, retrieving the body will throw an error in CDP. if (responseData.StatusCode < 300 || responseData.StatusCode > 399) { @@ -270,12 +308,18 @@ public override async Task AddResponseBody(HttpResponseData responseData) /// /// The of the network response. /// A task that represents the asynchronous operation. + /// If is . public override async Task ContinueResponseWithoutModification(HttpResponseData responseData) { + if (responseData is null) + { + throw new ArgumentNullException(nameof(responseData)); + } + await fetch.ContinueRequest(new ContinueRequestCommandSettings() { RequestId = responseData.RequestId }).ConfigureAwait(false); } - private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) + private void OnFetchAuthRequired(object? sender, Fetch.AuthRequiredEventArgs e) { AuthRequiredEventArgs wrapped = new AuthRequiredEventArgs ( @@ -286,7 +330,7 @@ private void OnFetchAuthRequired(object sender, Fetch.AuthRequiredEventArgs e) this.OnAuthRequired(wrapped); } - private void OnFetchRequestPaused(object sender, Fetch.RequestPausedEventArgs e) + private void OnFetchRequestPaused(object? sender, Fetch.RequestPausedEventArgs e) { if (e.ResponseErrorReason == null && e.ResponseStatusCode == null) { diff --git a/dotnet/src/webdriver/ICredentials.cs b/dotnet/src/webdriver/ICredentials.cs index 971c3dcb821e8..e56e6ea1b76de 100644 --- a/dotnet/src/webdriver/ICredentials.cs +++ b/dotnet/src/webdriver/ICredentials.cs @@ -17,6 +17,8 @@ // under the License. // +#nullable enable + namespace OpenQA.Selenium { /// diff --git a/dotnet/src/webdriver/NetworkManager.cs b/dotnet/src/webdriver/NetworkManager.cs index b508c32140ca0..eae9b433c7cbb 100644 --- a/dotnet/src/webdriver/NetworkManager.cs +++ b/dotnet/src/webdriver/NetworkManager.cs @@ -200,7 +200,7 @@ private async Task OnAuthRequired(object sender, AuthRequiredEventArgs e) { if (authenticationHandler.UriMatcher.Invoke(uri)) { - PasswordCredentials credentials = authenticationHandler.Credentials as PasswordCredentials; + PasswordCredentials credentials = (PasswordCredentials)authenticationHandler.Credentials; await this.session.Value.Domains.Network.ContinueWithAuth(e.RequestId, credentials.UserName, credentials.Password).ConfigureAwait(false); successfullyAuthenticated = true; break; diff --git a/dotnet/src/webdriver/PasswordCredentials.cs b/dotnet/src/webdriver/PasswordCredentials.cs index f22d40f0bb425..4709ead785517 100644 --- a/dotnet/src/webdriver/PasswordCredentials.cs +++ b/dotnet/src/webdriver/PasswordCredentials.cs @@ -17,6 +17,8 @@ // under the License. // +#nullable enable + namespace OpenQA.Selenium { /// @@ -37,7 +39,7 @@ public PasswordCredentials() /// /// The user name for the credentials. /// The password for the credentials. - public PasswordCredentials(string userName, string password) + public PasswordCredentials(string? userName, string? password) { UserName = userName; Password = password; @@ -46,11 +48,11 @@ public PasswordCredentials(string userName, string password) /// /// Gets the user name. /// - public string UserName { get; private set; } + public string? UserName { get; } /// /// Gets the password. /// - public string Password { get; private set; } + public string? Password { get; } } } diff --git a/dotnet/src/webdriver/UserAgent.cs b/dotnet/src/webdriver/UserAgent.cs index 68b823b0a16a8..ba47a350b9291 100644 --- a/dotnet/src/webdriver/UserAgent.cs +++ b/dotnet/src/webdriver/UserAgent.cs @@ -17,6 +17,10 @@ // under the License. // +#nullable enable + +using System; + namespace OpenQA.Selenium.DevTools { /// @@ -24,6 +28,24 @@ namespace OpenQA.Selenium.DevTools /// public class UserAgent { + /// + /// Initializes a new instance of the type. + /// + [Obsolete("Use the constructor which sets the userAgentString")] + public UserAgent() + { + UserAgentString = null!; + } + + /// + /// Initializes a new instance of the type. + /// + /// The user agent string. + public UserAgent(string userAgentString) + { + UserAgentString = userAgentString; + } + /// /// Gets or sets the user agent string. /// @@ -32,11 +54,11 @@ public class UserAgent /// /// Gets or sets the language to accept in headers. /// - public string AcceptLanguage { get; set; } + public string? AcceptLanguage { get; set; } /// /// Gets or sets the value of the platform. /// - public string Platform { get; set; } + public string? Platform { get; set; } } }