Skip to content

Conversation

@Jozott00
Copy link
Collaborator

@Jozott00 Jozott00 commented Nov 27, 2025

Subsystem
Protobuf

Problem Description
Messages had no copy method to easily creating an altered message instance.

Solution
This PR adds the copy {} extension function, which will produce a deep copy of the receiver message.
Users can override copied fields as with the invoke/constructor function.

Limitation
The copy function should also preserve all unknown message fields.
However, as unknown fields are not yet stored (just discarded), this isn't implemented yet.

@Jozott00 Jozott00 self-assigned this Nov 27, 2025
@Jozott00 Jozott00 added the feature New feature or request label Nov 27, 2025
@Jozott00 Jozott00 requested a review from Mr3zee November 27, 2025 10:59
Copy link
Member

@Mr3zee Mr3zee left a comment

Choose a reason for hiding this comment

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

Lgtm, and please see the changes before merging

@Jozott00 Jozott00 requested a review from Mr3zee November 28, 2025 10:05
@Jozott00
Copy link
Collaborator Author

Jozott00 commented Nov 28, 2025

@Mr3zee I replaced the copy method with an extension function. I also added documentation generation for the copy and invoke functions.

Copy link
Member

@Mr3zee Mr3zee left a comment

Choose a reason for hiding this comment

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

Love the doc gen for invoke

@Jozott00 Jozott00 merged commit aec2a0b into grpc-common Nov 28, 2025
5 of 7 checks passed
@Jozott00 Jozott00 deleted the pb/copy branch November 28, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants