Skip to content

Commit 7b6f992

Browse files
Merge pull request #211 from akkadotnet/dev
v0.10.0 Release
2 parents 255948e + e620a15 commit 7b6f992

17 files changed

+129
-33
lines changed

RELEASE_NOTES.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,22 @@
1-
### 0.9.17 March 25 2021 ####
2-
* [Bump Microsoft.NET.Test.Sdk from 16.6.1 to 16.7.1](https://github.com/akkadotnet/Hyperion/pull/182)
3-
* [Fix unit test problem](https://github.com/akkadotnet/Hyperion/pull/191)
4-
* [Bump FSharp.Core from 4.7.2 to 5.0.0](https://github.com/akkadotnet/Hyperion/pull/189)
5-
* [Fix issue #40 regarding partial streams](https://github.com/akkadotnet/Hyperion/pull/185)
6-
* [Fix Hyperion not using known serializers when defined](https://github.com/akkadotnet/Hyperion/pull/184)
7-
* [Bump Microsoft.NET.Test.Sdk from 16.7.1 to 16.8.3](https://github.com/akkadotnet/Hyperion/pull/196)
8-
* [Bump System.Collections.Immutable from 1.7.1 to 5.0.0](https://github.com/akkadotnet/Hyperion/pull/195)
9-
* [Bump FSharp.Core from 5.0.0 to 5.0.1](https://github.com/akkadotnet/Hyperion/pull/202)
10-
* [Update the cross framework spec to include complex POCO object, Type serialization, and support for netcoreapp3.1 and net5.0](https://github.com/akkadotnet/Hyperion/pull/204)
1+
### 0.10.0 April 13 2021 ####
2+
* [Add a generic cross platform serialization support](https://github.com/akkadotnet/Hyperion/pull/208)
3+
4+
# Cross platform serialization
5+
6+
You can now address any cross platform package serialization differences by providing a list of package name transformation lambda function into the `SerializerOptions` constructor. The package name will be passed into the lambda function before it is deserialized, and the result of the string transformation is used for deserialization instead of the original package name.
7+
8+
This short example shows how to address the change from `System.Drawing` in .NET Framework to `System.Drawing.Primitives` in .NET Core:
9+
10+
```
11+
Serializer serializer;
12+
#if NETFX
13+
serializer = new Serializer(new SerializerOptions(
14+
packageNameOverrides: new List<Func<string, string>> {
15+
str => str.Contains("System.Drawing.Primitives") ? str.Replace(".Primitives", "") : str
16+
}));
17+
#elif NETCOREAPP
18+
serializer = new Serializer();
19+
#endif
20+
```
21+
22+
Note that only one package name transformation is allowed, any transform lambda function after the first applied transformation is ignored.

build-system/windows-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ steps:
2525
displayName: 'FAKE Build'
2626
inputs:
2727
filename: build.cmd
28-
arguments: 'All SignClientUser=$(signingUsername) SignClientSecret=$(signingPassword) nugetpublishurl=https://www.nuget.org/api/v2/package nugetkey=$(hyperionKey)'
28+
arguments: 'nuget nugetpublishurl=https://www.nuget.org/api/v2/package nugetkey=$(hyperionKey)'
2929

3030
- task: GitHubRelease@0
3131
displayName: 'GitHub release (create)'
@@ -35,4 +35,4 @@ steps:
3535
title: '$(projectName) v$(Build.SourceBranchName)'
3636
releaseNotesFile: 'RELEASE_NOTES.md'
3737
assets: |
38-
bin\nuget\*.nupkg
38+
bin\nuget\*.nupkg

src/Hyperion.Tests/Bugs.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Collections;
1212
using System.Collections.Generic;
1313
using System.Collections.Immutable;
14+
using System.Drawing;
1415
using System.IO;
1516
using System.Linq;
1617
using System.Reflection;
@@ -24,7 +25,7 @@
2425
namespace Hyperion.Tests
2526
{
2627

27-
public class Bugs
28+
public class Bugs : TestBase
2829
{
2930
private readonly ITestOutputHelper _output;
3031

@@ -218,6 +219,19 @@ public void CanSerializeUri()
218219
Assert.Equal(stream.Length, stream.Position);
219220
}
220221

222+
#region Issue 117
223+
224+
[Fact]
225+
public void CanSerializeColor()
226+
{
227+
var expected = Color.Aquamarine;
228+
Serialize(expected);
229+
Reset();
230+
var actual = Deserialize<Color>();
231+
Assert.Equal(expected, actual);
232+
}
233+
234+
#endregion
221235

222236
public class SnapshotSelectionCriteria
223237
{

src/Hyperion.Tests/CrossFrameworkSerializationTests.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
using System.Collections;
1+
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.IO;
45
using System.Linq;
6+
using System.Runtime.InteropServices;
57
using FluentAssertions;
68
using Hyperion.Tests.Generator;
79
using Xunit;
@@ -19,9 +21,21 @@ public class CrossFrameworkSerializationTests
1921
public CrossFrameworkSerializationTests(ITestOutputHelper log)
2022
{
2123
_log = log;
22-
_serializer = new Serializer();
2324
_originalObject = CrossFrameworkInitializer.Init();
2425
_originalMixedObject = CrossFrameworkInitializer.InitMixed();
26+
27+
// Demonstrating the use of custom dll package name override
28+
// to convert netcore System.Drawing.Primitives to netfx
29+
// System.Drawing package.
30+
#if NETFX
31+
_serializer = new Serializer(new SerializerOptions(
32+
packageNameOverrides: new List<Func<string, string>>
33+
{
34+
str => str.Contains("System.Drawing.Primitives") ? str.Replace(".Primitives", "") : str
35+
}));
36+
#elif NETCOREAPP
37+
_serializer = new Serializer();
38+
#endif
2539
}
2640

2741
public static IEnumerable<object[]> SerializationFiles()

src/Hyperion.Tests/Generator/CrossFrameworkClass.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.Collections.Generic;
3+
using System.Drawing;
24

35
namespace Hyperion.Tests.Generator
46
{
@@ -144,6 +146,15 @@ public class CrossFrameworkMixedClass : CrossFrameworkBase
144146
public Type FriendType { get; set; }
145147
public CrossFrameworkClass Data { get; set; }
146148

149+
// Test case for (netcore) System.Drawing.Primitives to (net45) System.Drawing
150+
public Color Color { get; set; }
151+
public Point Point { get; set; }
152+
public PointF PointF { get; set; }
153+
public Rectangle Rectangle { get; set; }
154+
public RectangleF RectangleF { get; set; }
155+
public Size Size { get; set; }
156+
public SizeF SizeF { get; set; }
157+
147158
public override bool Equals(object obj)
148159
{
149160
if (!(obj is CrossFrameworkMixedClass other))

src/Hyperion.Tests/Generator/CrossFrameworkInitializer.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.Collections.Generic;
3+
using System.Drawing;
24

35
namespace Hyperion.Tests.Generator
46
{
@@ -13,6 +15,13 @@ public static CrossFrameworkMixedClass InitMixed()
1315
Name = "Cookie",
1416
Sound = "Bark",
1517
FriendType = typeof(CrossFrameworkClass),
18+
Color = Color.Blue,
19+
Point = new Point(10, 10),
20+
PointF = new PointF(10, 10),
21+
Rectangle = new Rectangle(10, 10, 10, 10),
22+
RectangleF = new RectangleF(10, 10, 10, 10),
23+
Size = new Size(10, 10),
24+
SizeF = new SizeF(10, 10),
1625
Data = Init()
1726
};
1827
}

src/Hyperion.Tests/Hyperion.Tests.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
<StartupObject>Hyperion.Tests.Generator.Program</StartupObject>
1010
</PropertyGroup>
1111

12+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0' ">
13+
<DefineConstants>$(DefineConstants);NETCOREAPP</DefineConstants>
14+
</PropertyGroup>
15+
16+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
17+
<DefineConstants>$(DefineConstants);NETFX</DefineConstants>
18+
</PropertyGroup>
19+
1220
<ItemGroup>
1321
<PackageReference Include="FluentAssertions" Version="5.10.3" />
1422
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
@@ -22,4 +30,9 @@
2230
<ProjectReference Include="..\Hyperion\Hyperion.csproj" />
2331
</ItemGroup>
2432

33+
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
34+
<Reference Include="System.Drawing">
35+
<Private>true</Private>
36+
</Reference>
37+
</ItemGroup>
2538
</Project>
450 Bytes
Binary file not shown.
450 Bytes
Binary file not shown.
450 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)