diff --git a/Runtime/Google.Protobuf/Collections/MapField.cs b/Runtime/Google.Protobuf/Collections/MapField.cs index ac008ef..d4d3cdf 100644 --- a/Runtime/Google.Protobuf/Collections/MapField.cs +++ b/Runtime/Google.Protobuf/Collections/MapField.cs @@ -81,6 +81,32 @@ public sealed class MapField : IDeepCloneable>>(KeyEqualityComparer); private readonly LinkedList> list = new LinkedList>(); + /// + /// Merges entries from an into this instance. + /// + /// + /// The dictionary whose entries will be merged into this map. + /// + public void MergeFrom(IDictionary other) + { + foreach (var kv in other) + { + this[kv.Key] = kv.Value; + } + } + + /// + /// Merges entries from another into this instance. + /// + /// + /// The whose entries will be merged. + /// + public void MergeFrom(MapField other) + { + // Reuse the IDictionary MergeFrom implementation + MergeFrom((IDictionary)other); + } + /// /// Creates a deep clone of this object. ///