Skip to content

fix(client-gen): implement client-side extends with service accessors#1139

Merged
m62624 merged 3 commits intomaster-idl-v2from
fix/client-gen-v2
Dec 8, 2025
Merged

fix(client-gen): implement client-side extends with service accessors#1139
m62624 merged 3 commits intomaster-idl-v2from
fix/client-gen-v2

Conversation

@m62624
Copy link
Member

@m62624 m62624 commented Dec 8, 2025

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @m62624, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant enhancement to the client-side code generation by implementing the extends keyword for services in the IDL. This feature allows for better modularity and reusability of service definitions. Alongside this, the structure of mock object generation has been refactored to be more granular and organized, residing within individual service modules. The changes also include refinements in type handling, such as supporting external types and improving type path resolution, leading to cleaner and more efficient generated client code.

Highlights

  • Client-side extends Implementation: The client-gen tool now supports the extends keyword in IDL definitions, allowing services to inherit functionality from other services. This generates accessor methods on the client for the extended services, as demonstrated by the Dog service extending WalkerService and MammalService.
  • Refactored Mock Generation: Mock modules are now generated within each service's module (e.g., service_name::mockall) instead of a single top-level mockall module. This improves code organization and reduces potential naming conflicts for generated mocks.
  • Improved Type Handling: The client generator now supports specifying external types (e.g., NonZeroU8, NonZeroU32), preventing redundant code generation for types already defined elsewhere. Additionally, type path resolution for Result and Option within generated io modules has been improved, and program-level types are now relocated to their primary service modules.
  • Updated Demo and Tests: The demo_client IDL and associated tests have been updated to showcase the new extends functionality, demonstrating how to interact with extended services through their accessors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements the extends feature for services on the client-side, which is a great addition. The implementation of service accessors for extended services within the service client itself looks correct. The refactoring of the generator to move mock generation into per-service modules is also a good improvement for modularity.

However, I've identified a couple of issues in the generator logic:

  1. The generator incorrectly creates top-level accessors on the program client for services that are not exported by the program but are used in extends.
  2. The path resolution for types in function signatures (especially in Result types) is not always correct, as it doesn't seem to account for types defined in different scopes (e.g., program-level vs. service-level).

I've added specific comments with suggestions for these issues.

@m62624 m62624 marked this pull request as ready for review December 8, 2025 09:24
@m62624 m62624 requested a review from vobradovich December 8, 2025 09:24
@m62624 m62624 merged commit bc29376 into master-idl-v2 Dec 8, 2025
3 checks passed
@m62624 m62624 deleted the fix/client-gen-v2 branch December 8, 2025 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants