Skip to content

Commit ba6b7ed

Browse files
committed
Event args type safety
1 parent ea77d15 commit ba6b7ed

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

dotnet/src/webdriver/BiDi/Communication/Broker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public async Task<TResult> ExecuteCommandAsync<TCommand, TResult>(TCommand comma
156156
return (TResult)await tcs.Task.ConfigureAwait(false);
157157
}
158158

159-
public async Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, Action<TEventArgs> action, SubscriptionOptions? options, JsonTypeInfo jsonTypeInfo)
159+
public async Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, Action<TEventArgs> action, SubscriptionOptions? options, JsonTypeInfo<TEventArgs> jsonTypeInfo)
160160
where TEventArgs : EventArgs
161161
{
162162
_eventTypesMap[eventName] = jsonTypeInfo;
@@ -185,7 +185,7 @@ public async Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, Act
185185
}
186186
}
187187

188-
public async Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, Func<TEventArgs, Task> func, SubscriptionOptions? options, JsonTypeInfo jsonTypeInfo)
188+
public async Task<Subscription> SubscribeAsync<TEventArgs>(string eventName, Func<TEventArgs, Task> func, SubscriptionOptions? options, JsonTypeInfo<TEventArgs> jsonTypeInfo)
189189
where TEventArgs : EventArgs
190190
{
191191
_eventTypesMap[eventName] = jsonTypeInfo;

dotnet/src/webdriver/BiDi/Communication/EventHandler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@
2323

2424
namespace OpenQA.Selenium.BiDi.Communication;
2525

26-
public abstract class EventHandler(string eventName, Type eventArgsType, IEnumerable<BrowsingContext.BrowsingContext>? contexts = null)
26+
public abstract class EventHandler(string eventName, IEnumerable<BrowsingContext.BrowsingContext>? contexts = null)
2727
{
2828
public string EventName { get; } = eventName;
29-
public Type EventArgsType { get; set; } = eventArgsType;
29+
3030
public IEnumerable<BrowsingContext.BrowsingContext>? Contexts { get; } = contexts;
3131

3232
public abstract ValueTask InvokeAsync(object args);
3333
}
3434

3535
internal class AsyncEventHandler<TEventArgs>(string eventName, Func<TEventArgs, Task> func, IEnumerable<BrowsingContext.BrowsingContext>? contexts = null)
36-
: EventHandler(eventName, typeof(TEventArgs), contexts) where TEventArgs : EventArgs
36+
: EventHandler(eventName, contexts) where TEventArgs : EventArgs
3737
{
3838
private readonly Func<TEventArgs, Task> _func = func;
3939

@@ -44,7 +44,7 @@ public override async ValueTask InvokeAsync(object args)
4444
}
4545

4646
internal class SyncEventHandler<TEventArgs>(string eventName, Action<TEventArgs> action, IEnumerable<BrowsingContext.BrowsingContext>? contexts = null)
47-
: EventHandler(eventName, typeof(TEventArgs), contexts) where TEventArgs : EventArgs
47+
: EventHandler(eventName, contexts) where TEventArgs : EventArgs
4848
{
4949
private readonly Action<TEventArgs> _action = action;
5050

0 commit comments

Comments
 (0)