From c1c4441f49e0923578f97a5afed58ada590f0b0a Mon Sep 17 00:00:00 2001 From: Michael Render Date: Wed, 15 Jan 2025 00:09:42 -0500 Subject: [PATCH 1/6] [dotnet] Move devtools generator into a specific project --- dotnet/src/webdriver/cdp/BUILD.bazel | 18 +++++++++--------- .../devtools/DevToolsProtocolGenerator.sln | 2 +- .../BUILD.bazel | 2 +- ...CodeGenerationDefinitionTemplateSettings.cs | 0 .../CodeGen/CodeGenerationSettings.cs | 0 .../CodeGen/CodeGenerationTemplateSettings.cs | 0 .../CodeGen/CodeGeneratorBase.cs | 0 .../CodeGen/CodeGeneratorContext.cs | 0 .../CodeGen/CommandGenerator.cs | 0 .../CodeGen/CommandInfo.cs | 0 .../CodeGen/DomainGenerator.cs | 0 .../CodeGen/EventGenerator.cs | 0 .../CodeGen/EventInfo.cs | 0 .../CodeGen/ICodeGenerator.cs | 0 .../CodeGen/IServiceProviderExtensions.cs | 0 .../CodeGen/ProtocolGenerator.cs | 0 .../CodeGen/TemplatesManager.cs | 0 .../CodeGen/TypeGenerator.cs | 0 .../CodeGen/TypeInfo.cs | 0 .../CodeGen/Utility.cs | 0 .../CommandLineOptions.cs | 0 .../Converters/BooleanJsonConverter.cs | 0 .../DevToolsGenerator.csproj | 0 .../Program.cs | 0 .../ProtocolDefinition/CommandDefinition.cs | 0 .../ProtocolDefinition/DomainDefinition.cs | 0 .../ProtocolDefinition/EventDefinition.cs | 0 .../ProtocolDefinition/IDefinition.cs | 0 .../ProtocolDefinition/ProtocolDefinition.cs | 0 .../ProtocolDefinitionItem.cs | 0 .../ProtocolVersionDefinition.cs | 0 .../ProtocolDefinition/TypeDefinition.cs | 0 .../ProtocolDefinition/Version.cs | 0 .../Templates/BUILD.bazel | 0 .../Templates/DevToolsSessionDomains.hbs | 0 .../Templates/command.hbs | 0 .../Templates/domain.hbs | 0 .../Templates/event.hbs | 0 .../Templates/project.hbs | 0 .../Templates/settings.json | 0 .../Templates/type-enum.hbs | 0 .../Templates/type-hash.hbs | 0 .../Templates/type-object.hbs | 0 43 files changed, 11 insertions(+), 11 deletions(-) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/BUILD.bazel (95%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/CodeGenerationDefinitionTemplateSettings.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/CodeGenerationSettings.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/CodeGenerationTemplateSettings.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/CodeGeneratorBase.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/CodeGeneratorContext.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/CommandGenerator.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/CommandInfo.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/DomainGenerator.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/EventGenerator.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/EventInfo.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/ICodeGenerator.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/IServiceProviderExtensions.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/ProtocolGenerator.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/TemplatesManager.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/TypeGenerator.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/TypeInfo.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CodeGen/Utility.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/CommandLineOptions.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Converters/BooleanJsonConverter.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/DevToolsGenerator.csproj (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Program.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/ProtocolDefinition/CommandDefinition.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/ProtocolDefinition/DomainDefinition.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/ProtocolDefinition/EventDefinition.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/ProtocolDefinition/IDefinition.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/ProtocolDefinition/ProtocolDefinition.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/ProtocolDefinition/ProtocolDefinitionItem.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/ProtocolDefinition/ProtocolVersionDefinition.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/ProtocolDefinition/TypeDefinition.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/ProtocolDefinition/Version.cs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/BUILD.bazel (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/DevToolsSessionDomains.hbs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/command.hbs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/domain.hbs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/event.hbs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/project.hbs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/settings.json (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/type-enum.hbs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/type-hash.hbs (100%) rename third_party/dotnet/devtools/src/{generator => DevToolsGenerator}/Templates/type-object.hbs (100%) diff --git a/dotnet/src/webdriver/cdp/BUILD.bazel b/dotnet/src/webdriver/cdp/BUILD.bazel index fbea7aec9ff45..bb5b01d9725d5 100644 --- a/dotnet/src/webdriver/cdp/BUILD.bazel +++ b/dotnet/src/webdriver/cdp/BUILD.bazel @@ -6,18 +6,18 @@ load("//dotnet:selenium-dotnet-version.bzl", "SUPPORTED_DEVTOOLS_VERSIONS") name = "generate-{}".format(devtools_version), out = "{}".format(devtools_version), browser_protocol = "//common/devtools/chromium/{}:browser_protocol".format(devtools_version), - generator = "//third_party/dotnet/devtools/src/generator", + generator = "//third_party/dotnet/devtools/src/DevToolsGenerator", js_protocol = "//common/devtools/chromium/{}:js_protocol".format(devtools_version), protocol_version = "{}".format(devtools_version), templates = [ - "//third_party/dotnet/devtools/src/generator/Templates:command.hbs", - "//third_party/dotnet/devtools/src/generator/Templates:DevToolsSessionDomains.hbs", - "//third_party/dotnet/devtools/src/generator/Templates:domain.hbs", - "//third_party/dotnet/devtools/src/generator/Templates:event.hbs", - "//third_party/dotnet/devtools/src/generator/Templates:project.hbs", - "//third_party/dotnet/devtools/src/generator/Templates:type-enum.hbs", - "//third_party/dotnet/devtools/src/generator/Templates:type-hash.hbs", - "//third_party/dotnet/devtools/src/generator/Templates:type-object.hbs", + "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:command.hbs", + "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:DevToolsSessionDomains.hbs", + "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:domain.hbs", + "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:event.hbs", + "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:project.hbs", + "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:type-enum.hbs", + "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:type-hash.hbs", + "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:type-object.hbs", ], visibility = ["//dotnet:__subpackages__"], ) diff --git a/third_party/dotnet/devtools/DevToolsProtocolGenerator.sln b/third_party/dotnet/devtools/DevToolsProtocolGenerator.sln index 2c7acdc34243f..10ed9a5e1763e 100644 --- a/third_party/dotnet/devtools/DevToolsProtocolGenerator.sln +++ b/third_party/dotnet/devtools/DevToolsProtocolGenerator.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30611.23 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToolsGenerator", "src\generator\DevToolsGenerator.csproj", "{E5D54A93-645D-4D0F-956F-C467208AD14F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToolsGenerator", "src\DevToolsGenerator\DevToolsGenerator.csproj", "{E5D54A93-645D-4D0F-956F-C467208AD14F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/third_party/dotnet/devtools/src/generator/BUILD.bazel b/third_party/dotnet/devtools/src/DevToolsGenerator/BUILD.bazel similarity index 95% rename from third_party/dotnet/devtools/src/generator/BUILD.bazel rename to third_party/dotnet/devtools/src/DevToolsGenerator/BUILD.bazel index f202cd9df6387..91d4501a3f0a8 100644 --- a/third_party/dotnet/devtools/src/generator/BUILD.bazel +++ b/third_party/dotnet/devtools/src/DevToolsGenerator/BUILD.bazel @@ -1,7 +1,7 @@ load("//dotnet:defs.bzl", "csharp_binary", "framework") csharp_binary( - name = "generator", + name = "DevToolsGenerator", srcs = glob(["**/*.cs"]), nullable = "annotations", # Used as a tool in our build, so just target one framework diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationDefinitionTemplateSettings.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationDefinitionTemplateSettings.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationDefinitionTemplateSettings.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationDefinitionTemplateSettings.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationSettings.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationSettings.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationSettings.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationSettings.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationTemplateSettings.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationTemplateSettings.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationTemplateSettings.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationTemplateSettings.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorBase.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGeneratorBase.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorBase.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGeneratorBase.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorContext.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGeneratorContext.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorContext.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGeneratorContext.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CommandGenerator.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CommandGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/CommandGenerator.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CommandGenerator.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CommandInfo.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CommandInfo.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/CommandInfo.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CommandInfo.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/DomainGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/DomainGenerator.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/EventGenerator.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/EventGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/EventGenerator.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/EventGenerator.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/EventInfo.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/EventInfo.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/EventInfo.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/EventInfo.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/ICodeGenerator.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/ICodeGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/ICodeGenerator.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/ICodeGenerator.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/IServiceProviderExtensions.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/IServiceProviderExtensions.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/IServiceProviderExtensions.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/IServiceProviderExtensions.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/ProtocolGenerator.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/ProtocolGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/ProtocolGenerator.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/ProtocolGenerator.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/TemplatesManager.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TemplatesManager.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/TemplatesManager.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TemplatesManager.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/TypeGenerator.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TypeGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/TypeGenerator.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TypeGenerator.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/TypeInfo.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TypeInfo.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/TypeInfo.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TypeInfo.cs diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/Utility.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/Utility.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CodeGen/Utility.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/Utility.cs diff --git a/third_party/dotnet/devtools/src/generator/CommandLineOptions.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/CommandLineOptions.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/CommandLineOptions.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/CommandLineOptions.cs diff --git a/third_party/dotnet/devtools/src/generator/Converters/BooleanJsonConverter.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/Converters/BooleanJsonConverter.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Converters/BooleanJsonConverter.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Converters/BooleanJsonConverter.cs diff --git a/third_party/dotnet/devtools/src/generator/DevToolsGenerator.csproj b/third_party/dotnet/devtools/src/DevToolsGenerator/DevToolsGenerator.csproj similarity index 100% rename from third_party/dotnet/devtools/src/generator/DevToolsGenerator.csproj rename to third_party/dotnet/devtools/src/DevToolsGenerator/DevToolsGenerator.csproj diff --git a/third_party/dotnet/devtools/src/generator/Program.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/Program.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Program.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Program.cs diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/CommandDefinition.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/CommandDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/ProtocolDefinition/CommandDefinition.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/CommandDefinition.cs diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/DomainDefinition.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/DomainDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/ProtocolDefinition/DomainDefinition.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/DomainDefinition.cs diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/EventDefinition.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/EventDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/ProtocolDefinition/EventDefinition.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/EventDefinition.cs diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/IDefinition.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/IDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/ProtocolDefinition/IDefinition.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/IDefinition.cs diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinition.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinition.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolDefinition.cs diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolDefinitionItem.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolDefinitionItem.cs diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolVersionDefinition.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolVersionDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolVersionDefinition.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolVersionDefinition.cs diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/TypeDefinition.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/TypeDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/ProtocolDefinition/TypeDefinition.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/TypeDefinition.cs diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/Version.cs b/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/Version.cs similarity index 100% rename from third_party/dotnet/devtools/src/generator/ProtocolDefinition/Version.cs rename to third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/Version.cs diff --git a/third_party/dotnet/devtools/src/generator/Templates/BUILD.bazel b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/BUILD.bazel similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/BUILD.bazel rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/BUILD.bazel diff --git a/third_party/dotnet/devtools/src/generator/Templates/DevToolsSessionDomains.hbs b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/DevToolsSessionDomains.hbs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/DevToolsSessionDomains.hbs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/DevToolsSessionDomains.hbs diff --git a/third_party/dotnet/devtools/src/generator/Templates/command.hbs b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/command.hbs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/command.hbs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/command.hbs diff --git a/third_party/dotnet/devtools/src/generator/Templates/domain.hbs b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/domain.hbs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/domain.hbs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/domain.hbs diff --git a/third_party/dotnet/devtools/src/generator/Templates/event.hbs b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/event.hbs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/event.hbs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/event.hbs diff --git a/third_party/dotnet/devtools/src/generator/Templates/project.hbs b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/project.hbs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/project.hbs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/project.hbs diff --git a/third_party/dotnet/devtools/src/generator/Templates/settings.json b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/settings.json similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/settings.json rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/settings.json diff --git a/third_party/dotnet/devtools/src/generator/Templates/type-enum.hbs b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-enum.hbs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/type-enum.hbs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-enum.hbs diff --git a/third_party/dotnet/devtools/src/generator/Templates/type-hash.hbs b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-hash.hbs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/type-hash.hbs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-hash.hbs diff --git a/third_party/dotnet/devtools/src/generator/Templates/type-object.hbs b/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-object.hbs similarity index 100% rename from third_party/dotnet/devtools/src/generator/Templates/type-object.hbs rename to third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-object.hbs From efc80ed1008c7163cf81a94fd3486fc15cf5e2ff Mon Sep 17 00:00:00 2001 From: Michael Render Date: Wed, 15 Jan 2025 00:33:51 -0500 Subject: [PATCH 2/6] rename generator name in generate_devtools --- dotnet/private/generate_devtools.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/private/generate_devtools.bzl b/dotnet/private/generate_devtools.bzl index de2cc20343fe0..6278e761d98e4 100644 --- a/dotnet/private/generate_devtools.bzl +++ b/dotnet/private/generate_devtools.bzl @@ -60,7 +60,7 @@ generate_devtools = rule( doc = "File name, without extension, of the built assembly.", ), "generator": attr.label( - default = Label("//third_party/dotnet/devtools/src/generator:generator"), + default = Label("//third_party/dotnet/devtools/src/DevToolsGenerator:DevToolsGenerator"), executable = True, cfg = "exec", ), From 9ee34f6911c18e5bd2a5e481c388372703d7405f Mon Sep 17 00:00:00 2001 From: Michael Render Date: Wed, 15 Jan 2025 19:09:01 -0500 Subject: [PATCH 3/6] Revert "rename generator name in generate_devtools" This reverts commit efc80ed1008c7163cf81a94fd3486fc15cf5e2ff. --- dotnet/private/generate_devtools.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/private/generate_devtools.bzl b/dotnet/private/generate_devtools.bzl index 6278e761d98e4..de2cc20343fe0 100644 --- a/dotnet/private/generate_devtools.bzl +++ b/dotnet/private/generate_devtools.bzl @@ -60,7 +60,7 @@ generate_devtools = rule( doc = "File name, without extension, of the built assembly.", ), "generator": attr.label( - default = Label("//third_party/dotnet/devtools/src/DevToolsGenerator:DevToolsGenerator"), + default = Label("//third_party/dotnet/devtools/src/generator:generator"), executable = True, cfg = "exec", ), From 5e2fe91e33633b9bc89639feb1161515599337bc Mon Sep 17 00:00:00 2001 From: Michael Render Date: Wed, 15 Jan 2025 19:10:13 -0500 Subject: [PATCH 4/6] Revert "[dotnet] Move devtools generator into a specific project" This reverts commit c1c4441f49e0923578f97a5afed58ada590f0b0a. --- dotnet/src/webdriver/cdp/BUILD.bazel | 18 +++++++++--------- .../devtools/DevToolsProtocolGenerator.sln | 2 +- .../BUILD.bazel | 2 +- ...CodeGenerationDefinitionTemplateSettings.cs | 0 .../CodeGen/CodeGenerationSettings.cs | 0 .../CodeGen/CodeGenerationTemplateSettings.cs | 0 .../CodeGen/CodeGeneratorBase.cs | 0 .../CodeGen/CodeGeneratorContext.cs | 0 .../CodeGen/CommandGenerator.cs | 0 .../CodeGen/CommandInfo.cs | 0 .../CodeGen/DomainGenerator.cs | 0 .../CodeGen/EventGenerator.cs | 0 .../CodeGen/EventInfo.cs | 0 .../CodeGen/ICodeGenerator.cs | 0 .../CodeGen/IServiceProviderExtensions.cs | 0 .../CodeGen/ProtocolGenerator.cs | 0 .../CodeGen/TemplatesManager.cs | 0 .../CodeGen/TypeGenerator.cs | 0 .../CodeGen/TypeInfo.cs | 0 .../CodeGen/Utility.cs | 0 .../CommandLineOptions.cs | 0 .../Converters/BooleanJsonConverter.cs | 0 .../DevToolsGenerator.csproj | 0 .../Program.cs | 0 .../ProtocolDefinition/CommandDefinition.cs | 0 .../ProtocolDefinition/DomainDefinition.cs | 0 .../ProtocolDefinition/EventDefinition.cs | 0 .../ProtocolDefinition/IDefinition.cs | 0 .../ProtocolDefinition/ProtocolDefinition.cs | 0 .../ProtocolDefinitionItem.cs | 0 .../ProtocolVersionDefinition.cs | 0 .../ProtocolDefinition/TypeDefinition.cs | 0 .../ProtocolDefinition/Version.cs | 0 .../Templates/BUILD.bazel | 0 .../Templates/DevToolsSessionDomains.hbs | 0 .../Templates/command.hbs | 0 .../Templates/domain.hbs | 0 .../Templates/event.hbs | 0 .../Templates/project.hbs | 0 .../Templates/settings.json | 0 .../Templates/type-enum.hbs | 0 .../Templates/type-hash.hbs | 0 .../Templates/type-object.hbs | 0 43 files changed, 11 insertions(+), 11 deletions(-) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/BUILD.bazel (95%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/CodeGenerationDefinitionTemplateSettings.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/CodeGenerationSettings.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/CodeGenerationTemplateSettings.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/CodeGeneratorBase.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/CodeGeneratorContext.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/CommandGenerator.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/CommandInfo.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/DomainGenerator.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/EventGenerator.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/EventInfo.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/ICodeGenerator.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/IServiceProviderExtensions.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/ProtocolGenerator.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/TemplatesManager.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/TypeGenerator.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/TypeInfo.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CodeGen/Utility.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/CommandLineOptions.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Converters/BooleanJsonConverter.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/DevToolsGenerator.csproj (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Program.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/ProtocolDefinition/CommandDefinition.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/ProtocolDefinition/DomainDefinition.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/ProtocolDefinition/EventDefinition.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/ProtocolDefinition/IDefinition.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/ProtocolDefinition/ProtocolDefinition.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/ProtocolDefinition/ProtocolDefinitionItem.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/ProtocolDefinition/ProtocolVersionDefinition.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/ProtocolDefinition/TypeDefinition.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/ProtocolDefinition/Version.cs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/BUILD.bazel (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/DevToolsSessionDomains.hbs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/command.hbs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/domain.hbs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/event.hbs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/project.hbs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/settings.json (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/type-enum.hbs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/type-hash.hbs (100%) rename third_party/dotnet/devtools/src/{DevToolsGenerator => generator}/Templates/type-object.hbs (100%) diff --git a/dotnet/src/webdriver/cdp/BUILD.bazel b/dotnet/src/webdriver/cdp/BUILD.bazel index bb5b01d9725d5..fbea7aec9ff45 100644 --- a/dotnet/src/webdriver/cdp/BUILD.bazel +++ b/dotnet/src/webdriver/cdp/BUILD.bazel @@ -6,18 +6,18 @@ load("//dotnet:selenium-dotnet-version.bzl", "SUPPORTED_DEVTOOLS_VERSIONS") name = "generate-{}".format(devtools_version), out = "{}".format(devtools_version), browser_protocol = "//common/devtools/chromium/{}:browser_protocol".format(devtools_version), - generator = "//third_party/dotnet/devtools/src/DevToolsGenerator", + generator = "//third_party/dotnet/devtools/src/generator", js_protocol = "//common/devtools/chromium/{}:js_protocol".format(devtools_version), protocol_version = "{}".format(devtools_version), templates = [ - "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:command.hbs", - "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:DevToolsSessionDomains.hbs", - "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:domain.hbs", - "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:event.hbs", - "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:project.hbs", - "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:type-enum.hbs", - "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:type-hash.hbs", - "//third_party/dotnet/devtools/src/DevToolsGenerator/Templates:type-object.hbs", + "//third_party/dotnet/devtools/src/generator/Templates:command.hbs", + "//third_party/dotnet/devtools/src/generator/Templates:DevToolsSessionDomains.hbs", + "//third_party/dotnet/devtools/src/generator/Templates:domain.hbs", + "//third_party/dotnet/devtools/src/generator/Templates:event.hbs", + "//third_party/dotnet/devtools/src/generator/Templates:project.hbs", + "//third_party/dotnet/devtools/src/generator/Templates:type-enum.hbs", + "//third_party/dotnet/devtools/src/generator/Templates:type-hash.hbs", + "//third_party/dotnet/devtools/src/generator/Templates:type-object.hbs", ], visibility = ["//dotnet:__subpackages__"], ) diff --git a/third_party/dotnet/devtools/DevToolsProtocolGenerator.sln b/third_party/dotnet/devtools/DevToolsProtocolGenerator.sln index 10ed9a5e1763e..2c7acdc34243f 100644 --- a/third_party/dotnet/devtools/DevToolsProtocolGenerator.sln +++ b/third_party/dotnet/devtools/DevToolsProtocolGenerator.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30611.23 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToolsGenerator", "src\DevToolsGenerator\DevToolsGenerator.csproj", "{E5D54A93-645D-4D0F-956F-C467208AD14F}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToolsGenerator", "src\generator\DevToolsGenerator.csproj", "{E5D54A93-645D-4D0F-956F-C467208AD14F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/BUILD.bazel b/third_party/dotnet/devtools/src/generator/BUILD.bazel similarity index 95% rename from third_party/dotnet/devtools/src/DevToolsGenerator/BUILD.bazel rename to third_party/dotnet/devtools/src/generator/BUILD.bazel index 91d4501a3f0a8..f202cd9df6387 100644 --- a/third_party/dotnet/devtools/src/DevToolsGenerator/BUILD.bazel +++ b/third_party/dotnet/devtools/src/generator/BUILD.bazel @@ -1,7 +1,7 @@ load("//dotnet:defs.bzl", "csharp_binary", "framework") csharp_binary( - name = "DevToolsGenerator", + name = "generator", srcs = glob(["**/*.cs"]), nullable = "annotations", # Used as a tool in our build, so just target one framework diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationDefinitionTemplateSettings.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationDefinitionTemplateSettings.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationDefinitionTemplateSettings.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationDefinitionTemplateSettings.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationSettings.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationSettings.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationSettings.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationSettings.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationTemplateSettings.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationTemplateSettings.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGenerationTemplateSettings.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationTemplateSettings.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGeneratorBase.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorBase.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGeneratorBase.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorBase.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGeneratorContext.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorContext.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CodeGeneratorContext.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorContext.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CommandGenerator.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CommandGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CommandGenerator.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/CommandGenerator.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CommandInfo.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CommandInfo.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/CommandInfo.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/CommandInfo.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/DomainGenerator.cs b/third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/DomainGenerator.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/EventGenerator.cs b/third_party/dotnet/devtools/src/generator/CodeGen/EventGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/EventGenerator.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/EventGenerator.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/EventInfo.cs b/third_party/dotnet/devtools/src/generator/CodeGen/EventInfo.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/EventInfo.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/EventInfo.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/ICodeGenerator.cs b/third_party/dotnet/devtools/src/generator/CodeGen/ICodeGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/ICodeGenerator.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/ICodeGenerator.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/IServiceProviderExtensions.cs b/third_party/dotnet/devtools/src/generator/CodeGen/IServiceProviderExtensions.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/IServiceProviderExtensions.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/IServiceProviderExtensions.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/ProtocolGenerator.cs b/third_party/dotnet/devtools/src/generator/CodeGen/ProtocolGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/ProtocolGenerator.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/ProtocolGenerator.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TemplatesManager.cs b/third_party/dotnet/devtools/src/generator/CodeGen/TemplatesManager.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TemplatesManager.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/TemplatesManager.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TypeGenerator.cs b/third_party/dotnet/devtools/src/generator/CodeGen/TypeGenerator.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TypeGenerator.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/TypeGenerator.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TypeInfo.cs b/third_party/dotnet/devtools/src/generator/CodeGen/TypeInfo.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/TypeInfo.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/TypeInfo.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/Utility.cs b/third_party/dotnet/devtools/src/generator/CodeGen/Utility.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CodeGen/Utility.cs rename to third_party/dotnet/devtools/src/generator/CodeGen/Utility.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/CommandLineOptions.cs b/third_party/dotnet/devtools/src/generator/CommandLineOptions.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/CommandLineOptions.cs rename to third_party/dotnet/devtools/src/generator/CommandLineOptions.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Converters/BooleanJsonConverter.cs b/third_party/dotnet/devtools/src/generator/Converters/BooleanJsonConverter.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Converters/BooleanJsonConverter.cs rename to third_party/dotnet/devtools/src/generator/Converters/BooleanJsonConverter.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/DevToolsGenerator.csproj b/third_party/dotnet/devtools/src/generator/DevToolsGenerator.csproj similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/DevToolsGenerator.csproj rename to third_party/dotnet/devtools/src/generator/DevToolsGenerator.csproj diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Program.cs b/third_party/dotnet/devtools/src/generator/Program.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Program.cs rename to third_party/dotnet/devtools/src/generator/Program.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/CommandDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/CommandDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/CommandDefinition.cs rename to third_party/dotnet/devtools/src/generator/ProtocolDefinition/CommandDefinition.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/DomainDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/DomainDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/DomainDefinition.cs rename to third_party/dotnet/devtools/src/generator/ProtocolDefinition/DomainDefinition.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/EventDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/EventDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/EventDefinition.cs rename to third_party/dotnet/devtools/src/generator/ProtocolDefinition/EventDefinition.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/IDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/IDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/IDefinition.cs rename to third_party/dotnet/devtools/src/generator/ProtocolDefinition/IDefinition.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolDefinition.cs rename to third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinition.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolDefinitionItem.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolDefinitionItem.cs rename to third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolVersionDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolVersionDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/ProtocolVersionDefinition.cs rename to third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolVersionDefinition.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/TypeDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/TypeDefinition.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/TypeDefinition.cs rename to third_party/dotnet/devtools/src/generator/ProtocolDefinition/TypeDefinition.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/Version.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/Version.cs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/ProtocolDefinition/Version.cs rename to third_party/dotnet/devtools/src/generator/ProtocolDefinition/Version.cs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/BUILD.bazel b/third_party/dotnet/devtools/src/generator/Templates/BUILD.bazel similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/BUILD.bazel rename to third_party/dotnet/devtools/src/generator/Templates/BUILD.bazel diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/DevToolsSessionDomains.hbs b/third_party/dotnet/devtools/src/generator/Templates/DevToolsSessionDomains.hbs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/DevToolsSessionDomains.hbs rename to third_party/dotnet/devtools/src/generator/Templates/DevToolsSessionDomains.hbs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/command.hbs b/third_party/dotnet/devtools/src/generator/Templates/command.hbs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/command.hbs rename to third_party/dotnet/devtools/src/generator/Templates/command.hbs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/domain.hbs b/third_party/dotnet/devtools/src/generator/Templates/domain.hbs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/domain.hbs rename to third_party/dotnet/devtools/src/generator/Templates/domain.hbs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/event.hbs b/third_party/dotnet/devtools/src/generator/Templates/event.hbs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/event.hbs rename to third_party/dotnet/devtools/src/generator/Templates/event.hbs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/project.hbs b/third_party/dotnet/devtools/src/generator/Templates/project.hbs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/project.hbs rename to third_party/dotnet/devtools/src/generator/Templates/project.hbs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/settings.json b/third_party/dotnet/devtools/src/generator/Templates/settings.json similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/settings.json rename to third_party/dotnet/devtools/src/generator/Templates/settings.json diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-enum.hbs b/third_party/dotnet/devtools/src/generator/Templates/type-enum.hbs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-enum.hbs rename to third_party/dotnet/devtools/src/generator/Templates/type-enum.hbs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-hash.hbs b/third_party/dotnet/devtools/src/generator/Templates/type-hash.hbs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-hash.hbs rename to third_party/dotnet/devtools/src/generator/Templates/type-hash.hbs diff --git a/third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-object.hbs b/third_party/dotnet/devtools/src/generator/Templates/type-object.hbs similarity index 100% rename from third_party/dotnet/devtools/src/DevToolsGenerator/Templates/type-object.hbs rename to third_party/dotnet/devtools/src/generator/Templates/type-object.hbs From 39ca40984114c3502c584d9bf2799a6e5a6c7e66 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Wed, 15 Jan 2025 23:12:24 -0500 Subject: [PATCH 5/6] Modernize and prepare devtools generator for source generation --- .../CodeGen/CodeGenerationSettings.cs | 2 +- .../CodeGen/CodeGenerationTemplateSettings.cs | 6 +- .../generator/CodeGen/CodeGeneratorBase.cs | 2 +- .../generator/CodeGen/CodeGeneratorContext.cs | 6 +- .../src/generator/CodeGen/CommandInfo.cs | 8 +- .../src/generator/CodeGen/EventInfo.cs | 6 +- .../src/generator/CodeGen/ICodeGenerator.cs | 2 +- .../generator/CodeGen/ProtocolGenerator.cs | 78 +++++++++---------- .../src/generator/CodeGen/TemplatesManager.cs | 8 +- .../src/generator/CodeGen/TypeInfo.cs | 10 +-- .../devtools/src/generator/CodeGen/Utility.cs | 51 ++++++------ .../src/generator/CommandLineOptions.cs | 10 +-- .../src/generator/DevToolsGenerator.csproj | 2 +- .../dotnet/devtools/src/generator/Program.cs | 27 ++++--- .../ProtocolDefinition/CommandDefinition.cs | 2 +- .../ProtocolDefinition/DomainDefinition.cs | 2 +- .../ProtocolDefinition/ProtocolDefinition.cs | 4 +- .../ProtocolDefinitionItem.cs | 8 +- .../ProtocolVersionDefinition.cs | 50 ++---------- .../ProtocolDefinition/TypeDefinition.cs | 10 +-- .../generator/ProtocolDefinition/Version.cs | 8 +- 21 files changed, 132 insertions(+), 170 deletions(-) diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationSettings.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationSettings.cs index b9049b2b08ba3..329a2ad0bd449 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationSettings.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationSettings.cs @@ -36,7 +36,7 @@ public sealed class CodeGenerationSettings /// Gets the version number of the runtime. /// [JsonPropertyName("runtimeVersion")] - public string RuntimeVersion { get; set; } + public string? RuntimeVersion { get; set; } [JsonPropertyName("definitionTemplates")] public CodeGenerationDefinitionTemplateSettings DefinitionTemplates { get; set; } = new CodeGenerationDefinitionTemplateSettings(); diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationTemplateSettings.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationTemplateSettings.cs index 99a9a2be31123..caa40da3171c5 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationTemplateSettings.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGenerationTemplateSettings.cs @@ -8,9 +8,11 @@ namespace OpenQA.Selenium.DevToolsGenerator.CodeGen public class CodeGenerationTemplateSettings { [JsonPropertyName("templatePath")] - public string TemplatePath { get; set; } + [JsonRequired] + public string TemplatePath { get; set; } = null!; [JsonPropertyName("outputPath")] - public string OutputPath { get; set; } + [JsonRequired] + public string OutputPath { get; set; } = null!; } } diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorBase.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorBase.cs index d142a3a622154..e89124b4d7500 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorBase.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorBase.cs @@ -10,7 +10,7 @@ namespace OpenQA.Selenium.DevToolsGenerator.CodeGen /// /// public abstract class CodeGeneratorBase : ICodeGenerator - where T : IDefinition + where T : class, IDefinition { private readonly Lazy m_settings; private readonly Lazy m_templatesManager; diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorContext.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorContext.cs index 07ce4735c19da..d81b84b4902d5 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorContext.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/CodeGeneratorContext.cs @@ -6,10 +6,10 @@ namespace OpenQA.Selenium.DevToolsGenerator.CodeGen /// /// Represents the current context of the code generator. /// - public sealed class CodeGeneratorContext + public sealed class CodeGeneratorContext(DomainDefinition domain, Dictionary knownTypes) { - public DomainDefinition Domain { get; set; } + public DomainDefinition Domain { get; } = domain; - public Dictionary KnownTypes { get; set; } + public Dictionary KnownTypes { get; } = knownTypes; } } diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/CommandInfo.cs b/third_party/dotnet/devtools/src/generator/CodeGen/CommandInfo.cs index f70dfd4601861..b898880d4e356 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/CommandInfo.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/CommandInfo.cs @@ -3,12 +3,12 @@ namespace OpenQA.Selenium.DevToolsGenerator.CodeGen /// /// Represents information about a Chrome Debugger Protocol command. /// - public sealed class CommandInfo + public sealed class CommandInfo(string commandName, string fullTypeName, string fullResponseTypeName) { - public string CommandName { get; set; } + public string CommandName { get; } = commandName; - public string FullTypeName { get; set; } + public string FullTypeName { get; } = fullTypeName; - public string FullResponseTypeName { get; set; } + public string FullResponseTypeName { get; } = fullResponseTypeName; } } diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/EventInfo.cs b/third_party/dotnet/devtools/src/generator/CodeGen/EventInfo.cs index 0e78b688ac880..2ed7bbd74fd6f 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/EventInfo.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/EventInfo.cs @@ -3,10 +3,10 @@ namespace OpenQA.Selenium.DevToolsGenerator.CodeGen /// /// Represents information about a Chrome Debugger Protocol event. /// - public sealed class EventInfo + public sealed class EventInfo(string eventName, string fullTypeName) { - public string EventName { get; set; } + public string EventName { get; } = eventName; - public string FullTypeName { get; set; } + public string FullTypeName { get; } = fullTypeName; } } diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/ICodeGenerator.cs b/third_party/dotnet/devtools/src/generator/CodeGen/ICodeGenerator.cs index 004fcb65ad21f..6620a5c5cda2a 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/ICodeGenerator.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/ICodeGenerator.cs @@ -8,7 +8,7 @@ namespace OpenQA.Selenium.DevToolsGenerator.CodeGen /// /// public interface ICodeGenerator - where T : IDefinition + where T : class, IDefinition { /// /// Generates one or more code files for the specified IDefinition item diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/ProtocolGenerator.cs b/third_party/dotnet/devtools/src/generator/CodeGen/ProtocolGenerator.cs index 660b44c07b125..9abf949722b53 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/ProtocolGenerator.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/ProtocolGenerator.cs @@ -3,6 +3,7 @@ using OpenQA.Selenium.DevToolsGenerator.ProtocolDefinition; using System; using System.Collections.Generic; +using System.Data; using System.IO; using System.Linq; @@ -22,7 +23,7 @@ public override IDictionary GenerateCode(ProtocolDefinition.Prot { if (string.IsNullOrWhiteSpace(Settings.TemplatesPath)) { - Settings.TemplatesPath = Path.GetDirectoryName(Settings.TemplatesPath); + Settings.TemplatesPath = Path.GetDirectoryName(Settings.TemplatesPath)!; } ICollection domains = protocolDefinition.Domains; @@ -44,11 +45,11 @@ public override IDictionary GenerateCode(ProtocolDefinition.Prot foreach (var command in domain.Commands) { commands.Add(new CommandInfo - { - CommandName = $"{domain.Name}.{command.Name}", - FullTypeName = $"{domain.Name.Dehumanize()}.{command.Name.Dehumanize()}CommandSettings", - FullResponseTypeName = $"{domain.Name.Dehumanize()}.{command.Name.Dehumanize()}CommandResponse" - }); + ( + commandName: $"{domain.Name}.{command.Name}", + fullTypeName: $"{domain.Name.Dehumanize()}.{command.Name.Dehumanize()}CommandSettings", + fullResponseTypeName: $"{domain.Name.Dehumanize()}.{command.Name.Dehumanize()}CommandResponse" + )); } } @@ -60,10 +61,10 @@ public override IDictionary GenerateCode(ProtocolDefinition.Prot foreach (var @event in domain.Events) { events.Add(new EventInfo - { - EventName = $"{domain.Name}.{@event.Name}", - FullTypeName = $"{domain.Name.Dehumanize()}.{@event.Name.Dehumanize()}EventArgs" - }); + ( + eventName: $"{domain.Name}.{@event.Name}", + fullTypeName: $"{domain.Name.Dehumanize()}.{@event.Name.Dehumanize()}EventArgs") + ); } } @@ -102,7 +103,7 @@ public override IDictionary GenerateCode(ProtocolDefinition.Prot return result; } - private Dictionary GetTypesInDomain(ICollection domains) + private static Dictionary GetTypesInDomain(ICollection domains) { var knownTypes = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -116,9 +117,9 @@ private Dictionary GetTypesInDomain(ICollection 0) { - TypeDefinition propertyTypeDefinition = new TypeDefinition() + string id = $"{type.Id.Dehumanize()}{propertyType.Name.Dehumanize()}Values"; + TypeDefinition propertyTypeDefinition = new TypeDefinition(id) { - Id = type.Id.Dehumanize() + propertyType.Name.Dehumanize() + "Values", Type = propertyType.Type, Description = $"Enumerated values for {domain.Name}.{type.Id}.{propertyType.Name}" }; @@ -136,35 +137,33 @@ private Dictionary GetTypesInDomain(ICollection 0) { - typeInfo = new TypeInfo + typeInfo = new TypeInfo(typeName: type.Id.Dehumanize(), isPrimitive: false) { ByRef = true, - IsPrimitive = false, - TypeName = type.Id.Dehumanize(), }; } else { - typeInfo = new TypeInfo - { - IsPrimitive = true, - TypeName = "string" - }; + typeInfo = new TypeInfo("string", isPrimitive: true); } break; + case "array": - if ((type.Items == null || string.IsNullOrWhiteSpace(type.Items.Type)) && - type.Items.TypeReference != "StringIndex" && type.Items.TypeReference != "FilterEntry") + if (type.Items is null) + { + throw new InvalidOperationException("Type definition's Type was array but Items is missing"); + } + + if (string.IsNullOrWhiteSpace(type.Items.Type) && + type.Items.TypeReference != "StringIndex" && + type.Items.TypeReference != "FilterEntry") { throw new NotImplementedException("Did not expect a top-level domain array type to specify a TypeReference"); } @@ -199,28 +198,23 @@ private Dictionary GetTypesInDomain(ICollection GetTypesInDomain(ICollection GenerateCode(ICollection do //Generate types/events/commands for all domains. foreach (var domain in domains) { - var context = new CodeGeneratorContext { Domain = domain, KnownTypes = knownTypes }; + var context = new CodeGeneratorContext(domain, knownTypes); foreach (KeyValuePair x in domainGenerator.GenerateCode(domain, context)) { result.Add(x.Key, x.Value); diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/TemplatesManager.cs b/third_party/dotnet/devtools/src/generator/CodeGen/TemplatesManager.cs index 4921ab04cbb46..7b13a0e0178fb 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/TemplatesManager.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/TemplatesManager.cs @@ -34,9 +34,9 @@ public TemplatesManager(CodeGenerationSettings settings) public Func GetGeneratorForTemplate(CodeGenerationTemplateSettings templateSettings) { var templatePath = templateSettings.TemplatePath; - if (m_templateGenerators.ContainsKey(templatePath)) + if (m_templateGenerators.TryGetValue(templatePath, out Func? value)) { - return m_templateGenerators[templatePath]; + return value; } var targetTemplate = templatePath; @@ -47,7 +47,7 @@ public Func GetGeneratorForTemplate(CodeGenerationTemplateSettin if (!File.Exists(targetTemplate)) { - throw new FileNotFoundException($"Unable to locate a template at {targetTemplate} - please ensure that a template file exists at this location."); + throw new FileNotFoundException($"Unable to locate a template at {targetTemplate} - please ensure that a template file exists at this location.", targetTemplate); } var templateContents = File.ReadAllText(targetTemplate); @@ -59,7 +59,7 @@ public Func GetGeneratorForTemplate(CodeGenerationTemplateSettin throw new HandlebarsException("{{humanize}} helper must have exactly one argument"); } - var str = arguments[0].ToString(); + var str = arguments[0].ToString()!; //Some overrides for values that start with '-' -- this fixes two instances in Runtime.UnserializableValue if (str.StartsWith("-")) diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/TypeInfo.cs b/third_party/dotnet/devtools/src/generator/CodeGen/TypeInfo.cs index 5b87e94c369bc..2ab67c9a0d636 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/TypeInfo.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/TypeInfo.cs @@ -3,16 +3,16 @@ namespace OpenQA.Selenium.DevToolsGenerator.CodeGen /// /// Represents information about a Chrome Debugger Protocol type. /// - public sealed class TypeInfo + public sealed class TypeInfo(string typeName, bool isPrimitive) { public bool ByRef { get; set; } - public string Namespace { get; set; } + public string? Namespace { get; set; } - public bool IsPrimitive { get; set; } + public bool IsPrimitive { get; } = isPrimitive; - public string TypeName { get; set; } + public string TypeName { get; } = typeName; - public string SourcePath { get; set; } + public string? SourcePath { get; set; } } } diff --git a/third_party/dotnet/devtools/src/generator/CodeGen/Utility.cs b/third_party/dotnet/devtools/src/generator/CodeGen/Utility.cs index b22454ee952ec..eed62654e63fb 100644 --- a/third_party/dotnet/devtools/src/generator/CodeGen/Utility.cs +++ b/third_party/dotnet/devtools/src/generator/CodeGen/Utility.cs @@ -8,7 +8,7 @@ namespace OpenQA.Selenium.DevToolsGenerator.CodeGen /// /// Contains various utility methods. /// - public static class Utility + public static partial class Utility { /// /// Replaces tokens in the target path. @@ -39,17 +39,21 @@ public static string ReplaceTokensInPath(string path, string className, CodeGene /// public static string GetTypeMappingForType(TypeDefinition typeDefinition, DomainDefinition domainDefinition, IDictionary knownTypes, bool isArray = false) { + if (typeDefinition is null) + { + throw new ArgumentNullException(nameof(typeDefinition)); + } + var type = typeDefinition.Type; if (string.IsNullOrWhiteSpace(type)) { - type = typeDefinition.TypeReference; + type = typeDefinition.TypeReference ?? throw new ArgumentException("Type definition has neither Type or TypeReference", nameof(typeDefinition)); } - string mappedType = null; - if (type.Contains(".") && knownTypes.ContainsKey(type)) + string mappedType; + if (type.Contains(".") && knownTypes.TryGetValue(type, out TypeInfo? typeInfo)) { - var typeInfo = knownTypes[type]; if (typeInfo.IsPrimitive) { var primitiveType = typeInfo.TypeName; @@ -72,50 +76,48 @@ public static string GetTypeMappingForType(TypeDefinition typeDefinition, Domain mappedType += "?"; } } - - if (mappedType == null) + else if (knownTypes.TryGetValue($"{domainDefinition.Name}.{type}", out typeInfo)) { - var fullyQualifiedTypeName = $"{domainDefinition.Name}.{type}"; - - if (knownTypes.ContainsKey(fullyQualifiedTypeName)) + mappedType = typeInfo.TypeName; + if (typeInfo.ByRef && typeDefinition.Optional) { - var typeInfo = knownTypes[fullyQualifiedTypeName]; - - mappedType = typeInfo.TypeName; - if (typeInfo.ByRef && typeDefinition.Optional) - { - mappedType += "?"; - } + mappedType += "?"; } } - - - if (mappedType == null) + else { switch (type) { case "number": mappedType = typeDefinition.Optional ? "double?" : "double"; break; + case "integer": mappedType = typeDefinition.Optional ? "long?" : "long"; break; + case "boolean": mappedType = typeDefinition.Optional ? "bool?" : "bool"; break; + case "string": mappedType = "string"; break; + case "object": case "any": mappedType = "object"; break; + case "binary": mappedType = "byte[]"; break; + case "array": - mappedType = GetTypeMappingForType(typeDefinition.Items, domainDefinition, knownTypes, true); + var items = typeDefinition.Items ?? throw new InvalidOperationException("Type definition was type array but has no Items"); + mappedType = GetTypeMappingForType(items, domainDefinition, knownTypes, true); break; + default: throw new InvalidOperationException($"Unmapped data type: {type}"); } @@ -129,7 +131,7 @@ public static string GetTypeMappingForType(TypeDefinition typeDefinition, Domain return mappedType; } - public static string ReplaceLineEndings(string value, string replacement = null) + public static string? ReplaceLineEndings(string? value, string? replacement = null) { if (string.IsNullOrEmpty(value)) { @@ -138,7 +140,10 @@ public static string ReplaceLineEndings(string value, string replacement = null) replacement ??= string.Empty; - return Regex.Replace(value, @"\r\n?|\n|\u2028|\u2029", replacement, RegexOptions.Compiled); + return WhitespaceRegex().Replace(value, replacement); } + + [GeneratedRegex(@"\r\n?|\n|\u2028|\u2029", RegexOptions.Compiled)] + private static partial Regex WhitespaceRegex(); } } diff --git a/third_party/dotnet/devtools/src/generator/CommandLineOptions.cs b/third_party/dotnet/devtools/src/generator/CommandLineOptions.cs index 9b2d35f0851ae..1d312464257bd 100644 --- a/third_party/dotnet/devtools/src/generator/CommandLineOptions.cs +++ b/third_party/dotnet/devtools/src/generator/CommandLineOptions.cs @@ -29,34 +29,34 @@ public class CommandLineOptions "output-path", Default = "./OutputProtocol", HelpText = "Indicates the folder that will contain the generated class library [Default: ./OutputProtocol]")] - public string OutputPath { get; set; } + public string OutputPath { get; set; } = null!; [Option( 'b', "browser-protocol-path", Default = "./browser_protocol.json", HelpText = "Indicates the path to the Chromium Debugging Browser Protocol JSON file to use. [Default: browser_protocol.json]")] - public string BrowserProtocolPath { get; set; } + public string BrowserProtocolPath { get; set; } = null!; [Option( 'j', "js-protocol-path", Default = "./js_protocol.json", HelpText = "Indicates the path to the Chromium Debugging JavaScript Protocol JSON file to use. [Default: js_protocol.json]")] - public string JavaScriptProtocolPath { get; set; } + public string JavaScriptProtocolPath { get; set; } = null!; [Option( 't', "templates-path", Default = "", HelpText = "Indicates the path to the code generation templates file.")] - public string TemplatesPath { get; set; } + public string TemplatesPath { get; set; } = null!; [Option( 's', "settings", Default = "./Templates/settings.json", HelpText = "Indicates the path to the code generation settings file. [Default: ./Templates/settings.json]")] - public string Settings { get; set; } + public string Settings { get; set; } = null!; } } diff --git a/third_party/dotnet/devtools/src/generator/DevToolsGenerator.csproj b/third_party/dotnet/devtools/src/generator/DevToolsGenerator.csproj index 9c32a512b6730..b1a56623c8b7e 100644 --- a/third_party/dotnet/devtools/src/generator/DevToolsGenerator.csproj +++ b/third_party/dotnet/devtools/src/generator/DevToolsGenerator.csproj @@ -4,7 +4,7 @@ Exe net8.0 OpenQA.Selenium.DevToolsGenerator - annotations + enable diff --git a/third_party/dotnet/devtools/src/generator/Program.cs b/third_party/dotnet/devtools/src/generator/Program.cs index 32cdfc52b5272..738c006440712 100644 --- a/third_party/dotnet/devtools/src/generator/Program.cs +++ b/third_party/dotnet/devtools/src/generator/Program.cs @@ -25,14 +25,16 @@ static int Main(string[] args) } var settingsJson = File.ReadAllText(cliArguments.Settings); - var settings = JsonSerializer.Deserialize(settingsJson); + var settings = JsonSerializer.Deserialize(settingsJson) + ?? throw new JsonException("CodeGenerationSettings JSON returned null"); + if (!string.IsNullOrEmpty(cliArguments.TemplatesPath)) { settings.TemplatesPath = cliArguments.TemplatesPath; if (File.Exists(cliArguments.TemplatesPath)) { FileInfo info = new FileInfo(cliArguments.TemplatesPath); - settings.TemplatesPath = info.DirectoryName; + settings.TemplatesPath = info.DirectoryName!; } } @@ -49,7 +51,8 @@ static int Main(string[] args) var protocolDefinitionData = GetProtocolDefinitionData(cliArguments); - var protocolDefinition = protocolDefinitionData.Deserialize(new JsonSerializerOptions() { ReferenceHandler = ReferenceHandler.IgnoreCycles }); + var protocolDefinition = protocolDefinitionData.Deserialize(new JsonSerializerOptions() { ReferenceHandler = ReferenceHandler.IgnoreCycles }) + ?? throw new JsonException("Protocol definition JSON returned null"); //Begin the code generation process. if (!cliArguments.Quiet) @@ -58,7 +61,7 @@ static int Main(string[] args) } var protocolGenerator = serviceProvider.GetRequiredService>(); - var codeFiles = protocolGenerator.GenerateCode(protocolDefinition, null); + var codeFiles = protocolGenerator.GenerateCode(protocolDefinition, null!); //Delete the output folder if force is specified and it exists... if (!cliArguments.Quiet) @@ -83,7 +86,7 @@ static int Main(string[] args) foreach (var codeFile in codeFiles) { var targetFilePath = Path.GetFullPath(Path.Combine(cliArguments.OutputPath, codeFile.Key)); - Directory.CreateDirectory(Path.GetDirectoryName(targetFilePath)); + Directory.CreateDirectory(Path.GetDirectoryName(targetFilePath)!); //Only update the file if the SHA1 hashes don't match if (File.Exists(targetFilePath)) { @@ -135,8 +138,8 @@ public static JsonObject GetProtocolDefinitionData(CommandLineOptions args) } } - JsonObject browserProtocol = JsonNode.Parse(File.ReadAllText(browserProtocolPath)).AsObject(); - JsonObject jsProtocol = JsonNode.Parse(File.ReadAllText(jsProtocolPath)).AsObject(); + JsonObject? browserProtocol = JsonNode.Parse(File.ReadAllText(browserProtocolPath))?.AsObject(); + JsonObject? jsProtocol = JsonNode.Parse(File.ReadAllText(jsProtocolPath))?.AsObject(); ProtocolVersionDefinition currentVersion = new ProtocolVersionDefinition(); currentVersion.ProtocolVersion = "1.3"; @@ -157,17 +160,17 @@ public static JsonObject GetProtocolDefinitionData(CommandLineOptions args) public static JsonObject MergeJavaScriptProtocolDefinitions(JsonObject? browserProtocol, JsonObject? jsProtocol) { //Merge the 2 protocols together. - if (jsProtocol["version"]["majorVersion"] != browserProtocol["version"]["majorVersion"] || - jsProtocol["version"]["minorVersion"] != browserProtocol["version"]["minorVersion"]) + if (jsProtocol!["version"]!["majorVersion"] != browserProtocol!["version"]!["majorVersion"] || + jsProtocol!["version"]!["minorVersion"] != browserProtocol!["version"]!["minorVersion"]) { throw new InvalidOperationException("Protocol mismatch -- The WebKit and V8 protocol versions should match."); } var result = browserProtocol.DeepClone().AsObject(); - foreach (var domain in jsProtocol["domains"].AsArray()) + foreach (var domain in jsProtocol["domains"]!.AsArray()) { - JsonArray jDomains = result["domains"].AsArray(); - jDomains.Add(domain.DeepClone()); + JsonArray jDomains = result["domains"]!.AsArray(); + jDomains.Add(domain!.DeepClone()); } return result; diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/CommandDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/CommandDefinition.cs index 521623ed7d856..db554e452edb5 100644 --- a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/CommandDefinition.cs +++ b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/CommandDefinition.cs @@ -16,7 +16,7 @@ public sealed class CommandDefinition : ProtocolDefinitionItem public ICollection Returns { get; set; } = new Collection(); [JsonPropertyName("redirect")] - public string Redirect { get; set; } + public string? Redirect { get; set; } [JsonIgnore] public bool NoParameters => Parameters == null || Parameters.Count == 0; diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/DomainDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/DomainDefinition.cs index 9cad0d8cf28ac..2344279f6ecd0 100644 --- a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/DomainDefinition.cs +++ b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/DomainDefinition.cs @@ -7,7 +7,7 @@ namespace OpenQA.Selenium.DevToolsGenerator.ProtocolDefinition public sealed class DomainDefinition : ProtocolDefinitionItem { [JsonPropertyName("domain")] - public override string Name { get; set; } + public override string? Name { get; set; } [JsonPropertyName("types")] public ICollection Types { get; set; } = new Collection(); diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinition.cs index ea3483e337056..153805c47f6c9 100644 --- a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinition.cs +++ b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinition.cs @@ -8,11 +8,11 @@ public sealed class ProtocolDefinition : IDefinition { [JsonPropertyName("browserVersion")] [JsonRequired] - public ProtocolVersionDefinition BrowserVersion { get; set; } + public ProtocolVersionDefinition? BrowserVersion { get; set; } [JsonPropertyName("version")] [JsonRequired] - public Version Version { get; set; } + public Version? Version { get; set; } [JsonPropertyName("domains")] [JsonRequired] diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs index fd0bcf9c582ce..9bf8d24b2c17a 100644 --- a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs +++ b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolDefinitionItem.cs @@ -9,7 +9,7 @@ public abstract class ProtocolDefinitionItem : IDefinition [JsonPropertyName("deprecated")] public bool Deprecated { get; set; } - public string Description + public string? Description { get => InitialDescription?.Replace("<", "<").Replace(">", ">"); set => InitialDescription = value; @@ -20,14 +20,14 @@ public string Description public bool Experimental { get; set; } [JsonPropertyName("name")] - public virtual string Name { get; set; } + public virtual string? Name { get; set; } - public override string ToString() + public override string? ToString() { return Name; } [JsonPropertyName("description")] - protected string InitialDescription { get; set; } + protected string? InitialDescription { get; set; } } } diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolVersionDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolVersionDefinition.cs index 9ad237c519c92..dd82944c8ba92 100644 --- a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolVersionDefinition.cs +++ b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/ProtocolVersionDefinition.cs @@ -10,58 +10,18 @@ namespace OpenQA.Selenium.DevToolsGenerator.ProtocolDefinition public class ProtocolVersionDefinition { [JsonPropertyName("Browser")] - public string Browser { get; set; } - - [JsonIgnore] - public string BrowserVersion => Regex.Match(Browser, ".*/(.*)").Groups[1].Value; - - [JsonIgnore] - public string BrowserMajorVersion => Regex.Match(Browser, ".*/(\\d+)\\..*").Groups[1].Value; + public string? Browser { get; set; } [JsonPropertyName("Protocol-Version")] - public string ProtocolVersion { get; set; } + public string? ProtocolVersion { get; set; } [JsonPropertyName("User-Agent")] - public string UserAgent { get; set; } + public string? UserAgent { get; set; } [JsonPropertyName("V8-Version")] - public string V8Version { get; set; } - - [JsonIgnore] - public string V8VersionNumber - { - get - { - //Get the v8 version - var v8VersionRegex = new Regex(@"^(\d+)\.(\d+)\.(\d+)(\.\d+.*)?"); - var v8VersionMatch = v8VersionRegex.Match(V8Version); - if (v8VersionMatch.Success == false || v8VersionMatch.Groups.Count < 4) - { - throw new InvalidOperationException($"Unable to determine v8 version number from v8 version string ({V8Version})"); - } - - return $"{v8VersionMatch.Groups[1].Value}.{v8VersionMatch.Groups[2].Value}.{v8VersionMatch.Groups[3].Value}"; - } - } + public string? V8Version { get; set; } [JsonPropertyName("WebKit-Version")] - public string WebKitVersion { get; set; } - - [JsonIgnore] - public string WebKitVersionHash - { - get - { - //Get the webkit version hash. - var webkitVersionRegex = new Regex(@"\s\(@(\b[0-9a-f]{5,40}\b)"); - var webkitVersionMatch = webkitVersionRegex.Match(WebKitVersion); - if (webkitVersionMatch.Success == false || webkitVersionMatch.Groups.Count != 2) - { - throw new InvalidOperationException($"Unable to determine webkit version hash from webkit version string ({WebKitVersion})"); - } - - return webkitVersionMatch.Groups[1].Value; - } - } + public string? WebKitVersion { get; set; } } } diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/TypeDefinition.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/TypeDefinition.cs index 2e030c15465a7..72355f137f601 100644 --- a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/TypeDefinition.cs +++ b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/TypeDefinition.cs @@ -5,13 +5,13 @@ namespace OpenQA.Selenium.DevToolsGenerator.ProtocolDefinition { - public sealed class TypeDefinition : ProtocolDefinitionItem + public sealed class TypeDefinition(string id) : ProtocolDefinitionItem { [JsonPropertyName("id")] - public string Id { get; set; } + public string Id { get; } = id; [JsonPropertyName("type")] - public string Type { get; set; } + public string? Type { get; set; } [JsonPropertyName("enum")] public ICollection Enum { get; set; } = new HashSet(); @@ -20,7 +20,7 @@ public sealed class TypeDefinition : ProtocolDefinitionItem public ICollection Properties { get; set; } = new Collection(); [JsonPropertyName("items")] - public TypeDefinition Items { get; set; } + public TypeDefinition? Items { get; set; } [JsonPropertyName("minItems")] public int MinItems { get; set; } @@ -29,7 +29,7 @@ public sealed class TypeDefinition : ProtocolDefinitionItem public int MaxItems { get; set; } [JsonPropertyName("$ref")] - public string TypeReference { get; set; } + public string? TypeReference { get; set; } [JsonPropertyName("optional")] [JsonConverter(typeof(BooleanJsonConverter))] diff --git a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/Version.cs b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/Version.cs index 315400661361d..367a20a576f03 100644 --- a/third_party/dotnet/devtools/src/generator/ProtocolDefinition/Version.cs +++ b/third_party/dotnet/devtools/src/generator/ProtocolDefinition/Version.cs @@ -9,12 +9,12 @@ namespace OpenQA.Selenium.DevToolsGenerator.ProtocolDefinition public sealed class Version : IComparable { [JsonPropertyName("major")] - public string Major { get; set; } + public string? Major { get; set; } [JsonPropertyName("minor")] - public string Minor { get; set; } + public string? Minor { get; set; } - public int CompareTo(Version other) + public int CompareTo(Version? other) { if (other == null) { @@ -24,7 +24,7 @@ public int CompareTo(Version other) return ToString().CompareTo(other.ToString()); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (obj is not Version other) { From 999eb7874ca4b7a4cd7924d9fb667d7b9f7cf427 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Wed, 15 Jan 2025 23:18:45 -0500 Subject: [PATCH 6/6] Enable nullability in devtools generator in bazel build. --- third_party/dotnet/devtools/src/generator/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/dotnet/devtools/src/generator/BUILD.bazel b/third_party/dotnet/devtools/src/generator/BUILD.bazel index f202cd9df6387..7d466358b4772 100644 --- a/third_party/dotnet/devtools/src/generator/BUILD.bazel +++ b/third_party/dotnet/devtools/src/generator/BUILD.bazel @@ -3,7 +3,7 @@ load("//dotnet:defs.bzl", "csharp_binary", "framework") csharp_binary( name = "generator", srcs = glob(["**/*.cs"]), - nullable = "annotations", + nullable = "enable", # Used as a tool in our build, so just target one framework target_frameworks = ["net8.0"], visibility = [