From 631c338969f053621eedc6702d59d9018b633188 Mon Sep 17 00:00:00 2001
From: "dependabot-preview[bot]"
<27856297+dependabot-preview[bot]@users.noreply.github.com>
Date: Tue, 26 May 2020 17:08:19 +0000
Subject: [PATCH 1/7] Bump FSharp.Core from 4.7.0 to 4.7.2 (#176)
---
src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj b/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj
index 9f89749e..75179c29 100644
--- a/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj
+++ b/src/Hyperion.Tests.FSharpData/Hyperion.Tests.FSharpData.fsproj
@@ -9,7 +9,7 @@
-
+
From 7afb21e7c5a78823142300d3848c4f3924b8407a Mon Sep 17 00:00:00 2001
From: "dependabot-preview[bot]"
<27856297+dependabot-preview[bot]@users.noreply.github.com>
Date: Tue, 26 May 2020 17:13:38 +0000
Subject: [PATCH 2/7] Bump Microsoft.NET.Test.Sdk from 16.5.0 to 16.6.1 (#174)
---
src/common.props | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/common.props b/src/common.props
index 1dbec836..6790ff2b 100644
--- a/src/common.props
+++ b/src/common.props
@@ -11,7 +11,7 @@
2.4.1
- 16.5.0
+ 16.6.1
1.2.2
\ No newline at end of file
From 22343b7ae20a5bb3d99526ded30cf1a2337286fc Mon Sep 17 00:00:00 2001
From: Gregorius Soedharmo
Date: Thu, 18 Jun 2020 00:45:17 +0700
Subject: [PATCH 3/7] Add deserialization support for ReadOnlyDictionary (#177)
* Create spec for ReadOnlyDictionary deserializer
* Add support for ReadOnlyDictionary serializer
---
.../ImmutableCollectionsTests.cs | 57 +++++++++++++++++++
.../DictionarySerializerFactory.cs | 54 +++++++++++++-----
2 files changed, 97 insertions(+), 14 deletions(-)
diff --git a/src/Hyperion.Tests/ImmutableCollectionsTests.cs b/src/Hyperion.Tests/ImmutableCollectionsTests.cs
index 4b1fbd79..4982b76f 100644
--- a/src/Hyperion.Tests/ImmutableCollectionsTests.cs
+++ b/src/Hyperion.Tests/ImmutableCollectionsTests.cs
@@ -9,6 +9,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
+using System.Collections.ObjectModel;
using System.Linq;
using Xunit;
@@ -150,6 +151,62 @@ public void CanSerializeImmutableDictionary()
Assert.Equal(expected.ToList(), actual.ToList());
}
+ [Fact]
+ public void CanSerializeIReadOnlyDictionary()
+ {
+ var dict = ImmutableDictionary.CreateRange(new Dictionary
+ {
+ ["a1"] = new Something
+ {
+ BoolProp = true,
+ Else = new Else
+ {
+ Name = "Yoho"
+ },
+ Int32Prop = 999,
+ StringProp = "Yesbox!"
+ },
+ ["a2"] = new Something(),
+ ["a3"] = new Something(),
+ ["a4"] = null
+ });
+
+ var expected = (IReadOnlyDictionary)dict;
+
+ Serialize(expected);
+ Reset();
+ var actual = Deserialize>();
+ Assert.Equal(expected.ToList(), actual.ToList());
+ }
+
+ [Fact]
+ public void CanSerializeReadOnlyDictionary()
+ {
+ var dict = new Dictionary
+ {
+ ["a1"] = new Something
+ {
+ BoolProp = true,
+ Else = new Else
+ {
+ Name = "Yoho"
+ },
+ Int32Prop = 999,
+ StringProp = "Yesbox!"
+ },
+ ["a2"] = new Something(),
+ ["a3"] = new Something(),
+ ["a4"] = null
+ };
+
+ var expected = new ReadOnlyDictionary(dict);
+
+ Serialize(expected);
+ Reset();
+ var actual = Deserialize>();
+ Assert.Equal(expected.ToList(), actual.ToList());
+ }
+
[Fact]
public void CanSerializeImmutableQueue()
{
diff --git a/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs b/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs
index 8d6a2715..113317b5 100644
--- a/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs
+++ b/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs
@@ -11,6 +11,7 @@
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using Hyperion.Extensions;
@@ -45,6 +46,44 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type
ObjectReader reader = (stream, session) =>
{
object instance;
+
+ void ReadDictionaryKeyValuePairs(object dictionaryInstance)
+ {
+ var count = stream.ReadInt32(session);
+ for (var i = 0; i < count; i++)
+ {
+ var entry = stream.ReadObject(session); // KeyValuePair
+
+ // Get entry.Key and entry.Value
+ var key = dictionaryTypes.KeyValuePairType.GetProperty(nameof(KeyValuePair