From 7cc65dab82f236a25f7bf4feaab49dd0e847d93e Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Fri, 13 Sep 2019 08:54:57 +1200 Subject: [PATCH] Deserializing immutable set and dictionary create hash impls (#2159) --- .../Serialization/ImmutableCollectionsTests.cs | 4 ++++ Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs index 81876c5d..09d8c461 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/ImmutableCollectionsTests.cs @@ -304,6 +304,8 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.IsTrue(l.Contains("3")); Assert.IsTrue(l.Contains("II")); Assert.IsTrue(l.Contains("One")); + + Assert.IsTrue(l is ImmutableHashSet); } #endregion @@ -395,6 +397,8 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual("One", l[1]); Assert.AreEqual("II", l[2]); Assert.AreEqual("3", l[3]); + + Assert.IsTrue(l is ImmutableDictionary); } #endregion diff --git a/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs b/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs index ab3b5522..dfe5d45e 100644 --- a/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ImmutableCollectionsUtils.cs @@ -90,7 +90,7 @@ namespace Newtonsoft.Json.Utilities new ImmutableCollectionTypeInfo(ImmutableQueueGenericTypeName, ImmutableQueueGenericTypeName, ImmutableQueueTypeName), new ImmutableCollectionTypeInfo(ImmutableStackGenericInterfaceTypeName, ImmutableStackGenericTypeName, ImmutableStackTypeName), new ImmutableCollectionTypeInfo(ImmutableStackGenericTypeName, ImmutableStackGenericTypeName, ImmutableStackTypeName), - new ImmutableCollectionTypeInfo(ImmutableSetGenericInterfaceTypeName, ImmutableSortedSetGenericTypeName, ImmutableSortedSetTypeName), + new ImmutableCollectionTypeInfo(ImmutableSetGenericInterfaceTypeName, ImmutableHashSetGenericTypeName, ImmutableHashSetTypeName), new ImmutableCollectionTypeInfo(ImmutableSortedSetGenericTypeName, ImmutableSortedSetGenericTypeName, ImmutableSortedSetTypeName), new ImmutableCollectionTypeInfo(ImmutableHashSetGenericTypeName, ImmutableHashSetGenericTypeName, ImmutableHashSetTypeName), new ImmutableCollectionTypeInfo(ImmutableArrayGenericTypeName, ImmutableArrayGenericTypeName, ImmutableArrayTypeName) @@ -106,7 +106,7 @@ namespace Newtonsoft.Json.Utilities private static readonly IList DictionaryContractImmutableCollectionDefinitions = new List { - new ImmutableCollectionTypeInfo(ImmutableDictionaryGenericInterfaceTypeName, ImmutableSortedDictionaryGenericTypeName, ImmutableSortedDictionaryTypeName), + new ImmutableCollectionTypeInfo(ImmutableDictionaryGenericInterfaceTypeName, ImmutableDictionaryGenericTypeName, ImmutableDictionaryTypeName), new ImmutableCollectionTypeInfo(ImmutableSortedDictionaryGenericTypeName, ImmutableSortedDictionaryGenericTypeName, ImmutableSortedDictionaryTypeName), new ImmutableCollectionTypeInfo(ImmutableDictionaryGenericTypeName, ImmutableDictionaryGenericTypeName, ImmutableDictionaryTypeName) };