Skip to content

Commit 6d26762

Browse files
authored
[dotnet] [bidi] Make BytesValue not nested (#15433)
1 parent 48d426b commit 6d26762

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
121121
[JsonSerializable(typeof(Modules.BrowsingContext.UserPromptClosedEventArgs))]
122122
[JsonSerializable(typeof(Modules.BrowsingContext.Origin), TypeInfoPropertyName = "BrowsingContext_Origin")]
123123

124-
[JsonSerializable(typeof(Modules.Network.BytesValue.String), TypeInfoPropertyName = "Network_BytesValue_String")]
125124
[JsonSerializable(typeof(Modules.Network.ContinueWithAuthParameters.Default), TypeInfoPropertyName = "Network_ContinueWithAuthParameters_Default")]
126125
[JsonSerializable(typeof(Modules.Network.AddInterceptCommand))]
127126
[JsonSerializable(typeof(Modules.Network.AddInterceptResult))]

dotnet/src/webdriver/BiDi/Modules/Network/BytesValue.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
namespace OpenQA.Selenium.BiDi.Modules.Network;
2323

2424
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
25-
[JsonDerivedType(typeof(String), "string")]
26-
[JsonDerivedType(typeof(Base64), "base64")]
25+
[JsonDerivedType(typeof(StringBytesValue), "string")]
26+
[JsonDerivedType(typeof(Base64BytesValue), "base64")]
2727
public abstract record BytesValue
2828
{
29-
public static implicit operator BytesValue(string value) => new String(value);
29+
public static implicit operator BytesValue(string value) => new StringBytesValue(value);
30+
}
3031

31-
public record String(string Value) : BytesValue;
32+
public record StringBytesValue(string Value) : BytesValue;
3233

33-
public record Base64(string Value) : BytesValue;
34-
}
34+
public record Base64BytesValue(string Value) : BytesValue;

dotnet/test/common/BiDi/Network/NetworkEventsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public async Task CanListenToBeforeRequestSentEventWithCookie()
101101

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

107107
[Test]

dotnet/test/common/BiDi/Storage/StorageTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ await context.Storage.SetCookieAsync(new("fish", "cod", UrlBuilder.HostName)
9999
var cookie = cookies[0];
100100

101101
Assert.That(cookie.Name, Is.EqualTo("fish"));
102-
Assert.That((cookie.Value as BytesValue.String).Value, Is.EqualTo("cod"));
102+
Assert.That((cookie.Value as StringBytesValue).Value, Is.EqualTo("cod"));
103103
Assert.That(cookie.Path, Is.EqualTo("/common/animals"));
104104
Assert.That(cookie.HttpOnly, Is.True);
105105
Assert.That(cookie.Secure, Is.False);

0 commit comments

Comments
 (0)