Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using OpenQA.Selenium.DevToolsGenerator.ProtocolDefinition;
using System;
using System.Collections.Generic;
using System.Linq;

namespace OpenQA.Selenium.DevToolsGenerator.CodeGen
{
Expand Down Expand Up @@ -61,7 +62,8 @@ public override IDictionary<string, string> 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);
Expand Down
15 changes: 13 additions & 2 deletions third_party/dotnet/devtools/src/generator/Templates/domain.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,20 @@ namespace {{rootNamespace}}.{{domain.Name}}
/// <summary>
/// {{xml-code-comment Description 2}}
/// </summary>
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);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks like this:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative, shorter syntax:
image

I can switch to this if it's preferable.


{{/each}}
Expand Down
Loading