Skip to content

Commit acac7d4

Browse files
committed
Parametrize command results
1 parent 77adbf2 commit acac7d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+69
-64
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ protected Command(string method)
3535
public int Id { get; internal set; }
3636
}
3737

38-
internal abstract class Command<TCommandParameters>(TCommandParameters @params, string method) : Command(method)
38+
internal abstract class Command<TCommandParameters, TCommandResult>(TCommandParameters @params, string method) : Command(method)
3939
where TCommandParameters : CommandParameters
40+
where TCommandResult : EmptyResult
4041
{
4142
[JsonPropertyOrder(2)]
4243
public TCommandParameters Params { get; } = @params;
@@ -46,3 +47,5 @@ internal record CommandParameters
4647
{
4748
public static CommandParameters Empty { get; } = new CommandParameters();
4849
}
50+
51+
public record EmptyResult;

dotnet/src/webdriver/BiDi/Modules/Browser/CloseCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
namespace OpenQA.Selenium.BiDi.Modules.Browser;
2323

2424
internal class CloseCommand()
25-
: Command<CommandParameters>(CommandParameters.Empty, "browser.close");
25+
: Command<CommandParameters, EmptyResult>(CommandParameters.Empty, "browser.close");
2626

2727
public record CloseOptions : CommandOptions;

dotnet/src/webdriver/BiDi/Modules/Browser/CreateUserContextCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
namespace OpenQA.Selenium.BiDi.Modules.Browser;
2323

2424
internal class CreateUserContextCommand()
25-
: Command<CommandParameters>(CommandParameters.Empty, "browser.createUserContext");
25+
: Command<CommandParameters, UserContextInfo>(CommandParameters.Empty, "browser.createUserContext");
2626

2727
public record CreateUserContextOptions : CommandOptions;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
namespace OpenQA.Selenium.BiDi.Modules.Browser;
2525

2626
internal class GetClientWindowsCommand()
27-
: Command<CommandParameters>(CommandParameters.Empty, "browser.getClientWindows");
27+
: Command<CommandParameters, GetClientWindowsResult>(CommandParameters.Empty, "browser.getClientWindows");
2828

2929
public record GetClientWindowsOptions : CommandOptions;
3030

31-
public record GetClientWindowsResult : IReadOnlyList<ClientWindowInfo>
31+
public record GetClientWindowsResult : EmptyResult, IReadOnlyList<ClientWindowInfo>
3232
{
3333
private readonly IReadOnlyList<ClientWindowInfo> _clientWindows;
3434

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
namespace OpenQA.Selenium.BiDi.Modules.Browser;
2525

2626
internal class GetUserContextsCommand()
27-
: Command<CommandParameters>(CommandParameters.Empty, "browser.getUserContexts");
27+
: Command<CommandParameters, GetUserContextsResult>(CommandParameters.Empty, "browser.getUserContexts");
2828

2929
public record GetUserContextsOptions : CommandOptions;
3030

31-
public record GetUserContextsResult : IReadOnlyList<UserContextInfo>
31+
public record GetUserContextsResult : EmptyResult, IReadOnlyList<UserContextInfo>
3232
{
3333
private readonly IReadOnlyList<UserContextInfo> _userContexts;
3434

dotnet/src/webdriver/BiDi/Modules/Browser/RemoveUserContextCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace OpenQA.Selenium.BiDi.Modules.Browser;
2323

2424
internal class RemoveUserContextCommand(RemoveUserContextCommandParameters @params)
25-
: Command<RemoveUserContextCommandParameters>(@params, "browser.removeUserContext");
25+
: Command<RemoveUserContextCommandParameters, EmptyResult>(@params, "browser.removeUserContext");
2626

2727
internal record RemoveUserContextCommandParameters(UserContext UserContext) : CommandParameters;
2828

dotnet/src/webdriver/BiDi/Modules/Browser/UserContextInfo.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication;
21+
2022
namespace OpenQA.Selenium.BiDi.Modules.Browser;
2123

22-
public record UserContextInfo(UserContext UserContext);
24+
public record UserContextInfo(UserContext UserContext) : EmptyResult;

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/ActivateCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
2323

2424
internal class ActivateCommand(ActivateCommandParameters @params)
25-
: Command<ActivateCommandParameters>(@params, "browsingContext.activate");
25+
: Command<ActivateCommandParameters, EmptyResult>(@params, "browsingContext.activate");
2626

2727
internal record ActivateCommandParameters(BrowsingContext Context) : CommandParameters;
2828

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
2424

2525
internal class CaptureScreenshotCommand(CaptureScreenshotCommandParameters @params)
26-
: Command<CaptureScreenshotCommandParameters>(@params, "browsingContext.captureScreenshot");
26+
: Command<CaptureScreenshotCommandParameters, CaptureScreenshotResult>(@params, "browsingContext.captureScreenshot");
2727

2828
internal record CaptureScreenshotCommandParameters(BrowsingContext Context, ScreenshotOrigin? Origin, ImageFormat? Format, ClipRectangle? Clip) : CommandParameters;
2929

@@ -56,7 +56,7 @@ public record BoxClipRectangle(double X, double Y, double Width, double Height)
5656

5757
public record ElementClipRectangle([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : ClipRectangle;
5858

59-
public record CaptureScreenshotResult(string Data)
59+
public record CaptureScreenshotResult(string Data) : EmptyResult
6060
{
6161
public byte[] ToByteArray() => System.Convert.FromBase64String(Data);
6262
}

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CloseCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
2323

2424
internal class CloseCommand(CloseCommandParameters @params)
25-
: Command<CloseCommandParameters>(@params, "browsingContext.close");
25+
: Command<CloseCommandParameters, EmptyResult>(@params, "browsingContext.close");
2626

2727
internal record CloseCommandParameters(BrowsingContext Context, bool? PromptUnload) : CommandParameters;
2828

0 commit comments

Comments
 (0)