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] Annotate nullability on Domains #15237

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

RenderMichael
Copy link
Contributor

@RenderMichael RenderMichael commented Feb 5, 2025

User description

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Annotate nullability on Domains

Motivation and Context

Contributes to #14640

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.
  • [x ] All new and existing tests passed.

PR Type

Enhancement, Bug fix


Description

  • Annotated nullability for multiple DevTools domain classes.

  • Added ArgumentNullException checks for constructor parameters.

  • Corrected typos in XML documentation comments.

  • Enabled nullable reference types in relevant files.


Changes walkthrough 📝

Relevant files
Documentation
DevToolsDomains.cs
Fix typos and enhance XML documentation                                   

dotnet/src/webdriver/DevTools/DevToolsDomains.cs

  • Corrected typos in XML documentation comments.
  • Improved clarity of parameter descriptions.
  • +2/-2     
    Enhancement
    V130Domains.cs
    Add nullability annotations and constructor validation     

    dotnet/src/webdriver/DevTools/v130/V130Domains.cs

  • Enabled nullable reference types.
  • Added ArgumentNullException for null session parameter.
  • Made domains field readonly.
  • +7/-2     
    V131Domains.cs
    Add nullability annotations and constructor validation     

    dotnet/src/webdriver/DevTools/v131/V131Domains.cs

  • Enabled nullable reference types.
  • Added ArgumentNullException for null session parameter.
  • Made domains field readonly.
  • +7/-2     
    V132Domains.cs
    Add nullability annotations and constructor validation     

    dotnet/src/webdriver/DevTools/v132/V132Domains.cs

  • Enabled nullable reference types.
  • Added ArgumentNullException for null session parameter.
  • Made domains field readonly.
  • +7/-2     
    V85Domains.cs
    Add nullability annotations and constructor validation     

    dotnet/src/webdriver/DevTools/v85/V85Domains.cs

  • Enabled nullable reference types.
  • Added ArgumentNullException for null session parameter.
  • Made domains field readonly.
  • +7/-2     

    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

    qodo-merge-pro bot commented Feb 5, 2025

    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

    Documentation Mismatch

    The class documentation states "version 86" but the class name and namespace indicate version 85. This inconsistency should be corrected.

    /// Class containing the domain implementation for version 86 of the DevTools Protocol.
    /// </summary>

    Copy link
    Contributor

    qodo-merge-pro bot commented Feb 5, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    General
    Fix incorrect version in documentation

    The class summary comment incorrectly states "version 86" while the class name
    and namespace indicate version 85. Update the comment to match the actual
    version.

    dotnet/src/webdriver/DevTools/v85/V85Domains.cs [26-29]

     /// <summary>
    -/// Class containing the domain implementation for version 86 of the DevTools Protocol.
    +/// Class containing the domain implementation for version 85 of the DevTools Protocol.
     /// </summary>
     public class V85Domains : DevToolsDomains
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    __

    Why: The suggestion identifies a clear documentation inconsistency where the class summary mentions version 86 while the class name and namespace are for version 85. This mismatch could confuse developers and should be corrected for accuracy.

    Medium
    Learned
    best practice
    Add null validation check at the start of method to prevent potential NullReferenceException

    The InitializeDomains method should validate that the session parameter is not
    null at the start of the method, since it's a required parameter. Add an
    ArgumentNullException check similar to what was added in the V130/V131/V132/V85
    domain classes.

    dotnet/src/webdriver/DevTools/DevToolsDomains.cs [95-98]

     public static DevToolsDomains InitializeDomains(int protocolVersion, DevToolsSession session)
     {
    +    ArgumentNullException.ThrowIfNull(session, nameof(session));
         return InitializeDomains(protocolVersion, session, DefaultVersionRange);
     }

    [To ensure code accuracy, apply this suggestion manually]

    Low

    @RenderMichael
    Copy link
    Contributor Author

    Failures are unrelated to changes

    //java/test/org/openqa/selenium/mobile:NetworkConnectionTest
    //java/test/org/openqa/selenium/remote:RemoteWebDriverScreenshotTest
    //java/test/org/openqa/selenium/remote:RemoteWebDriverScreenshotTest-firefox-beta
    //rb/spec/integration/selenium/webdriver:network-firefox-beta-bidi
    //rb/spec/integration/selenium/webdriver:network-firefox-bidi

    @RenderMichael RenderMichael merged commit 800abb1 into SeleniumHQ:trunk Feb 5, 2025
    9 of 10 checks passed
    @RenderMichael RenderMichael deleted the nullable-domains branch February 5, 2025 20:13
    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