Skip to content

fix(dart): enums referenced outside the package#2952

Merged
brianquinlan merged 4 commits intogoogleapis:mainfrom
brianquinlan:fix_enum
Nov 19, 2025
Merged

fix(dart): enums referenced outside the package#2952
brianquinlan merged 4 commits intogoogleapis:mainfrom
brianquinlan:fix_enum

Conversation

@brianquinlan
Copy link
Copy Markdown
Contributor

Fixes a bug where enums referenced from a package other than the current one did not have a package prefix.

Fixes a bug where enums referenced from a package other than the current one did not have a package prefix.
@brianquinlan brianquinlan requested review from a team November 19, 2025 01:35
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @brianquinlan, 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 resolves a critical bug in the Dart code generation process where enums originating from packages other than the current one were not being correctly prefixed, resulting in compilation errors. The solution involves a clear separation of concerns by introducing a specialized function for resolving enum names, which now correctly applies package prefixes. The existing function for resolving message names has also been renamed for better clarity. Comprehensive test cases have been added to ensure the robustness of these changes for both local and cross-package type references.

Highlights

  • Enum Reference Fix: Corrected a bug where Dart enums referenced from external packages did not include the necessary package prefix, leading to incorrect code generation.
  • Refactored Type Resolution: Introduced a new dedicated function, resolveEnumName, to handle the resolution of enum names, ensuring proper package prefixing. The existing resolveTypeName function was renamed to resolveMessageName to clarify its specific role in resolving message types.
  • Code Generation Updates: Updated various parts of the code generation logic in annotate.go to use the new resolveEnumName for enums and resolveMessageName for messages, ensuring consistent and correct type referencing.
  • Expanded Test Coverage: Added new test cases in annotate_test.go and dart_test.go to specifically validate the correct handling of foreign (cross-package) enums and messages in fromJson, toJson, and query line generation, including the application of package prefixes.
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
Copy Markdown
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 effectively addresses a bug concerning the incorrect handling of enums referenced from external packages by introducing a dedicated resolveEnumName function. The related refactoring of resolveTypeName to resolveMessageName improves code clarity. The accompanying test additions are thorough, validating the fix for both enums and messages from foreign packages. I have one minor suggestion to improve the clarity of a test function's name.

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 81.81818% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.38%. Comparing base (ed40446) to head (b0271fb).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
internal/sidekick/dart/annotate.go 81.81% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2952      +/-   ##
==========================================
+ Coverage   83.32%   83.38%   +0.05%     
==========================================
  Files         134      134              
  Lines       10987    10990       +3     
==========================================
+ Hits         9155     9164       +9     
+ Misses       1414     1409       -5     
+ Partials      418      417       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Brian Quinlan <[email protected]>
natebosch
natebosch previously approved these changes Nov 19, 2025
@brianquinlan brianquinlan merged commit 7331816 into googleapis:main Nov 19, 2025
8 checks passed
ldetmer added a commit that referenced this pull request Nov 20, 2025
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: not available
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-release-container:latest
<details><summary>librarian: 0.7.0</summary>

##
[0.7.0](v0.6.0...v0.7.0)
(2025-11-20)

### Features

* add command execution package with logging (#2968)
([12f4e94](12f4e949))

* add branch support to RepositoryConfig (#2906)
([2cab5d6](2cab5d65))

* add image sha as a config in repositories config (#2954)
([3d1f537](3d1f5375))

* add initial config (#2965)
([502b063](502b063c))

* add fetch package (#2964)
([53de44d](53de44d8))

* parse gapic_metadata for API version release notes (#2815)
([7ee0328](7ee03283))

* onboard 25 repositories to automation for publish-release (#2907)
([87fae04](87fae04a))

* add version command (#2894)
([8f85be0](8f85be09))

* add RequireCommand test helper (#2978)
([a820a71](a820a710))

* add initial command (#2961)
([c959aea](c959aeae))

* add `stage-release` command (#2902)
([ee05006](ee050065))

### Bug Fixes

* require git v2.28.0 (#2963)
([265ee47](265ee47f))

* enums referenced outside the package (#2952)
([7331816](73318169))

</details>
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