Skip to content

Commit dbe8e0b

Browse files
committed
Remove CoreModule
1 parent 9a26d1e commit dbe8e0b

File tree

11 files changed

+105
-49
lines changed

11 files changed

+105
-49
lines changed

dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json;
22+
using System.Text.Json;
23+
using System.Text.Json.Serialization;
2124
using System.Threading.Tasks;
2225

2326
namespace OpenQA.Selenium.BiDi.Browser;
2427

25-
public sealed class BrowserModule : CoreModule
28+
public sealed class BrowserModule : Module
2629
{
30+
internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext;
31+
2732
public async Task<CloseResult> CloseAsync(CloseOptions? options = null)
2833
{
2934
return await Broker.ExecuteCommandAsync(new CloseCommand(), options, JsonContext.Browser_CloseCommand, JsonContext.Browser_CloseResult).ConfigureAwait(false);
@@ -74,4 +79,8 @@ public async Task<SetDownloadBehaviorResult> SetDownloadBehaviorDeniedAsync(SetD
7479

7580
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.SetDownloadBehaviorResult).ConfigureAwait(false);
7681
}
82+
protected override JsonSerializerContext Initialize(JsonSerializerOptions options)
83+
{
84+
return new BiDiJsonSerializerContext(options);
85+
}
7786
}

dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json;
2022
using System;
23+
using System.Text.Json;
24+
using System.Text.Json.Serialization;
2125
using System.Threading.Tasks;
22-
using OpenQA.Selenium.BiDi.Communication;
2326

2427
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2528

