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

feat(generator): support self-referential fields #802

Merged

Conversation

coryan
Copy link
Contributor

@coryan coryan commented Jan 23, 2025

Message fields may refer to the same message, directly or indirectly.
With this change the fields gain a Recursive attribute, set to true
if the field directly (or indirectly) references the containing message.

The Rust Codec uses this attribute to emit Option<Box<T>> instead of
Option<T> for such fields.

Fixes #586

Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.57%. Comparing base (8aee77e) to head (1f6aae3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #802   +/-   ##
=======================================
  Coverage   95.57%   95.57%           
=======================================
  Files          36       36           
  Lines        1357     1357           
=======================================
  Hits         1297     1297           
  Misses         60       60           

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

@coryan coryan force-pushed the feat-generator-support-recursive-fields branch 2 times, most recently from 8ee4822 to 3eb8ba7 Compare January 24, 2025 01:39
@coryan coryan marked this pull request as ready for review January 24, 2025 01:47
@coryan coryan requested review from codyoss and julieqiu January 24, 2025 01:47
generator/internal/language/rust.go Outdated Show resolved Hide resolved
Message fields may refer to the same message, directly or indirectly.
With this change the fields gain a `Recursive` attribute, set to `true`
if the field directly (or indirectly) references the containing message.

The Rust Codec uses this attribute to emit `Option<Box<T>>` instead of
`Option<T>` for such fields.

In the process I found some mistakes in the handling of map types with objects
in them.
@coryan coryan force-pushed the feat-generator-support-recursive-fields branch from 3eb8ba7 to 1f6aae3 Compare January 24, 2025 15:56
@coryan coryan enabled auto-merge (squash) January 24, 2025 15:57
@coryan coryan merged commit 50a37e1 into googleapis:main Jan 24, 2025
15 checks passed
@coryan coryan deleted the feat-generator-support-recursive-fields branch January 24, 2025 16:11
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.

Support message types that are self referential
2 participants