Skip to content

[dotnet] [bidi] Make BytesValue not nested #15433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
[JsonSerializable(typeof(Modules.BrowsingContext.UserPromptClosedEventArgs))]
[JsonSerializable(typeof(Modules.BrowsingContext.Origin), TypeInfoPropertyName = "BrowsingContext_Origin")]

[JsonSerializable(typeof(Modules.Network.BytesValue.String), TypeInfoPropertyName = "Network_BytesValue_String")]
[JsonSerializable(typeof(Modules.Network.ContinueWithAuthParameters.Default), TypeInfoPropertyName = "Network_ContinueWithAuthParameters_Default")]
[JsonSerializable(typeof(Modules.Network.AddInterceptCommand))]
[JsonSerializable(typeof(Modules.Network.AddInterceptResult))]
Expand Down
12 changes: 6 additions & 6 deletions dotnet/src/webdriver/BiDi/Modules/Network/BytesValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
namespace OpenQA.Selenium.BiDi.Modules.Network;

[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
[JsonDerivedType(typeof(String), "string")]
[JsonDerivedType(typeof(Base64), "base64")]
[JsonDerivedType(typeof(StringBytesValue), "string")]
[JsonDerivedType(typeof(Base64BytesValue), "base64")]
public abstract record BytesValue
{
public static implicit operator BytesValue(string value) => new String(value);
public static implicit operator BytesValue(string value) => new StringBytesValue(value);
}

public record String(string Value) : BytesValue;
public record StringBytesValue(string Value) : BytesValue;

public record Base64(string Value) : BytesValue;
}
public record Base64BytesValue(string Value) : BytesValue;
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Network/NetworkEventsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public async Task CanListenToBeforeRequestSentEventWithCookie()

Assert.That(req.Request.Cookies, Has.Count.EqualTo(1));
Assert.That(req.Request.Cookies[0].Name, Is.EqualTo("foo"));
Assert.That((req.Request.Cookies[0].Value as BytesValue.String).Value, Is.EqualTo("bar"));
Assert.That((req.Request.Cookies[0].Value as StringBytesValue).Value, Is.EqualTo("bar"));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion dotnet/test/common/BiDi/Storage/StorageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ await context.Storage.SetCookieAsync(new("fish", "cod", UrlBuilder.HostName)
var cookie = cookies[0];

Assert.That(cookie.Name, Is.EqualTo("fish"));
Assert.That((cookie.Value as BytesValue.String).Value, Is.EqualTo("cod"));
Assert.That((cookie.Value as StringBytesValue).Value, Is.EqualTo("cod"));
Assert.That(cookie.Path, Is.EqualTo("/common/animals"));
Assert.That(cookie.HttpOnly, Is.True);
Assert.That(cookie.Secure, Is.False);
Expand Down
Loading