Skip to content

[dotnet] [bidi] Protect DTO types from inheritance #15919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 20, 2025

Conversation

nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Jun 19, 2025

User description

Classes/records in BiDi namespace are not supposed to be inherited.

💥 What does this PR do?

Adds sealed modifier for them.

🔧 Implementation Notes

💡 Additional Considerations

🔄 Types of changes

  • Cleanup (formatting, renaming)
  • Bug fix (backwards compatible)
  • New feature (non-breaking change which adds functionality and tests!)
  • Breaking change (fix or feature that would cause existing functionality to change)

PR Type

Other


Description

• Add sealed modifier to BiDi DTO classes and records
• Prevent inheritance of BiDi namespace types
• Improve type safety across Browser, BrowsingContext, Input, Log, Network, Script, Session, and Storage modules


Changes walkthrough 📝

Relevant files
Enhancement
72 files
ClientWindow.cs
Add sealed modifier to ClientWindow record                             
+1/-1     
ClientWindowInfo.cs
Add sealed modifier to ClientWindowInfo record                     
+1/-1     
CloseCommand.cs
Add sealed modifier to CloseCommand and CloseOptions         
+2/-2     
CreateUserContextCommand.cs
Add sealed modifier to CreateUserContext types                     
+3/-3     
GetClientWindowsCommand.cs
Add sealed modifier to GetClientWindows types                       
+3/-3     
GetUserContextsCommand.cs
Add sealed modifier to GetUserContexts types                         
+2/-2     
RemoveUserContextCommand.cs
Add sealed modifier to RemoveUserContext types                     
+3/-3     
UserContext.cs
Add sealed modifier to UserContext class                                 
+1/-1     
UserContextInfo.cs
Add sealed modifier to UserContextInfo record                       
+1/-1     
ActivateCommand.cs
Add sealed modifier to Activate types                                       
+3/-3     
BrowsingContext.cs
Add sealed modifier to BrowsingContext class                         
+1/-1     
BrowsingContextInfo.cs
Add sealed modifier to BrowsingContextInfo record               
+1/-1     
BrowsingContextInputModule.cs
Add sealed modifier to BrowsingContextInputModule class   
+1/-1     
BrowsingContextLogModule.cs
Add sealed modifier to BrowsingContextLogModule class       
+1/-1     
BrowsingContextModule.cs
Add sealed modifier to BrowsingContextModule class             
+1/-1     
BrowsingContextNetworkModule.cs
Add sealed modifier to BrowsingContextNetworkModule and options
+4/-4     
BrowsingContextScriptModule.cs
Add sealed modifier to BrowsingContextScriptModule class 
+1/-1     
BrowsingContextStorageModule.cs
Add sealed modifier to BrowsingContextStorageModule class
+1/-1     
CaptureScreenshotCommand.cs
Add sealed modifier to CaptureScreenshot types                     
+6/-6     
CloseCommand.cs
Add sealed modifier to Close types                                             
+3/-3     
CreateCommand.cs
Add sealed modifier to Create types                                           
+4/-4     
GetTreeCommand.cs
Add sealed modifier to GetTree types                                         
+5/-5     
HandleUserPromptCommand.cs
Add sealed modifier to HandleUserPrompt types                       
+3/-3     
HistoryUpdatedEventArgs.cs
Add sealed modifier to HistoryUpdatedEventArgs record       
+1/-1     
LocateNodesCommand.cs
Add sealed modifier to LocateNodes types                                 
+4/-4     
Locator.cs
Add sealed modifier to Locator types                                         
+7/-7     
NavigateCommand.cs
Add sealed modifier to Navigate types                                       
+4/-4     
Navigation.cs
Add sealed modifier to Navigation record                                 
+1/-1     
NavigationInfo.cs
Add sealed modifier to NavigationInfo record                         
+1/-1     
PrintCommand.cs
Add sealed modifier to Print types                                             
+4/-4     
ReloadCommand.cs
Add sealed modifier to Reload types                                           
+3/-3     
SetViewportCommand.cs
Add sealed modifier to SetViewport types                                 
+3/-3     
TraverseHistoryCommand.cs
Add sealed modifier to TraverseHistory types                         
+4/-4     
UserPromptClosedEventArgs.cs
Add sealed modifier to UserPromptClosedEventArgs record   
+1/-1     
UserPromptOpenedEventArgs.cs
Add sealed modifier to UserPromptOpenedEventArgs record   
+1/-1     
Key.cs
Add sealed modifier to Key record comment                               
+1/-1     
Origin.cs
Add sealed modifier to Origin types                                           
+3/-3     
PerformActionsCommand.cs
Add sealed modifier to PerformActions types                           
+3/-3     
ReleaseActionsCommand.cs
Add sealed modifier to ReleaseActions types                           
+3/-3     
SetFilesCommand.cs
Add sealed modifier to SetFiles types                                       
+3/-3     
SourceActions.cs
Add sealed modifier to SourceActions types                             
+13/-13 
LogEntry.cs
Add sealed modifier to LogEntry types                                       
+4/-4     
AddInterceptCommand.cs
Add sealed modifier to AddIntercept types                               
+3/-3     
AuthChallenge.cs
Add sealed modifier to AuthChallenge record                           
+1/-1     
AuthCredentials.cs
Add sealed modifier to AuthCredentials record                       
+1/-1     
BytesValue.cs
Add sealed modifier to BytesValue types                                   
+2/-2     
ContinueRequestCommand.cs
Add sealed modifier to ContinueRequest types                         
+3/-3     
ContinueResponseCommand.cs
Add sealed modifier to ContinueResponse types                       
+3/-3     
ContinueWithAuthCommand.cs
Add sealed modifier to ContinueWithAuth types                       
+8/-8     
Cookie.cs
Add sealed modifier to Cookie record                                         
+1/-1     
CookieHeader.cs
Add sealed modifier to CookieHeader record                             
+1/-1     
FailRequestCommand.cs
Add sealed modifier to FailRequest types                                 
+3/-3     
FetchErrorEventArgs.cs
Add sealed modifier to FetchErrorEventArgs record               
+1/-1     
FetchTimingInfo.cs
Add sealed modifier to FetchTimingInfo record                       
+14/-13 
Header.cs
Add sealed modifier to Header record                                         
+1/-1     
Initiator.cs
Add sealed modifier to Initiator record                                   
+1/-1     
Intercept.cs
Add sealed modifier to Intercept class                                     
+1/-1     
NetworkModule.HighLevel.cs
Add sealed modifier to NetworkModule high-level types       
+6/-6     
ProvideResponseCommand.cs
Add sealed modifier to ProvideResponse types                         
+3/-3     
RemoveInterceptCommand.cs
Add sealed modifier to RemoveIntercept types                         
+2/-2     
Request.cs
Add sealed modifier to Request class                                         
+1/-1     
RequestData.cs
Add sealed modifier to RequestData record                               
+11/-1   
ResponseCompletedEventArgs.cs
Add sealed modifier to ResponseCompletedEventArgs record 
+8/-1     
ResponseContent.cs
Add sealed modifier to ResponseContent record                       
+1/-1     
SetCacheBehaviorCommand.cs
Add sealed modifier to SetCacheBehavior types                       
+4/-7     
SetCookieHeader.cs
Add sealed modifier to SetCookieHeader record                       
+1/-1     
UrlPattern.cs
Add sealed modifier to UrlPattern types                                   
+2/-2     
AddPreloadScriptCommand.cs
Add sealed modifier to AddPreloadScript types                       
+5/-5     
CallFunctionCommand.cs
Add sealed modifier to CallFunction types                               
+3/-3     
Channel.cs
Add sealed modifier to Channel record                                       
+1/-1     
ChannelProperties.cs
Add sealed modifier to ChannelProperties record                   
+1/-1     
DisownCommand.cs
Add sealed modifier to Disown types                                           
+2/-2     
Formatting
2 files
ResponseData.cs
Format ResponseData record parameters                                       
+10/-10 
ResponseStartedEventArgs.cs
Format ResponseStartedEventArgs record parameters               
+8/-1     
Additional files
34 files
EvaluateCommand.cs +6/-6     
GetRealmsCommand.cs +4/-4     
Handle.cs +1/-1     
InternalId.cs +1/-1     
LocalValue.cs +13/-13 
MessageEventArgs.cs +1/-1     
NodeProperties.cs +1/-1     
PreloadScript.cs +1/-1     
Realm.cs +1/-1     
RealmDestroyedEventArgs.cs +1/-1     
RealmInfo.cs +8/-8     
RegExpValue.cs +1/-1     
RemoteValue.cs +28/-28 
RemovePreloadScriptCommand.cs +3/-3     
SerializationOptions.cs +1/-1     
Source.cs +1/-1     
StackFrame.cs +1/-1     
StackTrace.cs +1/-1     
Target.cs +3/-3     
WindowProxyProperties.cs +1/-1     
CapabilitiesRequest.cs +1/-1     
CapabilityRequest.cs +1/-1     
EndCommand.cs +2/-2     
NewCommand.cs +5/-5     
ProxyConfiguration.cs +5/-5     
StatusCommand.cs +3/-3     
SubscribeCommand.cs +4/-4     
UnsubscribeCommand.cs +6/-6     
UserPromptHandler.cs +1/-1     
DeleteCookiesCommand.cs +4/-4     
GetCookiesCommand.cs +7/-7     
PartitionKey.cs +1/-1     
SetCookieCommand.cs +5/-5     
StorageModule.cs +1/-1     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @selenium-ci selenium-ci added the C-dotnet .NET Bindings label Jun 19, 2025
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Missing Declaration

    The PrimitiveProtocolRemoteValue abstract record is being added but was previously declared elsewhere. This could cause compilation issues if the original declaration still exists.

    public abstract record PrimitiveProtocolRemoteValue : RemoteValue;
    Inconsistent Sealing

    The SourceActions<T> record is marked as abstract instead of sealed, which is inconsistent with the PR's goal of preventing inheritance. This should be reviewed to determine if it should be sealed or remain abstract for valid inheritance scenarios.

    public abstract record SourceActions<T> : SourceActions, IEnumerable<ISourceAction> where T : ISourceAction
    {

    Copy link
    Contributor

    qodo-merge-pro bot commented Jun 19, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @nvborisenko
    Copy link
    Member Author

    Thanks Nick, protecting types is good.

    @nvborisenko nvborisenko merged commit 12757f0 into SeleniumHQ:trunk Jun 20, 2025
    9 of 10 checks passed
    @nvborisenko nvborisenko deleted the bidi-sealed branch June 20, 2025 21:28
    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.

    2 participants