Skip to content

[dotnet] [bidi] Testing infra for custom module#17306

Merged
nvborisenko merged 2 commits intoSeleniumHQ:trunkfrom
nvborisenko:bidi-public-custom-module
Apr 6, 2026
Merged

[dotnet] [bidi] Testing infra for custom module#17306
nvborisenko merged 2 commits intoSeleniumHQ:trunkfrom
nvborisenko:bidi-public-custom-module

Conversation

@nvborisenko
Copy link
Copy Markdown
Member

Ability to declare custom bidi modules. Negotiated how to test internal logging via making some functionality publicly available. It is OK if we consider to expose it as separate package.

💥 What does this PR do?

This pull request makes several significant changes to the WebDriver .NET codebase, primarily focused on increasing the visibility of key APIs and types, removing internal access restrictions, and adding new tests for module extensibility. These updates improve the public API surface, facilitate external usage and testing, and introduce a pattern for custom modules.

Public API and Visibility Changes:

  • Changed several types and methods from internal to public, including ILogger, ILogContext, and logging methods in Log, making them accessible outside the assembly. (dotnet/src/webdriver/Internal/Logging/ILogger.cs, dotnet/src/webdriver/Internal/Logging/ILogContext.cs, dotnet/src/webdriver/Internal/Logging/Log.cs) [1] [2] [3] [4] [5]
  • Changed Command<TParameters, TResult> and related classes in the BiDi namespace from internal to public to allow external extension and usage. (dotnet/src/webdriver/BiDi/Command.cs)

Removal of Internal Access Restrictions:

  • Removed all InternalsVisibleTo settings from both BUILD.bazel and .csproj files, meaning internal types are no longer exposed to the test assembly and tests must now use only public APIs. (dotnet/src/webdriver/BUILD.bazel, dotnet/src/webdriver/Selenium.WebDriver.csproj) [1] [2] [3] [4]

Testing and Extensibility Improvements:

  • Added new tests for custom module extensibility in BiDi, including a sample CustomModule, command, and result types, demonstrating that modules can be extended and commands executed using the new public API. (dotnet/test/webdriver/BiDi/Session/SessionTests.cs) [1] [2]

Minor Test Code Updates:

  • Removed an obsolete test for null log handlers and modernized collection initialization in logging tests. (dotnet/test/webdriver/Internal/Logging/LogTests.cs) [1] [2]

🔄 Types of changes

  • Cleanup (formatting, renaming)
  • New feature (non-breaking change which adds functionality and tests!)

Copilot AI review requested due to automatic review settings April 6, 2026 12:36
@selenium-ci selenium-ci added C-dotnet .NET Bindings B-build Includes scripting, bazel and CI integrations labels Apr 6, 2026
@qodo-code-review
Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Expose logging and BiDi APIs for custom module extensibility

✨ Enhancement 🧪 Tests

Grey Divider

Walkthroughs

Description
• Expose logging APIs and BiDi command classes to public API
• Remove internal visibility restrictions from test assembly
• Add tests for custom module extensibility pattern
• Demonstrate custom module implementation with sample code

Grey Divider

File Changes

1. dotnet/src/webdriver/BiDi/Command.cs ✨ Enhancement +2/-2

Make BiDi command classes publicly accessible

• Changed Command<TParameters, TResult> class from internal to public
• Changed Parameters record from internal to public
• Enables external creation and extension of BiDi commands

dotnet/src/webdriver/BiDi/Command.cs


2. dotnet/src/webdriver/Internal/Logging/ILogger.cs ✨ Enhancement +1/-1

Expose ILogger interface publicly

• Changed ILogger interface from internal to public
• Allows external code to implement and use logging interface

dotnet/src/webdriver/Internal/Logging/ILogger.cs


3. dotnet/src/webdriver/Internal/Logging/ILogContext.cs ✨ Enhancement +2/-2

Make logger retrieval methods publicly accessible

• Changed GetLogger<T>() method from internal to public
• Changed GetLogger(Type type) method from internal to public
• Enables external access to logger retrieval functionality

