diff --git a/dotnet/src/webdriver/DevTools/Json/DevToolsJsonOptions.cs b/dotnet/src/webdriver/DevTools/Json/DevToolsJsonOptions.cs
deleted file mode 100644
index 4b624a9f6b43e..0000000000000
--- a/dotnet/src/webdriver/DevTools/Json/DevToolsJsonOptions.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Licensed to the Software Freedom Conservancy (SFC) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The SFC licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-
-using System.Text.Json;
-
-#nullable enable
-
-namespace OpenQA.Selenium.DevTools.Json;
-
-internal static class DevToolsJsonOptions
-{
- public static JsonSerializerOptions Default { get; } = new JsonSerializerOptions()
- {
- Converters =
- {
- new StringConverter(),
- }
- };
-}
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..c32612adb9a9e 100644
--- a/third_party/dotnet/devtools/src/generator/Templates/domain.hbs
+++ b/third_party/dotnet/devtools/src/generator/Templates/domain.hbs
@@ -60,7 +60,7 @@ namespace {{rootNamespace}}.{{domain.Name}}
if (m_eventMap.ContainsKey(e.EventName))
{
var eventData = m_eventMap[e.EventName];
- var eventArgs = e.EventData.Deserialize(eventData.EventArgsType, global::OpenQA.Selenium.DevTools.Json.DevToolsJsonOptions.Default);
+ var eventArgs = e.EventData.Deserialize(eventData.EventArgsType, {{rootNamespace}}.{{protocolVersion}}JsonSerializerContext.Default);
eventData.EventInvoker(eventArgs);
}
}