diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs b/third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs index 84c2c1988f579..29158e31615a1 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs @@ -3,6 +3,7 @@ using OpenQA.Selenium.DevToolsGenerator.ProtocolDefinition; using System; using System.Collections.Generic; +using System.Linq; namespace OpenQA.Selenium.DevToolsGenerator.CodeGen { @@ -61,7 +62,8 @@ public override IDictionary GenerateCode(DomainDefinition domain domain = domainDefinition, className = className, rootNamespace = Settings.RootNamespace, - context = context + context = context, + protocolVersion = Settings.RootNamespace.Split(".").Last() }); var outputPath = Utility.ReplaceTokensInPath(Settings.DefinitionTemplates.DomainTemplate.OutputPath, className, context, Settings); diff --git a/third_party/dotnet/devtools/src/generator/Templates/domain.hbs b/third_party/dotnet/devtools/src/generator/Templates/domain.hbs index 27c483f19d06e..0d2394e0fa87d 100644 --- a/third_party/dotnet/devtools/src/generator/Templates/domain.hbs +++ b/third_party/dotnet/devtools/src/generator/Templates/domain.hbs @@ -46,9 +46,20 @@ namespace {{rootNamespace}}.{{domain.Name}} /// /// {{xml-code-comment Description 2}} /// - public Task<{{dehumanize Name}}CommandResponse> {{dehumanize Name}}({{dehumanize Name}}CommandSettings command{{#if NoParameters}} = null{{/if}}, CancellationToken cancellationToken = default(CancellationToken), int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) + public async Task<{{dehumanize Name}}CommandResponse> {{dehumanize Name}}({{dehumanize Name}}CommandSettings command{{#if NoParameters}} = null{{/if}}, CancellationToken cancellationToken = default(CancellationToken), int? millisecondsTimeout = null, bool throwExceptionIfResponseNotReceived = true) { - return Session.SendCommand<{{dehumanize Name}}CommandSettings, {{dehumanize Name}}CommandResponse>(command{{#if NoParameters}} ?? new {{dehumanize Name}}CommandSettings(){{/if}}, cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived); + {{#if NoParameters}} + command ??= new {{dehumanize Name}}CommandSettings(); + {{/if}} + global::System.Text.Json.Nodes.JsonNode serializedCommand = global::System.Text.Json.JsonSerializer.SerializeToNode(command); + global::System.Text.Json.JsonElement? response = await Session.SendCommand(command.CommandName, serializedCommand, cancellationToken, millisecondsTimeout, throwExceptionIfResponseNotReceived).ConfigureAwait(false); + + if (response == null) + { + return default({{dehumanize Name}}CommandResponse); + } + + return global::System.Text.Json.JsonSerializer.Deserialize<{{dehumanize Name}}CommandResponse>(response.Value); } {{/each}}