diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs index 32c3335a61bb3..113bcf76e7a34 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/BiDiJsonSerializerContext.cs @@ -122,7 +122,6 @@ namespace OpenQA.Selenium.BiDi.Communication.Json; [JsonSerializable(typeof(Modules.BrowsingContext.Origin), TypeInfoPropertyName = "BrowsingContext_Origin")] [JsonSerializable(typeof(Modules.Network.BytesValue.String), TypeInfoPropertyName = "Network_BytesValue_String")] -[JsonSerializable(typeof(Modules.Network.UrlPattern.String), TypeInfoPropertyName = "Network_UrlPattern_String")] [JsonSerializable(typeof(Modules.Network.ContinueWithAuthParameters.Default), TypeInfoPropertyName = "Network_ContinueWithAuthParameters_Default")] [JsonSerializable(typeof(Modules.Network.AddInterceptCommand))] [JsonSerializable(typeof(Modules.Network.AddInterceptResult))] diff --git a/dotnet/src/webdriver/BiDi/Modules/Network/UrlPattern.cs b/dotnet/src/webdriver/BiDi/Modules/Network/UrlPattern.cs index 1a83a7d4651cb..29823516fcfe0 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Network/UrlPattern.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Network/UrlPattern.cs @@ -22,27 +22,24 @@ namespace OpenQA.Selenium.BiDi.Modules.Network; [JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] -[JsonDerivedType(typeof(Pattern), "pattern")] -[JsonDerivedType(typeof(String), "string")] +[JsonDerivedType(typeof(PatternUrlPattern), "pattern")] +[JsonDerivedType(typeof(StringUrlPattern), "string")] public abstract record UrlPattern { - public static implicit operator UrlPattern(string value) => new String(value); - - public record Pattern : UrlPattern - { - public string? Protocol { get; set; } + public static implicit operator UrlPattern(string value) => new StringUrlPattern(value); +} - public string? Hostname { get; set; } +public record PatternUrlPattern : UrlPattern +{ + public string? Protocol { get; set; } - public string? Port { get; set; } + public string? Hostname { get; set; } - public string? Pathname { get; set; } + public string? Port { get; set; } - public string? Search { get; set; } - } + public string? Pathname { get; set; } - public record String(string Pattern) : UrlPattern - { - public new string Pattern { get; } = Pattern; - } + public string? Search { get; set; } } + +public record StringUrlPattern(string Pattern) : UrlPattern; diff --git a/dotnet/test/common/BiDi/Network/NetworkTest.cs b/dotnet/test/common/BiDi/Network/NetworkTest.cs index 3ffc72e551a83..9a6c457e69e0e 100644 --- a/dotnet/test/common/BiDi/Network/NetworkTest.cs +++ b/dotnet/test/common/BiDi/Network/NetworkTest.cs @@ -40,7 +40,7 @@ public async Task CanAddInterceptStringUrlPattern() await using var intercept = await bidi.Network.InterceptRequestAsync(e => Task.CompletedTask, new() { UrlPatterns = [ - new UrlPattern.String("http://localhost:4444/"), + new StringUrlPattern("http://localhost:4444/"), "http://localhost:4444/" ] }); @@ -53,7 +53,7 @@ public async Task CanAddInterceptUrlPattern() { await using var intercept = await bidi.Network.InterceptRequestAsync(e => Task.CompletedTask, interceptOptions: new() { - UrlPatterns = [new UrlPattern.Pattern() + UrlPatterns = [new PatternUrlPattern() { Hostname = "localhost", Protocol = "http"