Skip to content

[dotnet] [bidi] Decouple WindowProxyProperties in Script module #15490

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 1 commit into from
Mar 23, 2025

Conversation

nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Mar 23, 2025

User description

Motivation and Context

Contributes to #15407

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement


Description

  • Decoupled WindowProxyProperties into a standalone class for better modularity.

  • Replaced nested Properties record with WindowProxyProperties in WindowProxyRemoteValue.

  • Improved code maintainability and future extensibility by avoiding nested DTO types.


Changes walkthrough 📝

Relevant files
Enhancement
RemoteValue.cs
Refactored `WindowProxyRemoteValue` to use standalone properties

dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs

  • Replaced nested Properties record with WindowProxyProperties.
  • Updated WindowProxyRemoteValue to use the new WindowProxyProperties.
  • Removed the nested Properties record definition.
  • +1/-3     
    WindowProxyProperties.cs
    Introduced standalone `WindowProxyProperties` record         

    dotnet/src/webdriver/BiDi/Modules/Script/WindowProxyProperties.cs

  • Added a new standalone WindowProxyProperties record.
  • Defined Context property within WindowProxyProperties.
  • Included licensing and namespace details for the new file.
  • +22/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    15407 - PR Code Verified

    Compliant requirements:

    • Avoid using nested DTO types in the .NET BiDi implementation
    • Replace nested types with standalone types for better maintainability

    Requires further human verification:

    • Verify if there are other nested types in the codebase that should be decoupled as part of this ticket

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

    Constructor Parameter

    The WindowProxyRemoteValue constructor now takes a WindowProxyProperties parameter, which is a breaking change. Verify that all existing code using this constructor is updated accordingly.

    public record WindowProxyRemoteValue(WindowProxyProperties Value) : RemoteValue

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add missing serialization attribute

    Add the JsonInclude attribute to ensure proper JSON
    serialization/deserialization of the WindowProxyProperties record, similar to
    how it's applied to other properties in the RemoteValue classes.

    dotnet/src/webdriver/BiDi/Modules/Script/WindowProxyProperties.cs [22]

    -public record WindowProxyProperties(BrowsingContext.BrowsingContext Context);
    +using System.Text.Json.Serialization;
     
    +public record WindowProxyProperties([JsonInclude] BrowsingContext.BrowsingContext Context);
    +
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: Adding the JsonInclude attribute is important for consistent serialization behavior across the codebase. Other similar properties in RemoteValue classes use this attribute, and maintaining this pattern ensures proper JSON handling for the new WindowProxyProperties record.

    Medium
    Learned
    best practice
    Add null validation for required constructor parameters to prevent NullReferenceException at runtime

    The constructor parameter Value is implicitly required but lacks null
    validation. Add a null check using ArgumentNullException.ThrowIfNull() to ensure
    that the Value parameter is not null before using it.

    dotnet/src/webdriver/BiDi/Modules/Script/RemoteValue.cs [263-268]

    -public record WindowProxyRemoteValue(WindowProxyProperties Value) : RemoteValue
    +public record WindowProxyRemoteValue : RemoteValue
     {
    +    public WindowProxyRemoteValue(WindowProxyProperties value)
    +    {
    +        ArgumentNullException.ThrowIfNull(value, nameof(value));
    +        Value = value;
    +    }
    +
    +    public WindowProxyProperties Value { get; }
         public Handle? Handle { get; set; }
    -
         public InternalId? InternalId { get; set; }
     }
    • Apply this suggestion
    Suggestion importance[1-10]: 6
    Low
    • More

    @nvborisenko nvborisenko merged commit a44134b into SeleniumHQ:trunk Mar 23, 2025
    10 checks passed
    @nvborisenko nvborisenko deleted the dotnet-nested-windowproxy branch March 23, 2025 20:20
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants