From d25ab69793240fe09fecbad97eb3608cb445ce87 Mon Sep 17 00:00:00 2001 From: Ryodo Tanaka Date: Sat, 10 May 2025 17:58:06 +0900 Subject: [PATCH 1/2] Patch for Map Field works with Protobuf 30.2 --- .../Google.Protobuf/Collections/MapField.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Runtime/Google.Protobuf/Collections/MapField.cs b/Runtime/Google.Protobuf/Collections/MapField.cs index ac008ef..e8f5243 100644 --- a/Runtime/Google.Protobuf/Collections/MapField.cs +++ b/Runtime/Google.Protobuf/Collections/MapField.cs @@ -81,6 +81,24 @@ public sealed class MapField : IDeepCloneable>>(KeyEqualityComparer); private readonly LinkedList> list = new LinkedList>(); + /// + /// Merges entries from another into this instance. + /// + /// + /// The whose entries will be merged. + /// + public void MergeFrom(MapField other) + { + // Reuse the IDictionary MergeFrom implementation + MergeFrom((System.Collections.Generic.IDictionary)other); + } + + public void MergeFrom(MapField other) + { + // IDictionary 用の MergeFrom を再利用 + MergeFrom((System.Collections.Generic.IDictionary)other); + } + /// /// Creates a deep clone of this object. /// From 2a90008d241ccb59fe0380e5f5a3fc0a4899369b Mon Sep 17 00:00:00 2001 From: Ryodo Tanaka Date: Sun, 11 May 2025 11:36:31 +0900 Subject: [PATCH 2/2] Fix compile error --- .../Google.Protobuf/Collections/MapField.cs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Runtime/Google.Protobuf/Collections/MapField.cs b/Runtime/Google.Protobuf/Collections/MapField.cs index e8f5243..d4d3cdf 100644 --- a/Runtime/Google.Protobuf/Collections/MapField.cs +++ b/Runtime/Google.Protobuf/Collections/MapField.cs @@ -82,23 +82,31 @@ public sealed class MapField : IDeepCloneable> list = new LinkedList>(); /// - /// Merges entries from another into this instance. + /// Merges entries from an into this instance. /// /// - /// The whose entries will be merged. + /// The dictionary whose entries will be merged into this map. /// - public void MergeFrom(MapField other) + public void MergeFrom(IDictionary other) { - // Reuse the IDictionary MergeFrom implementation - MergeFrom((System.Collections.Generic.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) { - // IDictionary 用の MergeFrom を再利用 - MergeFrom((System.Collections.Generic.IDictionary)other); + // Reuse the IDictionary MergeFrom implementation + MergeFrom((IDictionary)other); } - + /// /// Creates a deep clone of this object. ///