Skip to content

[dotnet] [bidi] Unify all event arguments to be *EventArgs#17125

Merged
nvborisenko merged 4 commits into
SeleniumHQ:trunkfrom
nvborisenko:bidi-event-args
Feb 21, 2026
Merged

[dotnet] [bidi] Unify all event arguments to be *EventArgs#17125
nvborisenko merged 4 commits into
SeleniumHQ:trunkfrom
nvborisenko:bidi-event-args

Conversation

@nvborisenko

Copy link
Copy Markdown
Member

Now all types are *EventArgs, pretty consistent.

🔗 Related Issues

Contributes to #15546

🔄 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 February 21, 2026 10:10
@selenium-ci selenium-ci added the C-dotnet .NET Bindings label Feb 21, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Type

Enhancement, Other


Description

  • Rename all BiDi event argument types to follow *EventArgs naming convention

  • Create new *EventArgs classes: BrowsingContextEventArgs, NavigationEventArgs, FileDialogEventArgs, LogEntryEventArgs

  • Update all event handler signatures across modules to use new EventArgs types

  • Maintain backward compatibility by keeping original Info classes without EventArgs inheritance


File Walkthrough

Relevant files
Enhancement
2 files
BrowsingContextEventArgs.cs
Create new BrowsingContextEventArgs sealed record               
+23/-0   
NavigationEventArgs.cs
Create new NavigationEventArgs sealed record                         
+23/-0   
Refactoring
11 files
BrowsingContextInfo.cs
Remove EventArgs inheritance from BrowsingContextInfo       
+1/-2     
BrowsingContext.cs
Update navigation event handlers to use NavigationEventArgs
+28/-28 
BrowsingContextInputModule.cs
Update file dialog handlers to use FileDialogEventArgs     
+4/-4     
BrowsingContextLogModule.cs
Update log entry handlers to use LogEntryEventArgs             
+4/-4     
BrowsingContextModule.cs
Update all event subscriptions to use new EventArgs types
+38/-38 
NavigationInfo.cs
Remove EventArgs inheritance from NavigationInfo                 
+1/-1     
FileDialogEventArgs.cs
Rename FileDialogInfo to FileDialogEventArgs                         
+2/-2     
InputModule.cs
Update file dialog event subscriptions to use FileDialogEventArgs
+5/-5     
LogEntryEventArgsConverter.cs
Rename LogEntryConverter and update to handle LogEntryEventArgs
+7/-7     
LogEntryEventArgs.cs
Rename LogEntry and derived types to *EventArgs variants 
+12/-12 
LogModule.cs
Update log entry event subscriptions to use LogEntryEventArgs
+9/-9     
Tests
3 files
InputEventsTests.cs
Update test to use FileDialogEventArgs type                           
+1/-1     
LogTests.cs
Update tests to use LogEntryEventArgs and derived types   
+6/-6     
ScriptCommandsTests.cs
Update test to use LogEntryEventArgs type                               
+1/-1     

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🟡
🎫 #15546
🟢
🔴 If accepting mutability, rename event argument types to match the spec-defined names
(i.e., without an EventArgs suffix).
Consider converting the base EventArgs type to an IEventArgs interface to support
potential spec-defined inheritance.
Decide/adjust the design of BiDi event argument types with respect to immutability (either
make *EventArgs immutable or accept mutability).
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Unimplemented JSON write: The new LogEntryEventArgsConverter.Write throws NotImplementedException, which may cause
runtime failures if serialization of LogEntryEventArgs is ever invoked.

Referred Code
public override void Write(Utf8JsonWriter writer, LogEntryEventArgs value, JsonSerializerOptions options)
{
    throw new NotImplementedException();
}

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Mark old record obsolete

Add the [Obsolete] attribute to the NavigationInfo record to indicate it has
been replaced by NavigationEventArgs.

dotnet/src/webdriver/BiDi/BrowsingContext/NavigationInfo.cs [22-23]

+[Obsolete("Use NavigationEventArgs instead")]
 public sealed record NavigationInfo(BrowsingContext Context, Navigation? Navigation, DateTimeOffset Timestamp, string Url, Browser.UserContext? UserContext)
     : IBaseNavigationInfo;
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: This is a valuable suggestion for maintainability, as marking the now-unused NavigationInfo record as obsolete will guide developers to use the new NavigationEventArgs and prevent accidental use of the old type.

Low
Implement converter Write method

Implement the Write method in LogEntryEventArgsConverter to support
serialization, replacing the current NotImplementedException.

dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/LogEntryEventArgsConverter.cs [39-42]

 public override void Write(Utf8JsonWriter writer, LogEntryEventArgs value, JsonSerializerOptions options)
 {
-    throw new NotImplementedException();
+    JsonSerializer.Serialize(writer, (object)value, options);
 }
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why: This is a good suggestion to complete the implementation of the LogEntryEventArgsConverter, making it fully functional for both serialization and deserialization, which improves code completeness.

Low
Learned
best practice
Use property-based EventArgs types

Convert the positional record to a sealed class (or non-positional record) with
explicit properties so call sites remain readable and new fields can be added
without breaking the constructor signature.

dotnet/src/webdriver/BiDi/BrowsingContext/NavigationEventArgs.cs [22-23]

-public sealed record NavigationEventArgs(BrowsingContext Context, Navigation? Navigation, DateTimeOffset Timestamp, string Url, Browser.UserContext? UserContext)
-    : EventArgs, IBaseNavigationInfo;
+public sealed class NavigationEventArgs : EventArgs, IBaseNavigationInfo
+{
+    public NavigationEventArgs(BrowsingContext context, Navigation? navigation, DateTimeOffset timestamp, string url, Browser.UserContext? userContext)
+    {
+        Context = context;
+        Navigation = navigation;
+        Timestamp = timestamp;
+        Url = url;
+        UserContext = userContext;
+    }
 
+    public BrowsingContext Context { get; }
+    public Navigation? Navigation { get; }
+    public DateTimeOffset Timestamp { get; }
+    public string Url { get; }
+    public Browser.UserContext? UserContext { get; }
+}
+
  • Apply / Chat
Suggestion importance[1-10]: 5

__

Why:
Relevant best practice - For public .NET APIs, prefer EventArgs classes with named properties over positional records to improve readability and allow non-breaking extensibility.

Low
  • More

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 unifies the naming convention for BiDi event argument types to consistently use the *EventArgs suffix, addressing issue #15546. The change improves API consistency by ensuring all event handler parameters follow the same naming pattern.

Changes:

  • Renamed LogEntry and derived types (ConsoleLogEntry, JavascriptLogEntry, GenericLogEntry) to *LogEntryEventArgs
  • Renamed FileDialogInfo to FileDialogEventArgs
  • Created NavigationEventArgs (while keeping NavigationInfo as a data type for implementing IBaseNavigationInfo)
  • Created BrowsingContextEventArgs (while keeping BrowsingContextInfo as a data type used in results)

Reviewed changes

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

Show a summary per file
File Description
dotnet/src/webdriver/BiDi/Log/LogEntryEventArgs.cs Renamed file and types from LogEntry to LogEntryEventArgs hierarchy
dotnet/src/webdriver/BiDi/Log/LogModule.cs Updated method signatures and JSON context to use LogEntryEventArgs
dotnet/src/webdriver/BiDi/Input/FileDialogEventArgs.cs Renamed file and type from FileDialogInfo to FileDialogEventArgs
dotnet/src/webdriver/BiDi/Input/InputModule.cs Updated method signatures and JSON context to use FileDialogEventArgs
dotnet/src/webdriver/BiDi/BrowsingContext/NavigationEventArgs.cs Created new EventArgs type for navigation events
dotnet/src/webdriver/BiDi/BrowsingContext/NavigationInfo.cs Removed EventArgs inheritance, keeping as data type
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextEventArgs.cs Created new EventArgs type for browsing context events
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInfo.cs Removed EventArgs inheritance, keeping as data type
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextModule.cs Updated all event handler signatures and JSON context
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContext.cs Updated all navigation event handler signatures
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextLogModule.cs Updated log entry handler signatures
dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextInputModule.cs Updated file dialog handler signatures
dotnet/src/webdriver/BiDi/Json/Converters/Polymorphic/LogEntryEventArgsConverter.cs Renamed converter class and updated all type references
dotnet/test/common/BiDi/Log/LogTests.cs Updated test code to use new EventArgs types
dotnet/test/common/BiDi/Input/InputEventsTests.cs Updated test code to use FileDialogEventArgs
dotnet/test/common/BiDi/Script/ScriptCommandsTests.cs Updated test code to use Log.LogEntryEventArgs

@nvborisenko nvborisenko merged commit 404100c into SeleniumHQ:trunk Feb 21, 2026
26 of 27 checks passed
@nvborisenko nvborisenko deleted the bidi-event-args branch February 21, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants