You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
I found a bug using the generated Csharp MergeFrom method. If my data contains mapfield, mergefrom will add other mapfield directly. If there are duplicates, it will always report : ArgumentException: Key already exists in map. I think the merge of the map should be changed to containskey and then directly replace the element.
`public void MergeFrom(LineComponent other) {
if (other == null) {
return;
}
if (other.target_ != null) {
if (target_ == null) {
Target = new global::Protocol.LineInfoComponent();
}
Target.MergeFrom(other.Target);
}
lines_.Add(other.lines_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}`
this lines is a mapfield type,using add directly on the opposite mapfield type will always report an error.
The text was updated successfully, but these errors were encountered:
Right, it looks like we should be using a specific merge method for a MapField<,>. The language guide specifically says:
When parsing from the wire or when merging, if there are duplicate map keys the last key seen is used. When parsing a map from text format, parsing may fail if there are duplicate keys.
I'll come up with a unit test to reproduce this, then fix it. It's likely to need both a generator and a support library change.
Hi
I found a bug using the generated Csharp MergeFrom method. If my data contains mapfield, mergefrom will add other mapfield directly. If there are duplicates, it will always report : ArgumentException: Key already exists in map. I think the merge of the map should be changed to containskey and then directly replace the element.
`public void MergeFrom(LineComponent other) {
this lines is a mapfield type,using add directly on the opposite mapfield type will always report an error.
The text was updated successfully, but these errors were encountered: