Repository navigation
Conversation
Remove extraneous imports from generated Swift conversion files. Previously, message conversion files unconditionally imported GoogleGax and always emitted GoogleWKTConvert alongside GoogleWKT, while enum conversion files unconditionally imported SwiftProtobuf. Message conversion files now import GoogleWKTConvert only when the message or a nested message converts a google.protobuf field without an LROAnyConverter, recomputing NeedsWktConvert after LROAnyConverter fields are populated on Operation. They import GoogleGax only when the message or a nested message declares nested enums, which throw ProtobufConversionError. Enum conversion files omit SwiftProtobuf when ModulePath is configured, because generated proto enums declare the rawValue initializer directly. For googleapis/google-cloud-swift#1704
Contributor
There was a problem hiding this comment.
Code Review
This pull request optimizes Swift code generation by conditionally importing GoogleGax and GoogleWKTConvert based on whether a message contains nested enums or requires Well-Known Type (WKT) conversions. It introduces helper functions to determine these requirements, updates the messageAnnotations struct, and refactors the template files to apply these conditional imports. Comprehensive unit tests have been added and updated to verify the new import logic. No review comments were provided, and the implementation is clean and well-tested.
coryan
marked this pull request as ready for review
December 5, 2026 16:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remove extraneous imports from generated Swift conversion files. Previously, message conversion files unconditionally imported GoogleGax and always emitted GoogleWKTConvert alongside GoogleWKT, while enum conversion files unconditionally imported SwiftProtobuf.
Message conversion files now import GoogleWKTConvert only when the message or a nested message converts a google.protobuf field without an LROAnyConverter, recomputing NeedsWktConvert after LROAnyConverter fields are populated on Operation. They import GoogleGax only when the message or a nested message declares nested enums, which throw ProtobufConversionError. Enum conversion files omit SwiftProtobuf when ModulePath is configured, because generated proto enums declare the rawValue initializer directly.
For googleapis/google-cloud-swift#1704
Generated code at googleapis/google-cloud-swift#1754