Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dotnet] Make Selenium Manager's AOT safety explicit #14733

Merged
merged 1 commit into from
Nov 8, 2024
Merged
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
13 changes: 6 additions & 7 deletions dotnet/src/webdriver/SeleniumManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> _lazyBinaryFullPath = new(() =>
{
string? binaryFullPath = Environment.GetEnvironmentVariable("SE_MANAGER_PATH");
Expand Down Expand Up @@ -187,7 +185,7 @@ private static ResultResponse RunCommand(string fileName, string arguments)

try
{
jsonResponse = JsonSerializer.Deserialize<SeleniumManagerResponse>(output, _serializerOptions)!;
jsonResponse = JsonSerializer.Deserialize(output, SeleniumManagerSerializerContext.Default.SeleniumManagerResponse)!;
}
catch (Exception ex)
{
Expand All @@ -210,11 +208,11 @@ private static ResultResponse RunCommand(string fileName, string arguments)
}
}

internal record SeleniumManagerResponse(IReadOnlyList<LogEntryResponse> Logs, ResultResponse Result)
internal sealed record SeleniumManagerResponse(IReadOnlyList<LogEntryResponse> 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,
Expand All @@ -224,5 +222,6 @@ string BrowserPath
}

[JsonSerializable(typeof(SeleniumManagerResponse))]
internal partial class SeleniumManagerSerializerContext : JsonSerializerContext;
[JsonSourceGenerationOptions(PropertyNameCaseInsensitive = true)]
internal sealed partial class SeleniumManagerSerializerContext : JsonSerializerContext;
}
Loading