Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.9.15 Release #168

Merged
merged 2 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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