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

Implement correct map merging behavior for C# #10339

Merged
merged 4 commits into from
Aug 2, 2022

Conversation

jskeet
Copy link
Contributor

@jskeet jskeet commented Aug 2, 2022

Previously, calling message1.MergeFrom(message2) would fail if message1 and message2 had map fields sharing a common key. After this change, the map entry from message2 takes priority over the one in message1, as documented in the language guide.

Fixes #10327.

Note that after this is released, any code using the latest generator will need to also use the latest version of Google.Protobuf, if it uses map fields. (That's the general expectation anyway, but definitely true this time.)

jskeet added 4 commits August 2, 2022 09:38
This will enable message MergeFrom methods to implement the documented behavior.
The only change is in generated MergeFrom methods for messages with map fields, which now call MapField.MergeFrom instead of Add.
Before the change, one test passed (merging from a stream) and one failed (merging from another message object)
@jskeet
Copy link
Contributor Author

jskeet commented Aug 2, 2022

@fowles: Thanks for the quick review. If you're happy to merge it, please do so - I don't have write permission.

@fowles fowles merged commit 7b3e6cb into protocolbuffers:main Aug 2, 2022
@jskeet jskeet deleted the merge-maps branch August 2, 2022 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I found a bug using the generated Csharp MergeFrom method
3 participants