- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.6k
 
Closed
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!C-dotnet.NET Bindings.NET BindingsI-defectSomething is not working as intendedSomething is not working as intended
Description
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
Metadata
Metadata
Assignees
Labels
A-needs-triagingA Selenium member will evaluate this soon!A Selenium member will evaluate this soon!C-dotnet.NET Bindings.NET BindingsI-defectSomething is not working as intendedSomething is not working as intended