diff --git a/dotnet/src/webdriver/DevTools/AuthRequiredEventArgs.cs b/dotnet/src/webdriver/DevTools/AuthRequiredEventArgs.cs
index b80ff70628c32..0763b730eb120 100644
--- a/dotnet/src/webdriver/DevTools/AuthRequiredEventArgs.cs
+++ b/dotnet/src/webdriver/DevTools/AuthRequiredEventArgs.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.DevTools
{
///
@@ -26,14 +28,25 @@ namespace OpenQA.Selenium.DevTools
///
public class AuthRequiredEventArgs : EventArgs
{
+ ///
+ /// Initializes a new instance of the type.
+ ///
+ /// The request ID of the request raised the event.
+ /// The URI for which the event is raised.
+ public AuthRequiredEventArgs(string requestId, string uri)
+ {
+ Uri = uri;
+ RequestId = requestId;
+ }
+
///
/// Gets the URI for which the event is raised.
///
- public string Uri { get; internal set; }
+ public string Uri { get; }
///
/// Gets the request ID of the request raising the event.
///
- public string RequestId { get; internal set; }
+ public string RequestId { get; }
}
}
diff --git a/dotnet/src/webdriver/DevTools/BindingCalledEventArgs.cs b/dotnet/src/webdriver/DevTools/BindingCalledEventArgs.cs
index dacb1d1af14e3..b51fc14f5f962 100644
--- a/dotnet/src/webdriver/DevTools/BindingCalledEventArgs.cs
+++ b/dotnet/src/webdriver/DevTools/BindingCalledEventArgs.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.DevTools
{
///
@@ -26,19 +28,32 @@ namespace OpenQA.Selenium.DevTools
///
public class BindingCalledEventArgs : EventArgs
{
+ ///
+ /// Initializes a new instance of the type.
+ ///
+ /// The execution ID of the call to the binding.
+ /// The name of the call to the binding.
+ /// The payload of the call to the binding.
+ public BindingCalledEventArgs(long executionContextId, string name, string payload)
+ {
+ this.ExecutionContextId = executionContextId;
+ this.Name = name;
+ this.Payload = payload;
+ }
+
///
/// Gets the execution context ID of the call to the binding.
///
- public long ExecutionContextId { get; internal set; }
+ public long ExecutionContextId { get; }
///
/// Gets the name of the call to the binding.
///
- public string Name { get; internal set; }
+ public string Name { get; }
///
/// Gets the payload of the call to the binding.
///
- public string Payload { get; internal set; }
+ public string Payload { get; }
}
}
diff --git a/dotnet/src/webdriver/DevTools/CommandResponseExtensions.cs b/dotnet/src/webdriver/DevTools/CommandResponseExtensions.cs
index 2b619a7089089..d08895c4f9dd7 100644
--- a/dotnet/src/webdriver/DevTools/CommandResponseExtensions.cs
+++ b/dotnet/src/webdriver/DevTools/CommandResponseExtensions.cs
@@ -17,6 +17,8 @@
// under the License.
//
+#nullable enable
+
namespace OpenQA.Selenium.DevTools
{
///
@@ -29,8 +31,8 @@ public static class ICommandResponseExtensions
///
/// The concrete implementation type of command response expected.
/// The object to convert to the implementation type
- /// The concrete implementation of the command response.
- public static TCommandResponse GetResponse(this ICommandResponse response)
+ /// The concrete implementation of the command response, or if is not the right type.
+ public static TCommandResponse? GetResponse(this ICommandResponse response)
where TCommandResponse : class, ICommandResponse
{
return response as TCommandResponse;
diff --git a/dotnet/src/webdriver/DevTools/CommandResponseTypeMap.cs b/dotnet/src/webdriver/DevTools/CommandResponseTypeMap.cs
index d0fb592e9740a..d4d3756238085 100644
--- a/dotnet/src/webdriver/DevTools/CommandResponseTypeMap.cs
+++ b/dotnet/src/webdriver/DevTools/CommandResponseTypeMap.cs
@@ -19,6 +19,9 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+
+#nullable enable
namespace OpenQA.Selenium.DevTools
{
@@ -34,8 +37,19 @@ public class CommandResponseTypeMap
///
/// The type of command to add the mapping for.
/// The type of response object corresponding to the command.
+ /// If or are .
public void AddCommandResponseType(Type commandSettingsType, Type commandResponseType)
{
+ if (commandSettingsType is null)
+ {
+ throw new ArgumentNullException(nameof(commandSettingsType));
+ }
+
+ if (commandResponseType is null)
+ {
+ throw new ArgumentNullException(nameof(commandResponseType));
+ }
+
if (!commandResponseTypeDictionary.ContainsKey(commandSettingsType))
{
commandResponseTypeDictionary.Add(commandSettingsType, commandResponseType);
@@ -48,7 +62,7 @@ public void AddCommandResponseType(Type commandSettingsType, Type commandRespons
/// The type of command for which to retrieve the response type.
/// The returned response type.
/// if the specified command type has a mapped response type; otherwise, .
- public bool TryGetCommandResponseType(out Type commandResponseType)
+ public bool TryGetCommandResponseType([NotNullWhen(true)] out Type? commandResponseType)
where T : ICommand
{
return commandResponseTypeDictionary.TryGetValue(typeof(T), out commandResponseType);
@@ -60,7 +74,7 @@ public bool TryGetCommandResponseType(out Type commandResponseType)
/// The type of command for which to retrieve the response type.
/// The returned response type.
/// if the specified command type has a mapped response type; otherwise, .
- public bool TryGetCommandResponseType(ICommand command, out Type commandResponseType)
+ public bool TryGetCommandResponseType(ICommand command, [NotNullWhen(true)] out Type? commandResponseType)
{
return commandResponseTypeDictionary.TryGetValue(command.GetType(), out commandResponseType);
}
diff --git a/dotnet/src/webdriver/DevTools/ConsoleApiArgument.cs b/dotnet/src/webdriver/DevTools/ConsoleApiArgument.cs
index 0aa28ea11f188..bd5aae21cdb2f 100644
--- a/dotnet/src/webdriver/DevTools/ConsoleApiArgument.cs
+++ b/dotnet/src/webdriver/DevTools/ConsoleApiArgument.cs
@@ -17,6 +17,10 @@
// under the License.
//
+#nullable enable
+
+using System;
+
namespace OpenQA.Selenium.DevTools
{
///
@@ -24,14 +28,26 @@ namespace OpenQA.Selenium.DevTools
///
public class ConsoleApiArgument
{
+ ///
+ /// Initializes a new instance of the type.
+ ///
+ /// The type of the argument in the call to the browser's console API.
+ /// The value of the argument in the call to the browser's console API.
+ /// If is .
+ public ConsoleApiArgument(string type, string? value)
+ {
+ Type = type ?? throw new ArgumentNullException(nameof(type));
+ Value = value;
+ }
+
///
/// Gets the type of the argument in the call to the browser's console API.
///
- public string Type { get; internal set; }
+ public string Type { get; }
///
/// Gets the value of the argument in the call to the browser's console API.
///
- public string Value { get; internal set; }
+ public string? Value { get; }
}
}
diff --git a/dotnet/src/webdriver/DevTools/ConsoleApiCalledEventArgs.cs b/dotnet/src/webdriver/DevTools/ConsoleApiCalledEventArgs.cs
index 0295fb30e9dee..0c702fe22b558 100644
--- a/dotnet/src/webdriver/DevTools/ConsoleApiCalledEventArgs.cs
+++ b/dotnet/src/webdriver/DevTools/ConsoleApiCalledEventArgs.cs
@@ -20,6 +20,8 @@
using System;
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium.DevTools
{
///
@@ -27,19 +29,33 @@ namespace OpenQA.Selenium.DevTools
///
public class ConsoleApiCalledEventArgs : EventArgs
{
+ ///
+ /// Initializes a new instance of the type.
+ ///
+ /// The time stanp when the browser's console API is called.
+ /// The type of message when the browser's console API is called.
+ /// The arguments of the call to the browser's console API.
+ /// If is .
+ public ConsoleApiCalledEventArgs(DateTime timestamp, string type, ReadOnlyCollection arguments)
+ {
+ Timestamp = timestamp;
+ Type = type;
+ Arguments = arguments ?? throw new ArgumentNullException(nameof(arguments));
+ }
+
///
/// Gets the time stanp when the browser's console API is called.
///
- public DateTime Timestamp { get; internal set; }
+ public DateTime Timestamp { get; }
///
/// Gets the type of message when the browser's console API is called.
///
- public string Type { get; internal set; }
+ public string Type { get; }
///
/// Gets the arguments of the call to the browser's console API.
///
- public ReadOnlyCollection Arguments { get; internal set; }
+ public ReadOnlyCollection Arguments { get; }
}
}
diff --git a/dotnet/src/webdriver/DevTools/DevToolsCommandData.cs b/dotnet/src/webdriver/DevTools/DevToolsCommandData.cs
index bee0765169061..95e665fb634a3 100644
--- a/dotnet/src/webdriver/DevTools/DevToolsCommandData.cs
+++ b/dotnet/src/webdriver/DevTools/DevToolsCommandData.cs
@@ -17,11 +17,14 @@
// under the License.
//
+using System;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Threading;
+#nullable enable
+
namespace OpenQA.Selenium.DevTools
{
///
@@ -35,6 +38,7 @@ public class DevToolsCommandData
/// The ID of the commmand execution.
/// The method name of the DevTools command.
/// The parameters of the DevTools command.
+ /// If is .
public DevToolsCommandData(long commandId, string commandName, JsonNode commandParameters)
: this(commandId, null, commandName, commandParameters)
{
@@ -47,11 +51,12 @@ public DevToolsCommandData(long commandId, string commandName, JsonNode commandP
/// The session ID of the current command execution.
/// The method name of the DevTools command.
/// The parameters of the DevTools command.
- public DevToolsCommandData(long commandId, string sessionId, string commandName, JsonNode commandParameters)
+ /// If is .
+ public DevToolsCommandData(long commandId, string? sessionId, string commandName, JsonNode commandParameters)
{
CommandId = commandId;
SessionId = sessionId;
- CommandName = commandName;
+ CommandName = commandName ?? throw new ArgumentNullException(nameof(commandName));
CommandParameters = commandParameters;
SyncEvent = new ManualResetEventSlim(false);
}
@@ -61,7 +66,7 @@ public DevToolsCommandData(long commandId, string sessionId, string commandName,
///
[JsonPropertyName("sessionId")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string SessionId { get; }
+ public string? SessionId { get; }
///
/// Gets the numeric ID of the command execution.
diff --git a/dotnet/src/webdriver/DevTools/DevToolsEventData.cs b/dotnet/src/webdriver/DevTools/DevToolsEventData.cs
index 1c527fb34f854..89cf25fec0624 100644
--- a/dotnet/src/webdriver/DevTools/DevToolsEventData.cs
+++ b/dotnet/src/webdriver/DevTools/DevToolsEventData.cs
@@ -19,6 +19,8 @@
using System;
+#nullable enable
+
namespace OpenQA.Selenium.DevTools
{
///
@@ -31,10 +33,11 @@ public class DevToolsEventData
///
/// The type of the event args for the event to be raised.
/// The method that will be used to invoke the event.
+ /// If or is .
public DevToolsEventData(Type eventArgsType, Action