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.Key)).GetValue(entry, null); + var value = dictionaryTypes.KeyValuePairType.GetProperty(nameof(KeyValuePair.Value)).GetValue(entry, null); + + // Same as: instance.Add(key, value) + dictionaryTypes.DictionaryInterfaceType + .GetMethod(nameof(IDictionary.Add), new[] { dictionaryTypes.KeyType, dictionaryTypes.ValueType }) + .Invoke(dictionaryInstance, new[] { key, value }); + } + } + + #region Special case for ReadOnlyDictionary + // Special case for ReadOnlyDictionary since ReadOnlyDictionary + // does not have a parameterless constructor + var genericReadOnlyDictionary = typeof(ReadOnlyDictionary<,>); + var readOnlyDictionaryType = + genericReadOnlyDictionary.MakeGenericType(dictionaryTypes.KeyType, dictionaryTypes.ValueType); + if (type.Equals(readOnlyDictionaryType)) + { + var genericDictionary = typeof(Dictionary<,>); + var genericDictionaryType = genericDictionary.MakeGenericType(dictionaryTypes.KeyType, dictionaryTypes.ValueType); + var dictionary = Activator.CreateInstance(genericDictionaryType); // normal dictionary + + ReadDictionaryKeyValuePairs(dictionary); + instance = Activator.CreateInstance(type, dictionary); // IDictionary + if (preserveObjectReferences) session.TrackDeserializedObject(instance); + return instance; + } + #endregion + try { instance = Activator.CreateInstance(type, true); // IDictionary @@ -56,20 +95,7 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type { session.TrackDeserializedObject(instance); } - 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.Key)).GetValue(entry, null); - var value = dictionaryTypes.KeyValuePairType.GetProperty(nameof(KeyValuePair.Value)).GetValue(entry, null); - - // Same as: instance.Add(key, value) - dictionaryTypes.DictionaryInterfaceType - .GetMethod(nameof(IDictionary.Add), new []{ dictionaryTypes.KeyType, dictionaryTypes.ValueType }) - .Invoke(instance, new [] { key, value }); - } + ReadDictionaryKeyValuePairs(instance); return instance; }; From e4c7cb1f7a91cac92df706c4a66da954b72ddcc2 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 17 Jun 2020 17:51:06 +0000 Subject: [PATCH 4/7] Bump FluentAssertions from 5.10.2 to 5.10.3 (#171) --- src/Hyperion.Tests/Hyperion.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hyperion.Tests/Hyperion.Tests.csproj b/src/Hyperion.Tests/Hyperion.Tests.csproj index 3c86a046..8afcc145 100644 --- a/src/Hyperion.Tests/Hyperion.Tests.csproj +++ b/src/Hyperion.Tests/Hyperion.Tests.csproj @@ -10,7 +10,7 @@ - + From 672899f73d29b9d9d2230f97a720d29308f5b508 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 17 Jun 2020 17:58:21 +0000 Subject: [PATCH 5/7] Bump System.Collections.Immutable from 1.7.0 to 1.7.1 (#175) --- src/Hyperion.Tests/Hyperion.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hyperion.Tests/Hyperion.Tests.csproj b/src/Hyperion.Tests/Hyperion.Tests.csproj index 8afcc145..2247c51a 100644 --- a/src/Hyperion.Tests/Hyperion.Tests.csproj +++ b/src/Hyperion.Tests/Hyperion.Tests.csproj @@ -12,7 +12,7 @@ - + From 4e4f742d6bf8e106014c6e950f153b15a3e51b3e Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 17 Jun 2020 18:45:05 +0000 Subject: [PATCH 6/7] Bump BenchmarkDotNet from 0.12.0 to 0.12.1 (#172) --- src/Hyperion.Benchmarks/Hyperion.Benchmarks.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hyperion.Benchmarks/Hyperion.Benchmarks.csproj b/src/Hyperion.Benchmarks/Hyperion.Benchmarks.csproj index 1cd99f66..4a4c8977 100644 --- a/src/Hyperion.Benchmarks/Hyperion.Benchmarks.csproj +++ b/src/Hyperion.Benchmarks/Hyperion.Benchmarks.csproj @@ -7,7 +7,7 @@ - + From e5d4900a0e8fc60492d0c42199a3dc791dae889e Mon Sep 17 00:00:00 2001 From: Gregorius Soedharmo Date: Thu, 18 Jun 2020 01:54:00 +0700 Subject: [PATCH 7/7] Update release notes for 0.9.16 (#178) * Update RELEASE_NOTES.md * Update RELEASE_NOTES.md * Update RELEASE_NOTES.md * Update RELEASE_NOTES.md Co-authored-by: Aaron Stannard --- RELEASE_NOTES.md | 9 ++++++--- src/common.props | 8 ++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 8ebd5baf..b0edd6b7 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ -### 0.9.15 February 27 2020 #### - -* [Fix `Type.GetGenericTypeDefinition()` interface error](https://github.com/akkadotnet/Hyperion/pull/166) +### 0.9.16 June 17 2020 #### +* [Bump Microsoft.NET.Test.Sdk from 16.5.0 to 16.6.1](https://github.com/akkadotnet/Hyperion/pull/174) +* [Add deserialization support for ReadOnlyDictionary](https://github.com/akkadotnet/Hyperion/pull/177) +* [Bump FluentAssertions from 5.10.2 to 5.10.3](https://github.com/akkadotnet/Hyperion/pull/171) +* [Bump System.Collections.Immutable from 1.7.0 to 1.7.1](https://github.com/akkadotnet/Hyperion/pull/175) +* [Bump BenchmarkDotNet from 0.12.0 to 0.12.1](https://github.com/akkadotnet/Hyperion/pull/172) diff --git a/src/common.props b/src/common.props index 6790ff2b..324f0a7d 100644 --- a/src/common.props +++ b/src/common.props @@ -2,8 +2,12 @@ Copyright © 2016-2017 Akka.NET Team Akka.NET Team - 0.9.15 - [Fix `Type.GetGenericTypeDefinition()` interface error](https://github.com/akkadotnet/Hyperion/pull/166) + 0.9.16 + [Bump Microsoft.NET.Test.Sdk from 16.5.0 to 16.6.1](https://github.com/akkadotnet/Hyperion/pull/174) +[Add deserialization support for ReadOnlyDictionary](https://github.com/akkadotnet/Hyperion/pull/177) +[Bump FluentAssertions from 5.10.2 to 5.10.3](https://github.com/akkadotnet/Hyperion/pull/171) +[Bump System.Collections.Immutable from 1.7.0 to 1.7.1](https://github.com/akkadotnet/Hyperion/pull/175) +[Bump BenchmarkDotNet from 0.12.0 to 0.12.1](https://github.com/akkadotnet/Hyperion/pull/172) http://getakka.net/images/akkalogo.png https://github.com/akkadotnet/Hyperion https://github.com/akkadotnet/Hyperion/blob/master/LICENSE