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

[🐛 Bug]: [dotnet] AOT changes have broken anonymous types #14731

Closed
RenderMichael opened this issue Nov 8, 2024 · 3 comments · Fixed by #14732
Closed

[🐛 Bug]: [dotnet] AOT changes have broken anonymous types #14731

RenderMichael opened this issue Nov 8, 2024 · 3 comments · Fixed by #14732

Comments

@RenderMichael
Copy link
Contributor

RenderMichael commented Nov 8, 2024

What happened?

Before the source-generated JSON serializer was introduced, anonymous types would serialize correctly. Now, an exception is thrown.

It's worth noting that there is nothing the source-generator can do to support anonymous types: dotnet/runtime#78164

There needs to be a fallback option.

Potentially found in aquality-automation/aquality-selenium-dotnet#265

How can we reproduce the issue?

var options = new ChromeOptions();
options.AddAdditionalOption("selenoid:options", new { enableVNC = true, enableVideo = false });

var driver = new ChromeDriver(options);

// If you go to `Command.s_jsonSerializerOptions` and comment out `TypeInfoResolver = CommandJsonSerializerContext.Default`, the above code works.

Relevant log output

System.NotSupportedException : JsonTypeInfo metadata for type '<>f__AnonymousType0`2[System.Boolean,System.Boolean]' was not provided by TypeInfoResolver of type 'OpenQA.Selenium.CommandJsonSerializerContext'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically. The unsupported member type is located on type 'System.Object'. Path: $.
  ----> System.NotSupportedException : JsonTypeInfo metadata for type '<>f__AnonymousType0`2[System.Boolean,System.Boolean]' was not provided by TypeInfoResolver of type 'OpenQA.Selenium.CommandJsonSerializerContext'. If using source generation, ensure that all root types passed to the serializer have been annotated with 'JsonSerializableAttribute', along with any types that might be serialized polymorphically.
ThrowHelper.ThrowNotSupportedException(WriteStack& state, NotSupportedException ex)
JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
JsonTypeInfo`1.Serialize(Utf8JsonWriter writer, T& rootValue, Object rootValueBoxed)
JsonSerializer.WriteString[TValue](TValue& value, JsonTypeInfo`1 jsonTypeInfo)
JsonSerializer.Serialize[TValue](TValue value, JsonSerializerOptions options)
Command.get_ParametersAsJsonString() line 105
HttpRequestInfo.ctor(Uri serverUri, Command commandToExecute, HttpCommandInfo commandInfo) line 372
HttpCommandExecutor.ExecuteAsync(Command commandToExecute) line 182
DriverServiceCommandExecutor.ExecuteAsync(Command commandToExecute) line 125
WebDriver.ExecuteAsync(String driverCommandToExecute, Dictionary`2 parameters) line 606


### Operating System

Windows 11

### Selenium version

`trunk`

### What are the browser(s) and version(s) where you see this issue?

N/A

### What are the browser driver(s) and version(s) where you see this issue?

N/A

### Are you using Selenium Grid?

No
Copy link

github-actions bot commented Nov 8, 2024

@RenderMichael, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@RenderMichael
Copy link
Contributor Author

Opened PR #14732 to fix this issue

Copy link

github-actions bot commented Dec 8, 2024

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant