Skip to content
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] Add nullability annotations to devtools domains #15143

Merged
merged 4 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/DevTools/DevToolsExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// under the License.
// </copyright>

#nullable enable

namespace OpenQA.Selenium.DevTools
{
/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/DevTools/DevToolsOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
// under the License.
// </copyright>

#nullable enable

namespace OpenQA.Selenium.DevTools
{
/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions dotnet/src/webdriver/DevTools/DevToolsSessionDomains.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
// under the License.
// </copyright>

#nullable enable

namespace OpenQA.Selenium.DevTools
{
/// <summary>
/// Provides an abstract base class for version-specific domain implementations.
/// </summary>
public abstract class DevToolsSessionDomains
{
private CommandResponseTypeMap responseTypeMap = new CommandResponseTypeMap();

/// <summary>
/// Initializes a new instance of the <see cref="DevToolsSessionDomains"/> class.
/// </summary>
Expand All @@ -37,7 +37,7 @@ protected DevToolsSessionDomains()
/// <summary>
/// Gets the <see cref="CommandResponseTypeMap"/> containing information about the types returned by DevTools Protocol commands.,
/// </summary>
internal CommandResponseTypeMap ResponseTypeMap => this.responseTypeMap;
internal CommandResponseTypeMap ResponseTypeMap { get; } = new CommandResponseTypeMap();

/// <summary>
/// Populates the command response type map.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
using System.Text.Json;
using System.Text.Json.Nodes;

#nullable enable

namespace OpenQA.Selenium.DevTools
{
/// <summary>
Expand All @@ -44,16 +46,16 @@ public DevToolsEventReceivedEventArgs(string domainName, string eventName, JsonE
/// <summary>
/// Gets the domain on which the event is to be raised.
/// </summary>
public string DomainName { get; private set; }
public string DomainName { get; }

/// <summary>
/// Gets the name of the event to be raised.
/// </summary>
public string EventName { get; private set; }
public string EventName { get; }

/// <summary>
/// Gets the data with which the event is to be raised.
/// </summary>
public JsonElement EventData { get; private set; }
public JsonElement EventData { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

using System;

#nullable enable

namespace OpenQA.Selenium.DevTools
{
/// <summary>
Expand Down
17 changes: 15 additions & 2 deletions dotnet/src/webdriver/DevTools/ExceptionThrownEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,34 @@

using System;

#nullable enable

namespace OpenQA.Selenium.DevTools
{
/// <summary>
/// Provides data for events relating to JavaScript exception handling.
/// </summary>
public class ExceptionThrownEventArgs : EventArgs
{
/// <summary>
/// Initializes new instance of the <see cref="ExceptionThrownEventArgs"/> type.
/// </summary>
/// <param name="timestamp">The time stamp of the exception.</param>
/// <param name="message">The text of the exception.</param>
public ExceptionThrownEventArgs(DateTime timestamp, string message)
{
Timestamp = timestamp;
Message = message;
}

/// <summary>
/// Gets the time stamp of the exception.
/// </summary>
public DateTime Timestamp { get; internal set; }
public DateTime Timestamp { get; }

/// <summary>
/// Gets the text of the exception.
/// </summary>
public string Message { get; internal set; }
public string Message { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable enable

namespace OpenQA.Selenium.DevTools.Json
{
internal sealed class JsonEnumMemberConverter<TEnum> : JsonConverter<TEnum>
Expand Down Expand Up @@ -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))
{
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/DevTools/ResponsePausedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

using System;

#nullable enable

namespace OpenQA.Selenium.DevTools
{
/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions dotnet/src/webdriver/DevTools/v130/V130JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions dotnet/src/webdriver/DevTools/v131/V131JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions dotnet/src/webdriver/DevTools/v132/V132JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 5 additions & 5 deletions dotnet/src/webdriver/DevTools/v85/V85JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading