diff --git a/dotnet/src/webdriver/DevTools/DevToolsExtensionMethods.cs b/dotnet/src/webdriver/DevTools/DevToolsExtensionMethods.cs index 21711f1822b75..0471eee435529 100644 --- a/dotnet/src/webdriver/DevTools/DevToolsExtensionMethods.cs +++ b/dotnet/src/webdriver/DevTools/DevToolsExtensionMethods.cs @@ -17,6 +17,8 @@ // under the License. // +#nullable enable + namespace OpenQA.Selenium.DevTools { /// diff --git a/dotnet/src/webdriver/DevTools/DevToolsOptions.cs b/dotnet/src/webdriver/DevTools/DevToolsOptions.cs index e0b5f365261a7..e3222fba48315 100644 --- a/dotnet/src/webdriver/DevTools/DevToolsOptions.cs +++ b/dotnet/src/webdriver/DevTools/DevToolsOptions.cs @@ -17,6 +17,8 @@ // under the License. // +#nullable enable + namespace OpenQA.Selenium.DevTools { /// diff --git a/dotnet/src/webdriver/DevTools/DevToolsSessionDomains.cs b/dotnet/src/webdriver/DevTools/DevToolsSessionDomains.cs index 96d1521f92500..a7c6825e8a659 100644 --- a/dotnet/src/webdriver/DevTools/DevToolsSessionDomains.cs +++ b/dotnet/src/webdriver/DevTools/DevToolsSessionDomains.cs @@ -17,6 +17,8 @@ // under the License. // +#nullable enable + namespace OpenQA.Selenium.DevTools { /// @@ -24,8 +26,6 @@ namespace OpenQA.Selenium.DevTools /// public abstract class DevToolsSessionDomains { - private CommandResponseTypeMap responseTypeMap = new CommandResponseTypeMap(); - /// /// Initializes a new instance of the class. /// @@ -37,7 +37,7 @@ protected DevToolsSessionDomains() /// /// Gets the containing information about the types returned by DevTools Protocol commands., /// - internal CommandResponseTypeMap ResponseTypeMap => this.responseTypeMap; + internal CommandResponseTypeMap ResponseTypeMap { get; } = new CommandResponseTypeMap(); /// /// Populates the command response type map. diff --git a/dotnet/src/webdriver/DevTools/DevToolsSessionEventReceivedEventArgs.cs b/dotnet/src/webdriver/DevTools/DevToolsSessionEventReceivedEventArgs.cs index 4840c7a366a7f..80ce25cd78403 100644 --- a/dotnet/src/webdriver/DevTools/DevToolsSessionEventReceivedEventArgs.cs +++ b/dotnet/src/webdriver/DevTools/DevToolsSessionEventReceivedEventArgs.cs @@ -21,6 +21,8 @@ using System.Text.Json; using System.Text.Json.Nodes; +#nullable enable + namespace OpenQA.Selenium.DevTools { /// @@ -44,16 +46,16 @@ public DevToolsEventReceivedEventArgs(string domainName, string eventName, JsonE /// /// Gets the domain on which the event is to be raised. /// - public string DomainName { get; private set; } + public string DomainName { get; } /// /// Gets the name of the event to be raised. /// - public string EventName { get; private set; } + public string EventName { get; } /// /// Gets the data with which the event is to be raised. /// - public JsonElement EventData { get; private set; } + public JsonElement EventData { get; } } } diff --git a/dotnet/src/webdriver/DevTools/DevToolsSessionLogMessageEventArgs.cs b/dotnet/src/webdriver/DevTools/DevToolsSessionLogMessageEventArgs.cs index b3f0bd5ad9fd8..c2e233a695e2a 100644 --- a/dotnet/src/webdriver/DevTools/DevToolsSessionLogMessageEventArgs.cs +++ b/dotnet/src/webdriver/DevTools/DevToolsSessionLogMessageEventArgs.cs @@ -19,6 +19,8 @@ using System; +#nullable enable + namespace OpenQA.Selenium.DevTools { /// diff --git a/dotnet/src/webdriver/DevTools/ExceptionThrownEventArgs.cs b/dotnet/src/webdriver/DevTools/ExceptionThrownEventArgs.cs index dadd804a4de58..8c1d92211a539 100644 --- a/dotnet/src/webdriver/DevTools/ExceptionThrownEventArgs.cs +++ b/dotnet/src/webdriver/DevTools/ExceptionThrownEventArgs.cs @@ -19,6 +19,8 @@ using System; +#nullable enable + namespace OpenQA.Selenium.DevTools { /// @@ -26,14 +28,25 @@ namespace OpenQA.Selenium.DevTools /// public class ExceptionThrownEventArgs : EventArgs { + /// + /// Initializes new instance of the type. + /// + /// The time stamp of the exception. + /// The text of the exception. + public ExceptionThrownEventArgs(DateTime timestamp, string message) + { + Timestamp = timestamp; + Message = message; + } + /// /// Gets the time stamp of the exception. /// - public DateTime Timestamp { get; internal set; } + public DateTime Timestamp { get; } /// /// Gets the text of the exception. /// - public string Message { get; internal set; } + public string Message { get; } } } diff --git a/dotnet/src/webdriver/DevTools/Json/JsonEnumMemberConverter.cs b/dotnet/src/webdriver/DevTools/Json/JsonEnumMemberConverter.cs index 7d109f5801466..58d23db40579d 100644 --- a/dotnet/src/webdriver/DevTools/Json/JsonEnumMemberConverter.cs +++ b/dotnet/src/webdriver/DevTools/Json/JsonEnumMemberConverter.cs @@ -24,6 +24,8 @@ using System.Text.Json; using System.Text.Json.Serialization; +#nullable enable + namespace OpenQA.Selenium.DevTools.Json { internal sealed class JsonEnumMemberConverter : JsonConverter @@ -63,7 +65,7 @@ public JsonEnumMemberConverter() public override TEnum Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - var stringValue = reader.GetString(); + var stringValue = reader.GetString() ?? throw new JsonException("Could not read an enum string from \"null\""); if (_stringToEnum.TryGetValue(stringValue, out var enumValue)) { diff --git a/dotnet/src/webdriver/DevTools/ResponsePausedEventArgs.cs b/dotnet/src/webdriver/DevTools/ResponsePausedEventArgs.cs index 417a1e4b43680..a38ccc40ec285 100644 --- a/dotnet/src/webdriver/DevTools/ResponsePausedEventArgs.cs +++ b/dotnet/src/webdriver/DevTools/ResponsePausedEventArgs.cs @@ -19,6 +19,8 @@ using System; +#nullable enable + namespace OpenQA.Selenium.DevTools { /// diff --git a/dotnet/src/webdriver/DevTools/v130/V130JavaScript.cs b/dotnet/src/webdriver/DevTools/v130/V130JavaScript.cs index be462967b0f0b..3f5946ed51033 100644 --- a/dotnet/src/webdriver/DevTools/v130/V130JavaScript.cs +++ b/dotnet/src/webdriver/DevTools/v130/V130JavaScript.cs @@ -153,11 +153,11 @@ private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArg private void OnRuntimeExceptionThrown(object sender, Runtime.ExceptionThrownEventArgs e) { // TODO: Collect stack trace elements - var wrapped = new ExceptionThrownEventArgs() - { - Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp), - Message = e.ExceptionDetails.Text - }; + var wrapped = new ExceptionThrownEventArgs + ( + timestamp: new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp), + message: e.ExceptionDetails.Text + ); this.OnExceptionThrown(wrapped); } diff --git a/dotnet/src/webdriver/DevTools/v131/V131JavaScript.cs b/dotnet/src/webdriver/DevTools/v131/V131JavaScript.cs index 873c03cc5360b..d523202a85086 100644 --- a/dotnet/src/webdriver/DevTools/v131/V131JavaScript.cs +++ b/dotnet/src/webdriver/DevTools/v131/V131JavaScript.cs @@ -153,11 +153,11 @@ private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArg private void OnRuntimeExceptionThrown(object sender, Runtime.ExceptionThrownEventArgs e) { // TODO: Collect stack trace elements - var wrapped = new ExceptionThrownEventArgs() - { - Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp), - Message = e.ExceptionDetails.Text - }; + var wrapped = new ExceptionThrownEventArgs + ( + timestamp: new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp), + message: e.ExceptionDetails.Text + ); this.OnExceptionThrown(wrapped); } diff --git a/dotnet/src/webdriver/DevTools/v132/V132JavaScript.cs b/dotnet/src/webdriver/DevTools/v132/V132JavaScript.cs index 6e9a093d145dd..edbcdab9280a9 100644 --- a/dotnet/src/webdriver/DevTools/v132/V132JavaScript.cs +++ b/dotnet/src/webdriver/DevTools/v132/V132JavaScript.cs @@ -153,11 +153,11 @@ private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArg private void OnRuntimeExceptionThrown(object sender, Runtime.ExceptionThrownEventArgs e) { // TODO: Collect stack trace elements - var wrapped = new ExceptionThrownEventArgs() - { - Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp), - Message = e.ExceptionDetails.Text - }; + var wrapped = new ExceptionThrownEventArgs + ( + timestamp: new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp), + message: e.ExceptionDetails.Text + ); this.OnExceptionThrown(wrapped); } diff --git a/dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs b/dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs index 570d05ada0c67..7a9cfbab234c5 100644 --- a/dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs +++ b/dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs @@ -153,11 +153,11 @@ private void OnRuntimeBindingCalled(object sender, Runtime.BindingCalledEventArg private void OnRuntimeExceptionThrown(object sender, Runtime.ExceptionThrownEventArgs e) { // TODO: Collect stack trace elements - var wrapped = new ExceptionThrownEventArgs() - { - Timestamp = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp), - Message = e.ExceptionDetails.Text - }; + var wrapped = new ExceptionThrownEventArgs + ( + timestamp: new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds(e.Timestamp), + message: e.ExceptionDetails.Text + ); this.OnExceptionThrown(wrapped); }