Skip to content

Commit

Permalink
Merge pull request #168 from akkadotnet/dev
Browse files Browse the repository at this point in the history
v0.9.15 Release
  • Loading branch information
Aaronontheweb authored Feb 27, 2020
2 parents b6a4f25 + cb48350 commit 0f2044d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### 0.9.14 February 13 2020 ####
### 0.9.15 February 27 2020 ####

* [Added support for serializing and deserializing `IDictionary<TKey, TValue>` 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)
12 changes: 11 additions & 1 deletion src/Hyperion.Tests/GenericDictionarySerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ public ProtectedCustomDictionary(Dictionary<TKey, TValue> 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
/// <summary>
/// Just a custom class wrapper for another <see cref="IDictionary{TKey,TValue}"/>
/// </summary>
class CustomDictionary<TKey, TValue> : IDictionary<TKey, TValue>
class CustomDictionary<TKey, TValue> :
IEnumerable,
IDictionary<TKey, TValue>,
IEquatable<CustomDictionary<TKey, TValue>>
{
private readonly IDictionary<TKey, TValue> _dictGeneric;

Expand Down Expand Up @@ -162,6 +167,11 @@ public bool TryGetValue(TKey key, out TValue value)
return _dictGeneric.TryGetValue(key, out value);
}

public bool Equals(CustomDictionary<TKey, TValue> other)
{
return true;
}

/// <inheritdoc />
public TValue this[TKey key]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions src/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<PropertyGroup>
<Copyright>Copyright © 2016-2017 Akka.NET Team</Copyright>
<Authors>Akka.NET Team</Authors>
<VersionPrefix>0.9.13</VersionPrefix>
<PackageReleaseNotes>[Added support for serializing and deserializing `IDictionary&lt;TKey, TValue&gt;`](https://github.com/akkadotnet/Hyperion/pull/156)</PackageReleaseNotes>
<VersionPrefix>0.9.15</VersionPrefix>
<PackageReleaseNotes>[Fix `Type.GetGenericTypeDefinition()` interface error](https://github.com/akkadotnet/Hyperion/pull/166)</PackageReleaseNotes>
<PackageIconUrl>http://getakka.net/images/akkalogo.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/akkadotnet/Hyperion</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/akkadotnet/Hyperion/blob/master/LICENSE</PackageLicenseUrl>
Expand Down

0 comments on commit 0f2044d

Please sign in to comment.