Skip to content

Commit 3efcdd7

Browse files
committed
[dotnet] [bidi] Make ClipRectangle as not nested
1 parent d7a011c commit 3efcdd7

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,13 @@ public record struct ImageFormat(string Type)
4848
}
4949

5050
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
51-
[JsonDerivedType(typeof(Box), "box")]
52-
[JsonDerivedType(typeof(Element), "element")]
53-
public abstract record ClipRectangle
54-
{
55-
public record Box(double X, double Y, double Width, double Height) : ClipRectangle;
51+
[JsonDerivedType(typeof(BoxClipRectangle), "box")]
52+
[JsonDerivedType(typeof(ElementClipRectangle), "element")]
53+
public abstract record ClipRectangle;
5654

57-
public record Element([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : ClipRectangle;
58-
}
55+
public record BoxClipRectangle(double X, double Y, double Width, double Height) : ClipRectangle;
56+
57+
public record ElementClipRectangle([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : ClipRectangle;
5958

6059
public record CaptureScreenshotResult(string Data)
6160
{

dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public async Task CanCaptureScreenshotWithParameters()
260260
var screenshot = await context.CaptureScreenshotAsync(new()
261261
{
262262
Origin = Origin.Document,
263-
Clip = new ClipRectangle.Box(5, 5, 10, 10)
263+
Clip = new BoxClipRectangle(5, 5, 10, 10)
264264
});
265265

266266
Assert.That(screenshot, Is.Not.Null);
@@ -273,7 +273,7 @@ public async Task CanCaptureScreenshotOfViewport()
273273
var screenshot = await context.CaptureScreenshotAsync(new()
274274
{
275275
Origin = Origin.Viewport,
276-
Clip = new ClipRectangle.Box(5, 5, 10, 10)
276+
Clip = new BoxClipRectangle(5, 5, 10, 10)
277277
});
278278

279279
Assert.That(screenshot, Is.Not.Null);
@@ -289,7 +289,7 @@ public async Task CanCaptureScreenshotOfElement()
289289

290290
var screenshot = await context.CaptureScreenshotAsync(new()
291291
{
292-
Clip = new ClipRectangle.Element(nodes[0])
292+
Clip = new ElementClipRectangle(nodes[0])
293293
});
294294

295295
Assert.That(screenshot, Is.Not.Null);

0 commit comments

Comments
 (0)