File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
dotnet/src/webdriver/BiDi/Network Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -30,12 +30,15 @@ public abstract record BytesValue
3030 public static implicit operator BytesValue ( string value ) => new StringBytesValue ( value ) ;
3131 public static implicit operator BytesValue ( byte [ ] value ) => new Base64BytesValue ( Convert . ToBase64String ( value ) ) ;
3232
33- public static explicit operator string ( BytesValue value ) => value switch
33+ public static explicit operator string ( BytesValue value )
3434 {
35- StringBytesValue stringBytesValue => stringBytesValue . Value ,
36- Base64BytesValue base64BytesValue => System . Text . Encoding . UTF8 . GetString ( Convert . FromBase64String ( base64BytesValue . Value ) ) ,
37- _ => throw new InvalidCastException ( $ "Cannot cast '{ value . GetType ( ) } ' to '{ typeof ( string ) } '.")
38- } ;
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+ }
3942}
4043
4144public sealed record StringBytesValue ( string Value ) : BytesValue ;
You can’t perform that action at this time.
0 commit comments