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] Annotate nullability on Log protocol #15239

Merged
merged 1 commit into from
Feb 6, 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
4 changes: 3 additions & 1 deletion dotnet/src/webdriver/DevTools/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
using System;
using System.Threading.Tasks;

#nullable enable

namespace OpenQA.Selenium.DevTools
{
/// <summary>
Expand All @@ -30,7 +32,7 @@ public abstract class Log
/// <summary>
/// Occurs when an entry is added to the browser's log.
/// </summary>
public event EventHandler<EntryAddedEventArgs> EntryAdded;
public event EventHandler<EntryAddedEventArgs>? EntryAdded;

/// <summary>
/// Asynchronously enables manipulation of the browser's log.
Expand Down
14 changes: 9 additions & 5 deletions dotnet/src/webdriver/DevTools/v130/V130Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,28 @@
// </copyright>

using OpenQA.Selenium.DevTools.V130.Log;
using System;
using System.Threading.Tasks;

#nullable enable

namespace OpenQA.Selenium.DevTools.V130
{
/// <summary>
/// Class containing the browser's log as referenced by version 130 of the DevTools Protocol.
/// </summary>
public class V130Log : DevTools.Log
{
private LogAdapter adapter;
private readonly LogAdapter adapter;

/// <summary>
/// Initializes a new instance of the <see cref="V130Log"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Log domain.</param>
/// <exception cref="ArgumentNullException">If <paramref name="adapter"/> is <see langword="null"/>.</exception>
public V130Log(LogAdapter adapter)
{
this.adapter = adapter;
this.adapter = adapter ?? throw new ArgumentNullException(nameof(adapter));
this.adapter.EntryAdded += OnAdapterEntryAdded;
}

Expand Down Expand Up @@ -66,14 +70,14 @@ public override async Task Clear()
await adapter.Clear().ConfigureAwait(false);
}

private void OnAdapterEntryAdded(object sender, Log.EntryAddedEventArgs e)
private void OnAdapterEntryAdded(object? sender, Log.EntryAddedEventArgs e)
{
var entry = new LogEntry(
kind: e.Entry.Source.ToString(),
message: e.Entry.Text
);
EntryAddedEventArgs propagated = new EntryAddedEventArgs(entry);
this.OnEntryAdded(propagated);

this.OnEntryAdded(new EntryAddedEventArgs(entry));
}
}
}
14 changes: 9 additions & 5 deletions dotnet/src/webdriver/DevTools/v131/V131Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,28 @@
// </copyright>

using OpenQA.Selenium.DevTools.V131.Log;
using System;
using System.Threading.Tasks;

#nullable enable

namespace OpenQA.Selenium.DevTools.V131
{
/// <summary>
/// Class containing the browser's log as referenced by version 131 of the DevTools Protocol.
/// </summary>
public class V131Log : DevTools.Log
{
private LogAdapter adapter;
private readonly LogAdapter adapter;

/// <summary>
/// Initializes a new instance of the <see cref="V131Log"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Log domain.</param>
/// <exception cref="ArgumentNullException">If <paramref name="adapter"/> is <see langword="null"/>.</exception>
public V131Log(LogAdapter adapter)
{
this.adapter = adapter;
this.adapter = adapter ?? throw new ArgumentNullException(nameof(adapter));
this.adapter.EntryAdded += OnAdapterEntryAdded;
}

Expand Down Expand Up @@ -66,14 +70,14 @@ public override async Task Clear()
await adapter.Clear().ConfigureAwait(false);
}

private void OnAdapterEntryAdded(object sender, Log.EntryAddedEventArgs e)
private void OnAdapterEntryAdded(object? sender, Log.EntryAddedEventArgs e)
{
var entry = new LogEntry(
kind: e.Entry.Source.ToString(),
message: e.Entry.Text
);
EntryAddedEventArgs propagated = new EntryAddedEventArgs(entry);
this.OnEntryAdded(propagated);

this.OnEntryAdded(new EntryAddedEventArgs(entry));
}
}
}
12 changes: 8 additions & 4 deletions dotnet/src/webdriver/DevTools/v132/V132Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
// </copyright>

using OpenQA.Selenium.DevTools.V132.Log;
using System;
using System.Threading.Tasks;

#nullable enable

namespace OpenQA.Selenium.DevTools.V132
{
/// <summary>
Expand All @@ -33,9 +36,10 @@ public class V132Log : DevTools.Log
/// Initializes a new instance of the <see cref="V132Log"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Log domain.</param>
/// <exception cref="ArgumentNullException">If <paramref name="adapter"/> is <see langword="null"/>.</exception>
public V132Log(LogAdapter adapter)
{
this.adapter = adapter;
this.adapter = adapter ?? throw new ArgumentNullException(nameof(adapter));
this.adapter.EntryAdded += OnAdapterEntryAdded;
}

Expand Down Expand Up @@ -66,14 +70,14 @@ public override async Task Clear()
await adapter.Clear().ConfigureAwait(false);
}

private void OnAdapterEntryAdded(object sender, Log.EntryAddedEventArgs e)
private void OnAdapterEntryAdded(object? sender, Log.EntryAddedEventArgs e)
{
var entry = new LogEntry(
kind: e.Entry.Source.ToString(),
message: e.Entry.Text
);
EntryAddedEventArgs propagated = new EntryAddedEventArgs(entry);
this.OnEntryAdded(propagated);

this.OnEntryAdded(new EntryAddedEventArgs(entry));
}
}
}
12 changes: 8 additions & 4 deletions dotnet/src/webdriver/DevTools/v85/V85Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,25 @@
// </copyright>

using OpenQA.Selenium.DevTools.V85.Log;
using System;
using System.Threading.Tasks;

#nullable enable

namespace OpenQA.Selenium.DevTools.V85
{
/// <summary>
/// Class containing the browser's log as referenced by version 86 of the DevTools Protocol.
/// </summary>
public class V85Log : DevTools.Log
{
private LogAdapter adapter;
private readonly LogAdapter adapter;

/// <summary>
/// Initializes a new instance of the <see cref="V85Log"/> class.
/// </summary>
/// <param name="adapter">The adapter for the Log domain.</param>
/// <exception cref="ArgumentNullException">If <paramref name="adapter"/> is <see langword="null"/>.</exception>
public V85Log(LogAdapter adapter)
{
this.adapter = adapter;
Expand Down Expand Up @@ -66,14 +70,14 @@ public override async Task Clear()
await adapter.Clear().ConfigureAwait(false);
}

private void OnAdapterEntryAdded(object sender, Log.EntryAddedEventArgs e)
private void OnAdapterEntryAdded(object? sender, Log.EntryAddedEventArgs e)
{
var entry = new LogEntry(
kind: e.Entry.Source.ToString(),
message: e.Entry.Text
);
EntryAddedEventArgs propagated = new EntryAddedEventArgs(entry);
this.OnEntryAdded(propagated);

this.OnEntryAdded(new EntryAddedEventArgs(entry));
}
}
}
Loading