Skip to content

[dotnet] [bidi] Remove enumerable json converter for Input module#17285

Merged
nvborisenko merged 8 commits intoSeleniumHQ:trunkfrom
nvborisenko:bidi-enumerable-input-dto
Apr 1, 2026
Merged

[dotnet] [bidi] Remove enumerable json converter for Input module#17285
nvborisenko merged 8 commits intoSeleniumHQ:trunkfrom
nvborisenko:bidi-enumerable-input-dto

Conversation

@nvborisenko
Copy link
Copy Markdown
Member

@nvborisenko nvborisenko commented Apr 1, 2026

Don't try to mix high-level and DTO serializable behaviour. Be truly low-level.

🔗 Related Issues

Contrinutes to #16095

💥 What does this PR do?

This pull request significantly refactors the BiDi Input Actions model in the .NET WebDriver codebase, simplifying and modernizing the type hierarchy, improving serialization, and updating usages in tests. The changes remove legacy code and custom serialization logic, unify the action type structure, and update tests to use the new model.

Core model and serialization refactor:

  • Refactored the SourceActions hierarchy to use modern C# records and type-safe generics, replacing the previous inheritance and interface-based approach. The new structure uses discriminated unions for action types, and moves from mutable collections to immutable IEnumerable properties. (dotnet/src/webdriver/BiDi/Input/SourceActions.cs, dotnet/src/webdriver/BiDi/Input/SourceActions.csL20-R50)
  • Updated all action records (e.g., KeySourceActions, PointerSourceActions, WheelSourceActions, NoneSourceActions) to the new structure, and replaced int properties with long for better consistency and range. (dotnet/src/webdriver/BiDi/Input/SourceActions.cs, [1] [2]
  • Removed the obsolete SequentialSourceActions and related types, as well as the custom InputSourceActionsConverter used for serialization. The new structure relies on built-in polymorphic serialization. (dotnet/src/webdriver/BiDi/Input/SequentialSourceActions.cs, [1]; dotnet/src/webdriver/BiDi/Json/Converters/Enumerable/InputSourceActionsConverter.cs, [2]
  • Cleaned up the InputJsonSerializerContext by removing unused enumerable serializable types, since they are no longer needed with the new model. (dotnet/src/webdriver/BiDi/Input/InputModule.cs, dotnet/src/webdriver/BiDi/Input/InputModule.csL78-L81)

Test updates:

  • Updated all usages in tests to use the new *SourceActions records with immutable lists, and adjusted test logic to match the new API, including more explicit pointer and key action sequences. (dotnet/test/webdriver/BiDi/Input/CombinedInputActionsTests.cs, [1] [2]

These changes modernize the codebase, reduce complexity, and improve maintainability for BiDi Input Actions.

References:
[1] [2] [3] [4] [5] [6] [7] [8]

💡 Additional Considerations

Still using IList, kind of opening doors for Builders. Revisit later.

🔄 Types of changes

  • Cleanup (formatting, renaming)
  • Breaking change (fix or feature that would cause existing functionality to change)

Copilot AI review requested due to automatic review settings April 1, 2026 13:10
@selenium-ci selenium-ci added the C-dotnet .NET Bindings label Apr 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the .NET BiDi Input actions model to remove the custom enumerable JSON converter and rely on System.Text.Json polymorphic serialization, making construction of action sequences explicit via action lists.

Changes:

  • Reworked SourceActions and concrete action source types (KeyActions, PointerActions, etc.) to take explicit IList<TAction> action lists instead of behaving like enumerables.
  • Removed the InputSourceActionsConverter and related enumerable JsonSerializable entries, switching to attribute-based polymorphic serialization.
  • Updated BiDi Input tests to use the new constructor-based action list API.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
dotnet/test/webdriver/BiDi/Input/CombinedInputActionsTests.cs Updates test call sites to construct SourceActions with explicit action lists.
dotnet/src/webdriver/BiDi/Json/Converters/Enumerable/InputSourceActionsConverter.cs Removes the now-unneeded custom SourceActions JSON converter.
dotnet/src/webdriver/BiDi/Input/SourceActions.cs Introduces polymorphic serialization attributes and refactors the SourceActions type hierarchy / action record types.
dotnet/src/webdriver/BiDi/Input/InputModule.cs Removes source-gen registrations that were previously needed by the custom converter.

Copilot AI review requested due to automatic review settings April 1, 2026 16:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings April 1, 2026 18:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@nvborisenko nvborisenko merged commit 3c525d8 into SeleniumHQ:trunk Apr 1, 2026
18 of 19 checks passed
@nvborisenko nvborisenko deleted the bidi-enumerable-input-dto branch April 1, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-dotnet .NET Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants