Skip to content

Commit 1e8b1dc

Browse files
committed
Win?
1 parent 40bfc5e commit 1e8b1dc

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

dotnet/src/webdriver/Command.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public string ParametersAsJsonString
101101
string parametersString = string.Empty;
102102
if (this.commandParameters != null && this.commandParameters.Count > 0)
103103
{
104-
parametersString = JsonSerializer.Serialize(this.commandParameters);
104+
parametersString = JsonSerializer.Serialize(new SerializableCommand() { Data = this.commandParameters }, CommandSerializerContext.Default.SerializableCommand);
105105
}
106106

107107
if (string.IsNullOrEmpty(parametersString))
@@ -133,4 +133,19 @@ private static Dictionary<string, object> ConvertParametersFromJson(string value
133133
return parameters;
134134
}
135135
}
136+
137+
internal class SerializableCommand
138+
{
139+
[JsonExtensionData]
140+
public Dictionary<string, object> Data { get; set; }
141+
}
142+
143+
[JsonSerializable(typeof(SerializableCommand))]
144+
145+
[JsonSerializable(typeof(IList<object>))]
146+
[JsonSerializable(typeof(System.Collections.ObjectModel.ReadOnlyCollection<string>))]
147+
internal partial class CommandSerializerContext : JsonSerializerContext
148+
{
149+
150+
}
136151
}

dotnet/src/webdriver/Response.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using System.Collections.Generic;
2222
using System.Globalization;
2323
using System.Text.Json;
24+
using System.Text.Json.Serialization;
2425

2526
namespace OpenQA.Selenium
2627
{
@@ -31,7 +32,8 @@ public class Response
3132
{
3233
private readonly static JsonSerializerOptions s_jsonSerializerOptions = new()
3334
{
34-
Converters = { new ResponseValueJsonConverter() }
35+
TypeInfoResolver = ResponseSerializerContext.Default,
36+
Converters = { new ResponseValueJsonConverter() } // we still need it to make `Object` as `Dictionary`
3537
};
3638

3739
private object responseValue;
@@ -208,4 +210,16 @@ public override string ToString()
208210
return string.Format(CultureInfo.InvariantCulture, "({0} {1}: {2})", this.SessionId, this.Status, this.Value);
209211
}
210212
}
213+
214+
internal class DeserializableResponse
215+
{
216+
[JsonExtensionData]
217+
public Dictionary<string, object> Data { get; set; }
218+
}
219+
220+
[JsonSerializable(typeof(DeserializableResponse))]
221+
internal partial class ResponseSerializerContext : JsonSerializerContext
222+
{
223+
224+
}
211225
}

0 commit comments

Comments
 (0)