26-
public sealed class BrowsingContextModule : CoreModule
29+
public sealed class BrowsingContextModule : Module
2730
{
31+
internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext;
32+
2833
public async Task<CreateResult> CreateAsync(ContextType type, CreateOptions? options = null)
2934
{
3035
var @params = new CreateParameters(type, options?.ReferenceContext, options?.Background, options?.UserContext);
@@ -248,4 +253,8 @@ public async Task<Subscription> OnUserPromptClosedAsync(Action<UserPromptClosedE
248253
{
249254
return await Broker.SubscribeAsync("browsingContext.userPromptClosed", handler, options, JsonContext.UserPromptClosedEventArgs).ConfigureAwait(false);
250255
}
256+
protected override JsonSerializerContext Initialize(JsonSerializerOptions options)
257+
{
258+
return new BiDiJsonSerializerContext(options);
259+
}
251260
}

dotnet/src/webdriver/BiDi/CoreModule.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

dotnet/src/webdriver/BiDi/Emulation/EmulationModule.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@
1717
// under the License.
1818
// </copyright>
1919

20-
using System.Threading.Tasks;
2120
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json;
22+
using System.Text.Json;
23+
using System.Text.Json.Serialization;
24+
using System.Threading.Tasks;
2225

2326
namespace OpenQA.Selenium.BiDi.Emulation;
2427

25-
public sealed class EmulationModule : CoreModule
28+
public sealed class EmulationModule : Module
2629
{
30+
internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext;
31+
2732
public async Task<SetTimezoneOverrideResult> SetTimezoneOverrideAsync(string? timezone, SetTimezoneOverrideOptions? options = null)
2833
{
2934
var @params = new SetTimezoneOverrideParameters(timezone, options?.Contexts, options?.UserContexts);
@@ -88,4 +93,8 @@ public async Task<SetGeolocationOverrideResult> SetGeolocationPositionErrorOverr
8893

8994
return await Broker.ExecuteCommandAsync(new SetGeolocationOverrideCommand(@params), options, JsonContext.SetGeolocationOverrideCommand, JsonContext.SetGeolocationOverrideResult).ConfigureAwait(false);
9095
}
96+
protected override JsonSerializerContext Initialize(JsonSerializerOptions options)
97+
{
98+
return new BiDiJsonSerializerContext(options);
99+
}
91100
}

dotnet/src/webdriver/BiDi/Input/InputModule.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json;
2122
using System.Collections.Generic;
23+
using System.Text.Json;
24+
using System.Text.Json.Serialization;
2225
using System.Threading.Tasks;
2326

2427
namespace OpenQA.Selenium.BiDi.Input;
2528

26-
public sealed class InputModule : CoreModule
29+
public sealed class InputModule : Module
2730
{
31+
internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext;
32+
2833
public async Task<PerformActionsResult> PerformActionsAsync(BrowsingContext.BrowsingContext context, IEnumerable<SourceActions> actions, PerformActionsOptions? options = null)
2934
{
3035
var @params = new PerformActionsParameters(context, actions);
@@ -45,4 +50,8 @@ public async Task<SetFilesResult> SetFilesAsync(BrowsingContext.BrowsingContext
4550

4651
return await Broker.ExecuteCommandAsync(new SetFilesCommand(@params), options, JsonContext.SetFilesCommand, JsonContext.SetFilesResult).ConfigureAwait(false);
4752
}
53+
protected override JsonSerializerContext Initialize(JsonSerializerOptions options)
54+
{
55+
return new BiDiJsonSerializerContext(options);
56+
}
4857
}

dotnet/src/webdriver/BiDi/Log/LogModule.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@
1717
// under the License.
1818
// </copyright>
1919

20-
using System.Threading.Tasks;
21-
using System;
2220
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json;
22+
using System;
23+
using System.Text.Json;
24+
using System.Text.Json.Serialization;
25+
using System.Threading.Tasks;
2326

2427
namespace OpenQA.Selenium.BiDi.Log;
2528

26-
public sealed class LogModule : CoreModule
29+
public sealed class LogModule : Module
2730
{
31+
internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext;
32+
2833
public async Task<Subscription> OnEntryAddedAsync(Func<LogEntry, Task> handler, SubscriptionOptions? options = null)
2934
{
3035
return await Broker.SubscribeAsync("log.entryAdded", handler, options, JsonContext.LogEntry).ConfigureAwait(false);
@@ -34,4 +39,8 @@ public async Task<Subscription> OnEntryAddedAsync(Action<LogEntry> handler, Subs
3439
{
3540
return await Broker.SubscribeAsync("log.entryAdded", handler, options, JsonContext.LogEntry).ConfigureAwait(false);
3641
}
42+
protected override JsonSerializerContext Initialize(JsonSerializerOptions options)
43+
{
44+
return new BiDiJsonSerializerContext(options);
45+
}
3746
}

dotnet/src/webdriver/BiDi/Network/NetworkModule.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json;
2022
using System;
2123
using System.Collections.Generic;
24+
using System.Text.Json;
25+
using System.Text.Json.Serialization;
2226
using System.Threading.Tasks;
23-
using OpenQA.Selenium.BiDi.Communication;
2427

2528
namespace OpenQA.Selenium.BiDi.Network;
2629

27-
public sealed partial class NetworkModule : CoreModule
30+
public sealed partial class NetworkModule : Module
2831
{
32+
internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext;
33+
2934
public async Task<Collector> AddDataCollectorAsync(IEnumerable<DataType> DataTypes, int MaxEncodedDataSize, AddDataCollectorOptions? options = null)
3035
{
3136
var @params = new AddDataCollectorParameters(DataTypes, MaxEncodedDataSize, options?.CollectorType, options?.Contexts, options?.UserContexts);
@@ -173,4 +178,8 @@ public async Task<Subscription> OnAuthRequiredAsync(Action<AuthRequiredEventArgs
173178
{
174179
return await Broker.SubscribeAsync("network.authRequired", handler, options, JsonContext.AuthRequiredEventArgs).ConfigureAwait(false);
175180
}
181+
protected override JsonSerializerContext Initialize(JsonSerializerOptions options)
182+
{
183+
return new BiDiJsonSerializerContext(options);
184+
}
176185
}

dotnet/src/webdriver/BiDi/Script/ScriptModule.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,19 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json;
2122
using System;
2223
using System.Collections.Generic;
24+
using System.Text.Json;
25+
using System.Text.Json.Serialization;
2326
using System.Threading.Tasks;
2427

2528
namespace OpenQA.Selenium.BiDi.Script;
2629

27-
public sealed class ScriptModule : CoreModule
30+
public sealed class ScriptModule : Module
2831
{
32+
internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext;
33+
2934
public async Task<EvaluateResult> EvaluateAsync(string expression, bool awaitPromise, Target target, EvaluateOptions? options = null)
3035
{
3136
var @params = new EvaluateParameters(expression, target, awaitPromise, options?.ResultOwnership, options?.SerializationOptions, options?.UserActivation);
@@ -111,4 +116,8 @@ public async Task<Subscription> OnRealmDestroyedAsync(Action<RealmDestroyedEvent
111116
{
112117
return await Broker.SubscribeAsync("script.realmDestroyed", handler, options, JsonContext.RealmDestroyedEventArgs).ConfigureAwait(false);
113118
}
119+
protected override JsonSerializerContext Initialize(JsonSerializerOptions options)
120+
{
121+
return new BiDiJsonSerializerContext(options);
122+
}
114123
}

dotnet/src/webdriver/BiDi/Session/SessionModule.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json;
2122
using System.Collections.Generic;
23+
using System.Text.Json;
24+
using System.Text.Json.Serialization;
2225
using System.Threading.Tasks;
2326

2427
namespace OpenQA.Selenium.BiDi.Session;
2528

26-
internal sealed class SessionModule : CoreModule
29+
internal sealed class SessionModule : Module
2730
{
31+
internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext;
32+
2833
public async Task<StatusResult> StatusAsync(StatusOptions? options = null)
2934
{
3035
return await Broker.ExecuteCommandAsync(new StatusCommand(), options, JsonContext.StatusCommand, JsonContext.StatusResult).ConfigureAwait(false);
@@ -55,4 +60,8 @@ public async Task<EndResult> EndAsync(EndOptions? options = null)
5560
{
5661
return await Broker.ExecuteCommandAsync(new EndCommand(), options, JsonContext.EndCommand, JsonContext.EndResult).ConfigureAwait(false);
5762
}
63+
protected override JsonSerializerContext Initialize(JsonSerializerOptions options)
64+
{
65+
return new BiDiJsonSerializerContext(options);
66+
}
5867
}

dotnet/src/webdriver/BiDi/Storage/StorageModule.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json;
22+
using System.Text.Json;
23+
using System.Text.Json.Serialization;
2124
using System.Threading.Tasks;
2225

2326
namespace OpenQA.Selenium.BiDi.Storage;
2427

25-
public sealed class StorageModule : CoreModule
28+
public sealed class StorageModule : Module
2629
{
30+
internal new BiDiJsonSerializerContext JsonContext => (BiDiJsonSerializerContext)base.JsonContext;
31+
2732
public async Task<GetCookiesResult> GetCookiesAsync(GetCookiesOptions? options = null)
2833
{
2934
var @params = new GetCookiesParameters(options?.Filter, options?.Partition);
@@ -44,4 +49,8 @@ public async Task<SetCookieResult> SetCookieAsync(PartialCookie cookie, SetCooki
4449

4550
return await Broker.ExecuteCommandAsync(new SetCookieCommand(@params), options, JsonContext.SetCookieCommand, JsonContext.SetCookieResult).ConfigureAwait(false);
4651
}
52+
protected override JsonSerializerContext Initialize(JsonSerializerOptions options)
53+
{
54+
return new BiDiJsonSerializerContext(options);
55+
}
4756
}

0 commit comments

Comments
 (0)