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

minimal support v2 messages in *dynamic.Message #533

Merged
merged 3 commits into from Sep 28, 2022

Conversation

jhump
Copy link
Owner

@jhump jhump commented Sep 28, 2022

In the V2 API, an extendable message can have extensions that are neither present in the return values from proto.ExtensionDescs nor in the message's unknown/unrecognized field bytes.

That means that they are simply dropped if such a message is converted to a *dynamic.Message.

This simple fix targets just the extensions in question and merges them into the dynamic message via marshalling to bytes and then unmarshalling.

While in here, the files I touched got reformetted with the Go 1.19 version of gofmt. And I also updated a few places that were relying on reflection to utilize newer(ish) features of the protobuf runtime (back when the version pinned was old enough that the simple/non-reflection logic wouldn't compile).

@@ -2553,13 +2558,48 @@ func (m *Message) mergeFrom(pm proto.Message) error {
}
}

// unrecognized extensions fields:
Copy link
Owner Author

Choose a reason for hiding this comment

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

Here's the actual fix. The rest of the diff is mostly the fallout of gofmt.

@jhump jhump merged commit 101791c into master Sep 28, 2022
@jhump jhump deleted the jh/support-v2-msgs-in-dynamic-message branch September 28, 2022 23:27
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.

None yet

1 participant