Skip to content

Commit 9d35b40

Browse files
committed
Return back explicit conversion to string
1 parent eeae5a8 commit 9d35b40

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ public abstract record BytesValue
2929
{
3030
public static implicit operator BytesValue(string value) => new StringBytesValue(value);
3131
public static implicit operator BytesValue(byte[] value) => new Base64BytesValue(value);
32+
33+
public static explicit operator string(BytesValue value)
34+
{
35+
if (value is StringBytesValue stringBytesValue)
36+
{
37+
return stringBytesValue.Value;
38+
}
39+
40+
throw new InvalidCastException($"Cannot cast '{value.GetType()}' to '{typeof(string)}'.");
41+
}
3242
}
3343

3444
public sealed record StringBytesValue(string Value) : BytesValue;

0 commit comments

Comments
 (0)