Skip to content

Commit feba306

Browse files
committed
Add CamelCaseEnumConverter<TEnum>
1 parent b689c81 commit feba306

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

dotnet/src/webdriver/BiDi/BrowsingContext/NavigateCommand.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
22+
using System.Text.Json.Serialization;
2123

2224
namespace OpenQA.Selenium.BiDi.BrowsingContext;
2325

@@ -31,6 +33,7 @@ public sealed class NavigateOptions : CommandOptions
3133
public ReadinessState? Wait { get; set; }
3234
}
3335

36+
[JsonConverter(typeof(CamelCaseEnumConverter<ReadinessState>))]
3437
public enum ReadinessState
3538
{
3639
None,

dotnet/src/webdriver/BiDi/Communication/Broker.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ internal Broker(BiDi bidi, Uri url)
9090
new InputOriginConverter(),
9191
new WebExtensionConverter(_bidi),
9292
new SubscriptionConverter(),
93-
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase),
9493

9594
// https://github.com/dotnet/runtime/issues/72604
9695
new Json.Converters.Polymorphic.EvaluateResultConverter(),

dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,4 @@ namespace OpenQA.Selenium.BiDi.Communication.Json;
186186
[JsonSerializable(typeof(Emulation.SetScreenOrientationOverrideCommand))]
187187
[JsonSerializable(typeof(Emulation.SetGeolocationOverrideCommand))]
188188

189-
[JsonSourceGenerationOptions(UseStringEnumConverter = true)]
190-
191189
internal partial class BiDiJsonSerializerContext : JsonSerializerContext;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// <copyright file="CamelCaseEnumConverter.cs" company="Selenium Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
// </copyright>
19+
20+
using System;
21+
using System.Text.Json;
22+
using System.Text.Json.Serialization;
23+
24+
namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;
25+
26+
public class CamelCaseEnumConverter<TEnum>() :
27+
JsonStringEnumConverter<TEnum>(JsonNamingPolicy.CamelCase) where TEnum : struct, Enum;

0 commit comments

Comments
 (0)