dotnet/src/webdriver/Internal/Logging/ILogContext.cs


View more (5)
4. dotnet/src/webdriver/Internal/Logging/Log.cs ✨ Enhancement +3/-3

Expose Log class methods and properties publicly

• Changed CurrentContext property from internal to public
• Changed GetLogger<T>() method from internal to public
• Changed GetLogger(Type type) method from internal to public
• Exposes logging context and logger access to public API

dotnet/src/webdriver/Internal/Logging/Log.cs


5. dotnet/src/webdriver/BUILD.bazel ⚙️ Configuration changes +0/-9

Remove internal visibility restrictions from Bazel build

• Removed internals_visible_to attribute from three csharp_library targets
• Eliminates internal visibility access for test assembly across all framework versions
• Forces tests to use only public APIs

dotnet/src/webdriver/BUILD.bazel


6. dotnet/src/webdriver/Selenium.WebDriver.csproj ⚙️ Configuration changes +0/-4

Remove internal visibility from project configuration

• Removed InternalsVisibleTo ItemGroup targeting WebDriver.Tests
• Eliminates internal visibility access for test assembly in project file

dotnet/src/webdriver/Selenium.WebDriver.csproj


7. dotnet/test/webdriver/BiDi/Session/SessionTests.cs 🧪 Tests +46/-0

Add custom module extensibility tests and sample implementation

• Added imports for System.Text.Json and OpenQA.Selenium.BiDi
• Added test for AsModule<T>() returning same instance for same type
• Added test for custom module command execution
• Implemented CustomModule class extending Module base class
• Created DoSomethingCommand, DoSomethingResult, and DoSomethingOptions types
• Demonstrated custom module pattern with JSON serialization context

dotnet/test/webdriver/BiDi/Session/SessionTests.cs


8. dotnet/test/webdriver/Internal/Logging/LogTests.cs 🧪 Tests +1/-9

Update logging tests for public API usage

• Removed test ShouldCreateContextWithNullLogHandlers that relied on internal constructor
• Changed list initialization from new List<LogEvent>() to collection initializer []
• Adapts tests to use only public APIs after removing internal visibility

dotnet/test/webdriver/Internal/Logging/LogTests.cs


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review bot commented Apr 6, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

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

This PR expands the .NET WebDriver/BiDi public API surface to support extensibility (custom BiDi modules) and adapts the test suite accordingly after removing internal test access.

Changes:

  • Exposes previously-internal logging APIs (ILogger, ILogContext members, and Log accessors) as public.
  • Makes core BiDi command primitives (Command<TParameters, TResult>, Parameters) public to enable external/custom module implementations.
  • Removes InternalsVisibleTo and adds BiDi tests demonstrating custom module caching and command execution.

Reviewed changes

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

Show a summary per file
File Description
dotnet/test/webdriver/Internal/Logging/LogTests.cs Adjusts logging tests after visibility changes; updates test handler initialization.
dotnet/test/webdriver/BiDi/Session/SessionTests.cs Adds tests and sample types to validate custom module extensibility.
dotnet/src/webdriver/Selenium.WebDriver.csproj Removes InternalsVisibleTo to stop exposing internals to the test assembly.
dotnet/src/webdriver/Internal/Logging/Log.cs Makes CurrentContext and GetLogger APIs public.
dotnet/src/webdriver/Internal/Logging/ILogger.cs Makes ILogger public.
dotnet/src/webdriver/Internal/Logging/ILogContext.cs Makes logger retrieval methods publicly accessible on ILogContext.
dotnet/src/webdriver/BUILD.bazel Removes Bazel internals_visible_to configuration for tests.
dotnet/src/webdriver/BiDi/Command.cs Makes BiDi command base types public for external extension.

@nvborisenko nvborisenko merged commit 54ab290 into SeleniumHQ:trunk Apr 6, 2026
26 checks passed
@nvborisenko nvborisenko deleted the bidi-public-custom-module branch April 6, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations C-dotnet .NET Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants