Skip to content

Commit 04a927e

Browse files
[dotnet] Move JSON converter attributes from centralized options into their respective types (#16393)
1 parent 3b61afe commit 04a927e

20 files changed

+58
-26
lines changed

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

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

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
21+
using System.Text.Json.Serialization;
22+
2023
namespace OpenQA.Selenium.BiDi.Browser;
2124

25+
[JsonConverter(typeof(BrowserClientWindowConverter))]
2226
public sealed record ClientWindow
2327
{
2428
internal ClientWindow(string id)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
2122
using System.Collections;
2223
using System.Collections.Generic;
24+
using System.Text.Json.Serialization;
2325

2426
namespace OpenQA.Selenium.BiDi.Browser;
2527

@@ -28,6 +30,7 @@ internal sealed class GetClientWindowsCommand()
2830

2931
public sealed class GetClientWindowsOptions : CommandOptions;
3032

33+
[JsonConverter(typeof(GetClientWindowsResultConverter))]
3134
public sealed record GetClientWindowsResult : EmptyResult, IReadOnlyList<ClientWindowInfo>
3235
{
3336
internal GetClientWindowsResult(IReadOnlyList<ClientWindowInfo> clientWindows)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
2122
using System.Collections;
2223
using System.Collections.Generic;
24+
using System.Text.Json.Serialization;
2325

2426
namespace OpenQA.Selenium.BiDi.Browser;
2527

@@ -28,6 +30,7 @@ internal sealed class GetUserContextsCommand()
2830

2931
public class GetUserContextsOptions : CommandOptions;
3032

33+
[JsonConverter(typeof(GetUserContextsResultConverter))]
3134
public sealed record GetUserContextsResult : EmptyResult, IReadOnlyList<UserContextInfo>
3235
{
3336
internal GetUserContextsResult(IReadOnlyList<UserContextInfo> userContexts)

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

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

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Polymorphic;
2021
using System;
22+
using System.Text.Json.Serialization;
2123

2224
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2325

2426
// https://github.com/dotnet/runtime/issues/72604
2527
//[JsonPolymorphic(TypeDiscriminatorPropertyName = "status")]
2628
//[JsonDerivedType(typeof(DownloadCanceledEventArgs), "canceled")]
2729
//[JsonDerivedType(typeof(DownloadCompleteEventArgs), "complete")]
30+
[JsonConverter(typeof(DownloadEndEventArgsConverter))]
2831
public abstract record DownloadEndEventArgs(BiDi BiDi, BrowsingContext Context)
2932
: BrowsingContextEventArgs(BiDi, Context);
3033

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
2122
using System.Collections;
2223
using System.Collections.Generic;
24+
using System.Text.Json.Serialization;
2325

2426
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2527

@@ -47,6 +49,7 @@ public sealed record BrowsingContextGetTreeOptions
4749
public long? MaxDepth { get; set; }
4850
}
4951

52+
[JsonConverter(typeof(GetTreeResultConverter))]
5053
public sealed record GetTreeResult : EmptyResult, IReadOnlyList<BrowsingContextInfo>
5154
{
5255
internal GetTreeResult(IReadOnlyList<BrowsingContextInfo> contexts)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters.Enumerable;
2122
using System.Collections;
2223
using System.Collections.Generic;
24+
using System.Text.Json.Serialization;
2325

2426
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2527

@@ -37,6 +39,7 @@ public sealed class LocateNodesOptions : CommandOptions
3739
public IEnumerable<Script.ISharedReference>? StartNodes { get; set; }
3840
}
3941

42+
[JsonConverter(typeof(LocateNodesResultConverter))]
4043
public sealed record LocateNodesResult : EmptyResult, IReadOnlyList<Script.NodeRemoteValue>
4144
{
4245
internal LocateNodesResult(IReadOnlyList<Script.NodeRemoteValue> nodes)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
21+
using System.Text.Json.Serialization;
22+
2023
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2124

25+
[JsonConverter(typeof(NavigationConverter))]
2226
public sealed record Navigation(string Id);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public struct PrintPage
7272
public double? Width { get; set; }
7373
}
7474

75+
[JsonConverter(typeof(PrintPageRangeConverter))]
7576
public readonly record struct PrintPageRange(int? Start, int? End)
7677
{
7778
public static implicit operator PrintPageRange(int index) { return new PrintPageRange(index, index); }

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,39 +72,15 @@ internal Broker(BiDi bidi, Uri url)
7272
Converters =
7373
{
7474
new BrowsingContextConverter(_bidi),
75-
new BrowserUserContextConverter(bidi),
76-
new BrowserClientWindowConverter(),
77-
new NavigationConverter(),
75+
new BrowserUserContextConverter(_bidi),
7876
new CollectorConverter(_bidi),
7977
new InterceptConverter(_bidi),
80-
new RequestConverter(),
81-
new ChannelConverter(),
8278
new HandleConverter(_bidi),
8379
new InternalIdConverter(_bidi),
8480
new PreloadScriptConverter(_bidi),
8581
new RealmConverter(_bidi),
8682
new DateTimeOffsetConverter(),
87-
new PrintPageRangeConverter(),
88-
new InputOriginConverter(),
8983
new WebExtensionConverter(_bidi),
90-
new SubscriptionConverter(),
91-
92-
// https://github.com/dotnet/runtime/issues/72604
93-
new Json.Converters.Polymorphic.EvaluateResultConverter(),
94-
new Json.Converters.Polymorphic.RemoteValueConverter(),
95-
new Json.Converters.Polymorphic.RealmInfoConverter(),
96-
new Json.Converters.Polymorphic.LogEntryConverter(),
97-
new Json.Converters.Polymorphic.DownloadEndEventArgsConverter(),
98-
//
99-
100-
// Enumerable
101-
new Json.Converters.Enumerable.GetCookiesResultConverter(),
102-
new Json.Converters.Enumerable.LocateNodesResultConverter(),
103-
new Json.Converters.Enumerable.InputSourceActionsConverter(),
104-
new Json.Converters.Enumerable.GetUserContextsResultConverter(),
105-
new Json.Converters.Enumerable.GetClientWindowsResultConverter(),
106-
new Json.Converters.Enumerable.GetRealmsResultConverter(),
107-
new Json.Converters.Enumerable.GetTreeResultConverter(),
10884
}
10985
};
11086

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

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

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
21+
using System.Text.Json.Serialization;
22+
2023
namespace OpenQA.Selenium.BiDi.Input;
2124

25+
[JsonConverter(typeof(InputOriginConverter))]
2226
public abstract record Origin;
2327

2428
public sealed record ViewportOrigin() : Origin;

0 commit comments

Comments
 (0)