Skip to content

Commit 02e0cb3

Browse files
committed
Use generated JSON context
1 parent c413984 commit 02e0cb3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using OpenQA.Selenium.DevToolsGenerator.ProtocolDefinition;
44
using System;
55
using System.Collections.Generic;
6+
using System.Linq;
67

78
namespace OpenQA.Selenium.DevToolsGenerator.CodeGen
89
{
@@ -61,7 +62,8 @@ public override IDictionary<string, string> GenerateCode(DomainDefinition domain
6162
domain = domainDefinition,
6263
className = className,
6364
rootNamespace = Settings.RootNamespace,
64-
context = context
65+
context = context,
66+
protocolVersion = Settings.RootNamespace.Split(".").Last()
6567
});
6668

6769
var outputPath = Utility.ReplaceTokensInPath(Settings.DefinitionTemplates.DomainTemplate.OutputPath, className, context, Settings);

third_party/dotnet/devtools/src/generator/Templates/domain.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ namespace {{rootNamespace}}.{{domain.Name}}
5151
{{#if NoParameters}}
5252
command ??= new {{dehumanize Name}}CommandSettings();
5353
{{/if}}
54-
global::System.Text.Json.Nodes.JsonNode serializedCommand = global::System.Text.Json.JsonSerializer.SerializeToNode(command);
54+
global::System.Text.Json.Nodes.JsonNode serializedCommand = global::System.Text.Json.JsonSerializer.SerializeToNode(command, {{rootNamespace}}.{{protocolVersion}}JsonSerializerContext.Default);
5555
global::System.Text.Json.JsonElement? response = await Session.SendCommand(command.CommandName, serializedCommand, cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived).ConfigureAwait(false);
5656

5757
if (response == null)
5858
{
5959
return default({{dehumanize Name}}CommandResponse);
6060
}
6161

62-
return global::System.Text.Json.JsonSerializer.Deserialize<{{dehumanize Name}}CommandResponse>(response.Value);
62+
return global::System.Text.Json.JsonSerializer.Deserialize<{{dehumanize Name}}CommandResponse>(response.Value, {{rootNamespace}}.{{protocolVersion}}JsonSerializerContext.Default);
6363
}
6464

6565
{{/each}}

0 commit comments

Comments
 (0)