Skip to content
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

[dotnet] [bidi] Make LogEntry as not nested #15432

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 nested DTO types to standalone classes for better extensibility.

  • Updated LogEntry and related types to standalone classes.

  • Adjusted JSON serialization and deserialization logic for new class structure.

  • Updated tests to align with refactored LogEntry structure.


Changes walkthrough 📝

Relevant files
Enhancement
5 files
BiDiJsonSerializerContext.cs
Updated JSON serialization for refactored `LogEntry` types
+3/-3     
LogEntryConverter.cs
Adjusted polymorphic converter for `LogEntry` refactor     
+5/-5     
BrowsingContextLogModule.cs
Updated method signatures to use new `LogEntry` types       
+2/-2     
LogEntry.cs
Refactored `Entry` and nested types to standalone `LogEntry` classes
+7/-7     
LogModule.cs
Updated `LogModule` to use refactored `LogEntry` types     
+2/-2     
Tests
2 files
LogTest.cs
Updated tests to align with `LogEntry` refactor                   
+6/-6     
ScriptCommandsTest.cs
Adjusted script command tests for `LogEntry` changes         
+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.
  • 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:

    • Don't use nested DTO types in the .NET BiDi implementation
    • Replace nested types with standalone classes for better extensibility
    • Maintain the same functionality while improving the API design

    Requires further human verification:

    • Ensure static factory methods and static singletons can be added in the future
    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    File Naming

    The file was renamed from Entry.cs to LogEntry.cs, but the copyright header still references the old file name. This should be updated to match the new file name.

    // <copyright file="LogEntry.cs" company="Selenium Committers">

    Copy link
    Contributor

    qodo-merge-pro bot commented Mar 16, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Learned
    best practice
    Use TryGetProperty to safely check for property existence before accessing JSON properties to prevent exceptions

    The code directly accesses the "type" property without checking if it exists
    first, which could throw a JsonException if the property is missing. Use
    TryGetProperty to safely check for the property's existence before accessing it.

    dotnet/src/webdriver/BiDi/Communication/Json/Converters/Polymorphic/LogEntryConverter.cs [34-39]

    -return jsonDocument.RootElement.GetProperty("type").ToString() switch
    +if (!jsonDocument.RootElement.TryGetProperty("type", out JsonElement typeElement))
    +    return null;
    +    
    +return typeElement.ToString() switch
     {
         "console" => jsonDocument.Deserialize<ConsoleLogEntry>(options),
         "javascript" => jsonDocument.Deserialize<JavascriptLogEntry>(options),
         _ => null,
     };
    • Apply this suggestion
    Suggestion importance[1-10]: 6
    Low
    • Update

    Copy link
    Contributor

    @RenderMichael RenderMichael left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Looks good, one small future-proofing change

    @nvborisenko nvborisenko merged commit f3361c3 into SeleniumHQ:trunk Mar 17, 2025
    3 of 4 checks passed
    @nvborisenko nvborisenko deleted the bidi-logentry branch March 17, 2025 15:40
    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