[dotnet] [bidi] Simplify context aware command options by nvborisenko · Pull Request #16954 · SeleniumHQ/selenium
Conversation
User description
💥 What does this PR do?
- Rename
BrowsingContext*OptionstoContext*Options - Propagate
Timeoutcommand property - Align context options with its parent (class instead of record)
🔄 Types of changes
- Cleanup (formatting, renaming)
- Bug fix (backwards compatible)
- Breaking change (fix or feature that would cause existing functionality to change)
PR Type
Enhancement, Bug fix
Description
-
Rename
BrowsingContext*OptionstoContext*Optionsfor consistency -
Convert context options from records to classes inheriting
CommandOptions -
Propagate
Timeoutproperty from context options to command options -
Align context-aware command options with parent class structure
Diagram Walkthrough
flowchart LR
A["BrowsingContext*Options<br/>records"] -- "rename to" --> B["Context*Options<br/>classes"]
B -- "inherit from" --> C["CommandOptions"]
C -- "provides" --> D["Timeout property"]
B -- "propagate to" --> E["Command Options"]
File Walkthrough
| Relevant files | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Refactoring |
|
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
| Security Compliance | |
| 🟢 | No security concerns identifiedNo security vulnerabilities detected by AI analysis. Human verification advised for critical code. |
| Ticket Compliance | |
| ⚪ | 🎫 No ticket provided
|
| Codebase Duplication Compliance | |
| ⚪ | Codebase context is not definedFollow the guide to enable codebase context checks. |
| Custom Compliance | |
| 🟢 |
Generic: Comprehensive Audit TrailsObjective: To create a detailed and reliable record of critical system actions for security analysis Status: Passed
|
Generic: Meaningful Naming and Self-Documenting CodeObjective: Ensure all identifiers clearly express their purpose and intent, making code Status: Passed
| |
Generic: Robust Error Handling and Edge Case ManagementObjective: Ensure comprehensive error handling that provides meaningful context and graceful Status: Passed
| |
Generic: Secure Error HandlingObjective: To prevent the leakage of sensitive system information through error messages while Status: Passed
| |
Generic: Secure Logging PracticesObjective: To ensure logs are useful for debugging and auditing without exposing sensitive Status: Passed
| |
Generic: Security-First Input Validation and Data HandlingObjective: Ensure all data inputs are validated, sanitized, and handled securely to prevent Status: Passed
| |
| |
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
PR Code Suggestions ✨
Explore these optional code suggestions:
| Category | Suggestion | Impact |
| Learned best practice |
Add fast argument validationValidate dotnet/src/webdriver/BiDi/BrowsingContext/BrowsingContextNetworkModule.cs [83-91] public Task<AddDataCollectorResult> AddDataCollectorAsync(IEnumerable<DataType> dataTypes, int maxEncodedDataSize, ContextAddDataCollectorOptions? options = null)
{
+ ArgumentNullException.ThrowIfNull(dataTypes);
+ ArgumentOutOfRangeException.ThrowIfNegative(maxEncodedDataSize);
+
AddDataCollectorOptions addDataCollectorOptions = new(options)
{
Contexts = [context]
};
return networkModule.AddDataCollectorAsync(dataTypes, maxEncodedDataSize, addDataCollectorOptions);
}
Suggestion importance[1-10]: 6__ Why: | Low |
Defensively copy caller collectionsCopy caller-provided enumerables (e.g., via dotnet/src/webdriver/BiDi/Network/AddDataCollectorCommand.cs [33-38] internal AddDataCollectorOptions(ContextAddDataCollectorOptions? options) : this()
{
CollectorType = options?.CollectorType;
- UserContexts = options?.UserContexts;
+ UserContexts = options?.UserContexts is null ? null : options.UserContexts.ToArray();
Timeout = options?.Timeout;
}
Suggestion importance[1-10]: 5__ Why: | Low | |
| General |
Make base options class abstractMark the dotnet/src/webdriver/BiDi/Network/AddInterceptCommand.cs [46-49] -public class ContextAddInterceptOptions : CommandOptions +public abstract class ContextAddInterceptOptions : CommandOptions { public IEnumerable<UrlPattern>? UrlPatterns { get; set; } }
Suggestion importance[1-10]: 5__ Why: The suggestion correctly identifies that | Low |
✅
| Low | |
| ||
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look good. I left one comment, not blocking the PR, about taking these changes even further.
This was referenced
Feb 20, 2026This was referenced
Feb 22, 2026This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters