Skip to content

Commit e95a4fd

Browse files
committed
Retain camel-casing of BiDi enums
1 parent ac867a6 commit e95a4fd

File tree

18 files changed

+63
-17
lines changed

18 files changed

+63
-17
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// <copyright file="CamelCaseJsonEnumStringConverter.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+
internal sealed class CamelCaseJsonEnumStringConverter<TEnum>()
27+
: JsonStringEnumConverter<TEnum>(JsonNamingPolicy.CamelCase)
28+
where TEnum : struct, Enum;
29+
}

dotnet/src/webdriver/BiDi/Modules/Browser/ClientWindowInfo.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2021
using System.Text.Json.Serialization;
2122

2223
namespace OpenQA.Selenium.BiDi.Modules.Browser;
2324

2425
public record ClientWindowInfo([property: JsonPropertyName("active")] bool IsActive, ClientWindow ClientWindow, ClientWindowState State, int Height, int Width, int X, int Y);
2526

26-
[JsonConverter(typeof(JsonStringEnumConverter<ClientWindowState>))]
27+
[JsonConverter(typeof(CamelCaseJsonEnumStringConverter<ClientWindowState>))]
2728
public enum ClientWindowState
2829
{
2930
Fullscreen,

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2122
using System.Text.Json.Serialization;
2223

2324
namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
@@ -36,7 +37,7 @@ public record CaptureScreenshotOptions : CommandOptions
3637
public ClipRectangle? Clip { get; set; }
3738
}
3839

39-
[JsonConverter(typeof(JsonStringEnumConverter<Origin>))]
40+
[JsonConverter(typeof(CamelCaseJsonEnumStringConverter<Origin>))]
4041
public enum Origin
4142
{
4243
Viewport,

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CreateCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2122
using System.Text.Json.Serialization;
2223

2324
namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
@@ -36,7 +37,7 @@ public record CreateOptions : CommandOptions
3637
public Browser.UserContext? UserContext { get; set; }
3738
}
3839

39-
[JsonConverter(typeof(JsonStringEnumConverter<ContextType>))]
40+
[JsonConverter(typeof(CamelCaseJsonEnumStringConverter<ContextType>))]
4041
public enum ContextType
4142
{
4243
Tab,

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/Locator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2021
using System.Text.Json.Serialization;
2122

2223
namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
@@ -51,7 +52,7 @@ public record InnerText(string Value) : Locator
5152
public record XPath(string Value) : Locator;
5253
}
5354

54-
[JsonConverter(typeof(JsonStringEnumConverter<MatchType>))]
55+
[JsonConverter(typeof(CamelCaseJsonEnumStringConverter<MatchType>))]
5556
public enum MatchType
5657
{
5758
Full,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2122
using System.Text.Json.Serialization;
2223

2324
namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
@@ -32,7 +33,7 @@ public record NavigateOptions : CommandOptions
3233
public ReadinessState? Wait { get; set; }
3334
}
3435

35-
[JsonConverter(typeof(JsonStringEnumConverter<ReadinessState>))]
36+
[JsonConverter(typeof(CamelCaseJsonEnumStringConverter<ReadinessState>))]
3637
public enum ReadinessState
3738
{
3839
None,

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/PrintCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// </copyright>
1919

2020
using OpenQA.Selenium.BiDi.Communication;
21+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2122
using System;
2223
using System.Collections.Generic;
2324
using System.Text.Json.Serialization;
@@ -57,7 +58,7 @@ public struct PrintMargin
5758
public double? Top { get; set; }
5859
}
5960

60-
[JsonConverter(typeof(JsonStringEnumConverter<PrintOrientation>))]
61+
[JsonConverter(typeof(CamelCaseJsonEnumStringConverter<PrintOrientation>))]
6162
public enum PrintOrientation
6263
{
6364
Portrait,

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/UserPromptOpenedEventArgs.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2021
using System.Text.Json.Serialization;
2122

2223
namespace OpenQA.Selenium.BiDi.Modules.BrowsingContext;
@@ -28,7 +29,7 @@ public record UserPromptOpenedEventArgs(BiDi BiDi, BrowsingContext Context, User
2829
public string? DefaultValue { get; internal set; }
2930
}
3031

31-
[JsonConverter(typeof(JsonStringEnumConverter<UserPromptType>))]
32+
[JsonConverter(typeof(CamelCaseJsonEnumStringConverter<UserPromptType>))]
3233
public enum UserPromptType
3334
{
3435
Alert,

dotnet/src/webdriver/BiDi/Modules/Input/SourceActions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2021
using System;
2122
using System.Collections;
2223
using System.Collections.Generic;
@@ -147,7 +148,7 @@ public record PointerParameters
147148
public PointerType? PointerType { get; set; }
148149
}
149150

150-
[JsonConverter(typeof(JsonStringEnumConverter<PointerType>))]
151+
[JsonConverter(typeof(CamelCaseJsonEnumStringConverter<PointerType>))]
151152
public enum PointerType
152153
{
153154
Mouse,

dotnet/src/webdriver/BiDi/Modules/Log/Entry.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2021
using System;
2122
using System.Collections.Generic;
2223
using System.Text.Json.Serialization;
@@ -39,7 +40,7 @@ public record Javascript(BiDi BiDi, Level Level, Script.Source Source, string Te
3940
: Entry(BiDi, Level, Source, Text, Timestamp);
4041
}
4142

42-
[JsonConverter(typeof(JsonStringEnumConverter<Level>))]
43+
[JsonConverter(typeof(CamelCaseJsonEnumStringConverter<Level>))]
4344
public enum Level
4445
{
4546
Debug,

0 commit comments

Comments
 (0)