From 216fb34daff43b8d67c5ff3cb030d82117696eff Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Mon, 7 Apr 2025 21:24:38 +0300 Subject: [PATCH] [dotnet] [bidi] Added missing GenericLogEntry log entry type in Script module --- .../Json/Converters/Polymorphic/LogEntryConverter.cs | 2 +- dotnet/src/webdriver/BiDi/Modules/Log/LogEntry.cs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Polymorphic/LogEntryConverter.cs b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Polymorphic/LogEntryConverter.cs index 17c917d3cd82a..fc72b2024fedc 100644 --- a/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Polymorphic/LogEntryConverter.cs +++ b/dotnet/src/webdriver/BiDi/Communication/Json/Converters/Polymorphic/LogEntryConverter.cs @@ -34,7 +34,7 @@ internal class LogEntryConverter : JsonConverter { "console" => JsonSerializer.Deserialize(ref reader, options.GetTypeInfo()), "javascript" => JsonSerializer.Deserialize(ref reader, options.GetTypeInfo()), - _ => null, + _ => JsonSerializer.Deserialize(ref reader, options.GetTypeInfo()), }; } diff --git a/dotnet/src/webdriver/BiDi/Modules/Log/LogEntry.cs b/dotnet/src/webdriver/BiDi/Modules/Log/LogEntry.cs index 5022ed0a5c6b7..e57761a9f2697 100644 --- a/dotnet/src/webdriver/BiDi/Modules/Log/LogEntry.cs +++ b/dotnet/src/webdriver/BiDi/Modules/Log/LogEntry.cs @@ -24,6 +24,7 @@ namespace OpenQA.Selenium.BiDi.Modules.Log; // https://github.com/dotnet/runtime/issues/72604 //[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")] +//[JsonDerivedType(typeof(GenericLogEntry))] // Fallback when discriminator is not recognized, we have to double check //[JsonDerivedType(typeof(ConsoleLogEntry), "console")] //[JsonDerivedType(typeof(JavascriptLogEntry), "javascript")] public abstract record LogEntry(BiDi BiDi, Level Level, Script.Source Source, string Text, DateTimeOffset Timestamp) @@ -32,6 +33,9 @@ public abstract record LogEntry(BiDi BiDi, Level Level, Script.Source Source, st public Script.StackTrace? StackTrace { get; set; } } +public record GenericLogEntry(BiDi BiDi, string Type, Level Level, Script.Source Source, string Text, DateTimeOffset Timestamp) + : LogEntry(BiDi, Level, Source, Text, Timestamp); + public record ConsoleLogEntry(BiDi BiDi, Level Level, Script.Source Source, string Text, DateTimeOffset Timestamp, string Method, IReadOnlyList Args) : LogEntry(BiDi, Level, Source, Text, Timestamp);