Skip to content

[dotnet] [bidi] Make ClipRectangle as not nested #15431

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 2 commits into from
Mar 17, 2025

Conversation

nvborisenko
Copy link
Member

@nvborisenko nvborisenko commented Mar 16, 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, Tests


Description

  • Refactored ClipRectangle to remove nested DTO types.

    • Introduced BoxClipRectangle and ElementClipRectangle as standalone types.
  • Updated test cases to use new standalone DTO types.

  • Improved code clarity and maintainability by avoiding nested types.


Changes walkthrough 📝

Relevant files
Enhancement
CaptureScreenshotCommand.cs
Refactored `ClipRectangle` to standalone DTO types             

dotnet/src/webdriver/BiDi/Modules/BrowsingContext/CaptureScreenshotCommand.cs

  • Replaced nested ClipRectangle types with standalone types.
  • Introduced BoxClipRectangle and ElementClipRectangle.
  • Updated JSON polymorphic type annotations for new types.
  • +6/-7     
    Tests
    BrowsingContextTest.cs
    Updated tests for new standalone DTO types                             

    dotnet/test/common/BiDi/BrowsingContext/BrowsingContextTest.cs

  • Updated test cases to use BoxClipRectangle and ElementClipRectangle.
  • Replaced references to nested ClipRectangle types.
  • +3/-3     

    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:

    • Replace nested DTO types with standalone types

    Requires further human verification:

    • Verify if all nested DTO types have been addressed (PR only shows ClipRectangle being refactored)
    • Check if the implementation follows the pattern described in the ticket (moving from new Locator.Css("div") to new CssLocator("div"))

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

    Type Naming

    The PR introduces BoxClipRectangle and ElementClipRectangle as standalone types, but the base class is still named ClipRectangle. Consider if this naming convention is consistent with the ticket's goal of moving away from nested types.

    public abstract record ClipRectangle;
    
    public record BoxClipRectangle(double X, double Y, double Width, double Height) : ClipRectangle;
    
    public record ElementClipRectangle([property: JsonPropertyName("element")] Script.ISharedReference SharedReference) : ClipRectangle;
    Test Coverage

    The tests have been updated to use the new types, but it might be worth adding specific tests that verify the serialization/deserialization of these types works correctly with the BiDi protocol.

    Clip = new BoxClipRectangle(5, 5, 10, 10)

    Copy link
    Contributor

    qodo-merge-pro bot commented Mar 16, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @nvborisenko nvborisenko merged commit 2518ae1 into SeleniumHQ:trunk Mar 17, 2025
    8 of 10 checks passed
    @nvborisenko nvborisenko deleted the bidi-cliprectangle branch March 17, 2025 16:19
    sandeepsuryaprasad pushed a commit to sandeepsuryaprasad/selenium that referenced this pull request Mar 23, 2025
    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