Skip to content

[dotnet] Avoid serializing to JSON in ToString() methods. #14741

@RenderMichael

Description

@RenderMichael

Feature and motivation

There are a few types whose ToString() methods will serialize the contents into a JSON representation. This has some drawbacks

  • Performance: This operation is heaver than a ToString() method should be. This is especially noticeable when using the debugger display.
  • AOT: These methods are on types which contain open-typed object values, which is inherently not AOT-safe. This can throw exceptions in AOT scenarios, which ToString() methods should never do. Of less concern is the fact that, since the ToString() method is basically always rooted, these operations will never be trimmed away, and AOT programs may be larger than they need to be.

Each of the relevant types are strongly-typed dictionaries. For reference, the standard convention for dictionary types is to avoid overriding the ToString() method.

The following types are affected:

  • DriverOptions (the base class for all browser options types)
  • ReturnedCapabilities (internal class)
  • RemoteSessionSettings

Usage example

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!C-dotnet.NET BindingsI-enhancementSomething could be better

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions