diff --git a/dotnet/src/webdriver/SeleniumManager.cs b/dotnet/src/webdriver/SeleniumManager.cs index 887978a107f37..5e2f99c46fa98 100644 --- a/dotnet/src/webdriver/SeleniumManager.cs +++ b/dotnet/src/webdriver/SeleniumManager.cs @@ -40,8 +40,6 @@ public static class SeleniumManager { private static readonly ILogger _logger = Log.GetLogger(typeof(SeleniumManager)); - private static readonly JsonSerializerOptions _serializerOptions = new() { PropertyNameCaseInsensitive = true, TypeInfoResolver = SeleniumManagerSerializerContext.Default }; - private static readonly Lazy _lazyBinaryFullPath = new(() => { string? binaryFullPath = Environment.GetEnvironmentVariable("SE_MANAGER_PATH"); @@ -187,7 +185,7 @@ private static ResultResponse RunCommand(string fileName, string arguments) try { - jsonResponse = JsonSerializer.Deserialize(output, _serializerOptions)!; + jsonResponse = JsonSerializer.Deserialize(output, SeleniumManagerSerializerContext.Default.SeleniumManagerResponse)!; } catch (Exception ex) { @@ -210,11 +208,11 @@ private static ResultResponse RunCommand(string fileName, string arguments) } } - internal record SeleniumManagerResponse(IReadOnlyList Logs, ResultResponse Result) + internal sealed record SeleniumManagerResponse(IReadOnlyList Logs, ResultResponse Result) { - public record LogEntryResponse(string Level, string Message); + public sealed record LogEntryResponse(string Level, string Message); - public record ResultResponse + public sealed record ResultResponse ( [property: JsonPropertyName("driver_path")] string DriverPath, @@ -224,5 +222,6 @@ string BrowserPath } [JsonSerializable(typeof(SeleniumManagerResponse))] - internal partial class SeleniumManagerSerializerContext : JsonSerializerContext; + [JsonSourceGenerationOptions(PropertyNameCaseInsensitive = true)] + internal sealed partial class SeleniumManagerSerializerContext : JsonSerializerContext; }