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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dotnet/src/webdriver/BiDi/Browser/ClientWindowInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Browser;

public sealed record ClientWindowInfo(bool Active, ClientWindow ClientWindow, ClientWindowState State, int Height, int Width, int X, int Y);

[JsonConverter(typeof(CamelCaseEnumConverter<ClientWindowState>))]
public enum ClientWindowState
{
Fullscreen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System;
using System.Text.Json.Serialization;

Expand All @@ -37,6 +38,7 @@ public sealed class CaptureScreenshotOptions : CommandOptions
public ClipRectangle? Clip { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ScreenshotOrigin>))]
public enum ScreenshotOrigin
{
Viewport,
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/CreateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

Expand All @@ -35,6 +37,7 @@ public sealed class CreateOptions : CommandOptions
public Browser.UserContext? UserContext { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ContextType>))]
public enum ContextType
{
Tab,
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/Locator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;
Expand Down Expand Up @@ -54,6 +55,7 @@ public sealed record AccessibilityValue

public sealed record ContextValue(BrowsingContext Context);

[JsonConverter(typeof(CamelCaseEnumConverter<MatchType>))]
public enum MatchType
{
Full,
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/NavigateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

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

[JsonConverter(typeof(CamelCaseEnumConverter<ReadinessState>))]
public enum ReadinessState
{
None,
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/BrowsingContext/PrintCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;

Expand Down Expand Up @@ -56,6 +58,7 @@ public struct PrintMargin
public double? Top { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<PrintOrientation>))]
public enum PrintOrientation
{
Portrait,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.BrowsingContext;
Expand All @@ -28,6 +29,7 @@ public sealed record UserPromptOpenedEventArgs(BiDi BiDi, BrowsingContext Contex
public string? DefaultValue { get; internal set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<UserPromptType>))]
public enum UserPromptType
{
Alert,
Expand Down
3 changes: 0 additions & 3 deletions dotnet/src/webdriver/BiDi/Communication/Broker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,11 @@ internal Broker(BiDi bidi, Uri url)
new InternalIdConverter(_bidi),
new PreloadScriptConverter(_bidi),
new RealmConverter(_bidi),
new RealmTypeConverter(),
new ScreenOrientationTypeConverter(),
new DateTimeOffsetConverter(),
new PrintPageRangeConverter(),
new InputOriginConverter(),
new WebExtensionConverter(_bidi),
new SubscriptionConverter(),
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase),

// https://github.com/dotnet/runtime/issues/72604
new Json.Converters.Polymorphic.EvaluateResultConverter(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <copyright file="CamelCaseEnumConverter.cs" company="Selenium Committers">
// 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.
// </copyright>

using System;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;

public class CamelCaseEnumConverter<TEnum>() :
JsonStringEnumConverter<TEnum>(JsonNamingPolicy.CamelCase) where TEnum : struct, Enum;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// <copyright file="KebabCaseEnumConverter.cs" company="Selenium Committers">
// 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.
// </copyright>

using System;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Communication.Json.Converters;

public class KebabCaseEnumConverter<TEnum>() :
JsonStringEnumConverter<TEnum>(JsonNamingPolicy.KebabCaseLower) where TEnum : struct, Enum;

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Emulation;

Expand All @@ -35,6 +36,7 @@ public sealed class SetForcedColorsModeThemeOverrideOptions : CommandOptions
public IEnumerable<Browser.UserContext>? UserContexts { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ForcedColorsModeTheme>))]
public enum ForcedColorsModeTheme
{
Light,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication;
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using OpenQA.Selenium.BiDi.Communication;

namespace OpenQA.Selenium.BiDi.Emulation;

Expand All @@ -35,12 +36,14 @@ public sealed class SetScreenOrientationOverrideOptions : CommandOptions
public IEnumerable<Browser.UserContext>? UserContexts { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<ScreenOrientationNatural>))]
public enum ScreenOrientationNatural
{
Portrait,
Landscape
}

[JsonConverter(typeof(KebabCaseEnumConverter<ScreenOrientationType>))]
public enum ScreenOrientationType
{
PortraitPrimary,
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/webdriver/BiDi/Input/SourceActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -144,6 +145,7 @@ public sealed record PointerParameters
public PointerType? PointerType { get; set; }
}

[JsonConverter(typeof(CamelCaseEnumConverter<PointerType>))]
public enum PointerType
{
Mouse,
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/webdriver/BiDi/Log/LogEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
// under the License.
// </copyright>

using OpenQA.Selenium.BiDi.Communication.Json.Converters;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace OpenQA.Selenium.BiDi.Log;

Expand All @@ -42,6 +44,7 @@ public sealed record ConsoleLogEntry(BiDi BiDi, Level Level, Script.Source Sourc
public sealed record JavascriptLogEntry(BiDi BiDi, Level Level, Script.Source Source, string? Text, DateTimeOffset Timestamp)
: LogEntry(BiDi, Level, Source, Text, Timestamp);

[JsonConverter(typeof(CamelCaseEnumConverter<Level>))]
public enum Level
{
Debug,
Expand Down
Loading