diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e0464de9..8ebd5baf 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,3 @@ -### 0.9.14 February 13 2020 #### +### 0.9.15 February 27 2020 #### -* [Added support for serializing and deserializing `IDictionary` with private and protected default constructor] (https://github.com/akkadotnet/Hyperion/pull/162) +* [Fix `Type.GetGenericTypeDefinition()` interface error](https://github.com/akkadotnet/Hyperion/pull/166) diff --git a/src/Hyperion.Tests/GenericDictionarySerializerTests.cs b/src/Hyperion.Tests/GenericDictionarySerializerTests.cs index a26882ec..0bbffbcf 100644 --- a/src/Hyperion.Tests/GenericDictionarySerializerTests.cs +++ b/src/Hyperion.Tests/GenericDictionarySerializerTests.cs @@ -71,10 +71,15 @@ public ProtectedCustomDictionary(Dictionary dict) : base(new Dicti { } } + // Dictionary serializer fails to fetch the generic IDictionary interface if + // Type.GetInterfaces() returns a non-generic interface before the IDictionary interface /// /// Just a custom class wrapper for another /// - class CustomDictionary : IDictionary + class CustomDictionary : + IEnumerable, + IDictionary, + IEquatable> { private readonly IDictionary _dictGeneric; @@ -162,6 +167,11 @@ public bool TryGetValue(TKey key, out TValue value) return _dictGeneric.TryGetValue(key, out value); } + public bool Equals(CustomDictionary other) + { + return true; + } + /// public TValue this[TKey key] { diff --git a/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs b/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs index 04169a9f..8d6a2715 100644 --- a/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs +++ b/src/Hyperion/SerializerFactories/DictionarySerializerFactory.cs @@ -97,7 +97,10 @@ public override ValueSerializer BuildSerializer(Serializer serializer, Type type private GenericDictionaryTypes GetKeyValuePairType(Type dictImplementationType) { - var dictInterface = dictImplementationType.GetInterfaces().First(i => i.GetGenericTypeDefinition() == typeof (IDictionary<,>)); + var dictInterface = dictImplementationType + .GetInterfaces() + .Where(i => i.GetTypeInfo().IsGenericType) + .First(i => i.GetGenericTypeDefinition() == typeof(IDictionary<,>)); var keyType = dictInterface.GetGenericArguments()[0]; var valueType = dictInterface.GetGenericArguments()[1]; return new GenericDictionaryTypes() diff --git a/src/common.props b/src/common.props index 5235b284..1dbec836 100644 --- a/src/common.props +++ b/src/common.props @@ -2,8 +2,8 @@ Copyright © 2016-2017 Akka.NET Team Akka.NET Team - 0.9.13 - [Added support for serializing and deserializing `IDictionary<TKey, TValue>`](https://github.com/akkadotnet/Hyperion/pull/156) + 0.9.15 + [Fix `Type.GetGenericTypeDefinition()` interface error](https://github.com/akkadotnet/Hyperion/pull/166) http://getakka.net/images/akkalogo.png https://github.com/akkadotnet/Hyperion https://github.com/akkadotnet/Hyperion/blob/master/LICENSE