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 nullable reference types on CDP-generated code #15255

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

RenderMichael
Copy link
Contributor

@RenderMichael RenderMichael commented Feb 9, 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.

Annotates nullable reference types on CDP-generated code

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

PR Type

Enhancement, Bug fix


Description

  • Annotated nullable reference types across CDP-generated code.

  • Updated type mappings to handle optional types consistently.

  • Enabled nullable context in multiple template files.

  • Improved event handling with nullable support in generated code.


Changes walkthrough 📝

Relevant files
Enhancement
8 files
DevToolsEventData.cs
Annotated nullable reference types for event invoker.       
+2/-2     
CommandDefinition.cs
Added nullable property for return types in command definitions.
+3/-0     
command.hbs
Enabled nullable context and added default values for required
properties.
+5/-2     
domain.hbs
Enabled nullable context and improved event handling.       
+9/-4     
event.hbs
Enabled nullable context and added default values for required
properties.
+4/-1     
type-enum.hbs
Enabled nullable context in type-enum template.                   
+3/-0     
type-hash.hbs
Enabled nullable context and added default values for required
properties.
+4/-1     
type-object.hbs
Enabled nullable context and added default values for required
properties.
+4/-1     
Bug fix
1 files
Utility.cs
Adjusted type mappings for optional and array types.         
+13/-7   

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 9, 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

    Potential Bug

    The changes to type mapping logic may affect array type handling. The removal of typeInfo.ByRef check could lead to incorrect nullable annotations for array types.

    mappedType = $"{typeInfo.Namespace}.{typeInfo.TypeName}";
    if (typeDefinition.Optional)
    {
        mappedType += "?";
    }
    Validation Needed

    The null handling in OnDevToolsEventReceived and event handlers needs validation to ensure null events are handled properly and don't cause runtime exceptions.

    private void OnDevToolsEventReceived(object? sender, DevToolsEventReceivedEventArgs e)
    {
        if (e.DomainName == m_domainName)
        {
            if (m_eventMap.ContainsKey(e.EventName))

    Copy link
    Contributor

    qodo-merge-pro bot commented Feb 9, 2025

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    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.

    1 participant