Skip to content

Conversation

@RenderMichael
Copy link
Contributor

@RenderMichael RenderMichael commented Jan 29, 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.

Motivation and Context

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

  • Updated DomainGenerator to include protocol version in code generation.

  • Modified event argument deserialization to use source-generated JSON serializer.

  • Improved maintainability by leveraging protocolVersion in generated code.


Changes walkthrough 📝

Relevant files
Enhancement
DomainGenerator.cs
Add protocol version to code generation logic                       

third_party/dotnet/devtools/src/generator/CodeGen/DomainGenerator.cs

  • Added protocolVersion derived from RootNamespace.
  • Updated code generation logic to include protocolVersion.
  • +3/-1     
    domain.hbs
    Use source-generated JSON serializer in templates               

    third_party/dotnet/devtools/src/generator/Templates/domain.hbs

  • Replaced static JSON options with source-generated serializer context.
  • Used protocolVersion to dynamically reference serializer context.
  • +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.
  • @qodo-merge-pro
    Copy link
    Contributor

    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

    Error Handling

    The JSON deserialization does not have any error handling or validation. Failed deserialization could cause runtime exceptions.

    var eventArgs = e.EventData.Deserialize(eventData.EventArgsType, {{rootNamespace}}.{{protocolVersion}}JsonSerializerContext.Default.Options);

    @qodo-merge-pro
    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add null check for deserialized data

    Add null check for eventArgs before invoking the event to prevent potential
    NullReferenceException if deserialization fails

    third_party/dotnet/devtools/src/generator/Templates/domain.hbs [63-64]

     var eventArgs = e.EventData.Deserialize(eventData.EventArgsType, {{rootNamespace}}.{{protocolVersion}}JsonSerializerContext.Default.Options);
    -eventData.EventInvoker(eventArgs);
    +if (eventArgs != null)
    +{
    +    eventData.EventInvoker(eventArgs);
    +}
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding a null check for deserialized data is a critical defensive programming practice that prevents potential NullReferenceException crashes in production. This is especially important when dealing with external data deserialization.

    8

    @RenderMichael RenderMichael deleted the generate-event-args branch February 1, 2025 05:39
    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