From c8cf693124949b5d496a0ed898c96c201ba10b62 Mon Sep 17 00:00:00 2001 From: John Stewien Date: Thu, 19 Dec 2024 12:39:52 +1030 Subject: [PATCH] Implemented a fix for issue #35 --- Swordfish.NET.CollectionsV3/ImmutableDictionaryListPair.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Swordfish.NET.CollectionsV3/ImmutableDictionaryListPair.cs b/Swordfish.NET.CollectionsV3/ImmutableDictionaryListPair.cs index c0e7f3b..b56e4f5 100644 --- a/Swordfish.NET.CollectionsV3/ImmutableDictionaryListPair.cs +++ b/Swordfish.NET.CollectionsV3/ImmutableDictionaryListPair.cs @@ -61,7 +61,8 @@ public ImmutableDictionaryListPair AddRange(IEnumerable new ObservableDictionaryNode(firstItem, endNode), - (previousNode, pair) => new ObservableDictionaryNode(pair, previousNode)); + (previousNode, pair) => new ObservableDictionaryNode(pair, previousNode)) + .ToList(); // create the key/value pairs for the internal dictionary var dictionaryEntries = nodes.Select(node => KeyValuePair.Create(node.Key, node)); @@ -151,7 +152,9 @@ public ImmutableDictionaryListPair RemoveRange(IList keys) var nodesToRemove = keys.Where(key => Dictionary.ContainsKey(key)).Select(key => Dictionary[key]); if (nodesToRemove.Any()) { - return new ImmutableDictionaryListPair(Dictionary.RemoveRange(keys), List.RemoveRange(nodesToRemove)); + var newDictionary = Dictionary.RemoveRange(keys); + var newList = List.RemoveRange(nodesToRemove); + return new ImmutableDictionaryListPair(newDictionary, newList); } else