Skip to content

Commit cc581cb

Browse files
author
Michaël Catanzariti
authored
Support for .NET 5.0 (Preview 7)
1 parent 5c264ef commit cc581cb

27 files changed

+696
-2325
lines changed

.github/workflows/BuildAndTest.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ on:
1919
- '*.*.*'
2020

2121
jobs:
22-
build:
22+
build_and_test:
2323

2424
runs-on: ubuntu-16.04
2525

@@ -35,12 +35,18 @@ jobs:
3535
- name: setup .net core 3.1.100
3636
uses: actions/setup-dotnet@v1
3737
with:
38-
dotnet-version: 3.1.100
38+
dotnet-version: 3.1.100
39+
40+
- name: setup .net core 5.0.100-preview.7.20366.6
41+
uses: actions/setup-dotnet@v1
42+
with:
43+
dotnet-version: 5.0.100-preview.7.20366.6
3944

4045
# workaround for using multiple dotnet core installs
4146
- name: setup multiple sdks
4247
run: |
43-
rsync -a ${DOTNET_ROOT/3.1.100/2.2.207}/* $DOTNET_ROOT/
48+
rsync -a ${DOTNET_ROOT/5.0.100-preview.7.20366.6/2.2.207}/* $DOTNET_ROOT/
49+
rsync -a ${DOTNET_ROOT/5.0.100-preview.7.20366.6/3.1.100}/* $DOTNET_ROOT/
4450
dotnet --info
4551
4652
- name: build

.github/workflows/Deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: setup
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: 3.1.100
19+
dotnet-version: 5.0.100-preview.6.20318.15
2020

2121
- name: build
2222
run: dotnet pack -p:Version=${GITHUB_REF##*/} -p:FileVersion=${GITHUB_REF##*/} -p:AssemblyVersion=${GITHUB_REF##*/} -c Release src/Dahomey.Cbor

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ High-performance [CBOR](https://cbor.io/) serialization framework for .Net (C#)
55
![](https://github.com/dahomey-technologies/Dahomey.Cbor/workflows/Build%20and%20Test/badge.svg)
66
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt)
77

8+
## Supported .NET versions
9+
* .NET Standard 2.0
10+
* .NET Core 3.0
11+
* .NET Core 3.1
12+
* .NET 5.0 (preview 7)
13+
814
## Features
915
* Serialization/Deserialization from/to Streams, byte buffer
1016
* Object Model

src/Dahomey.Cbor.Tests/CborReaderTests.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Xunit;
33
using System;
44
using Dahomey.Cbor.Util;
5+
using System.Globalization;
56

67
namespace Dahomey.Cbor.Tests
78
{
@@ -151,14 +152,20 @@ public void ReadUInt64(string hexBuffer, ulong expectedValue, Type expectedExcep
151152
[InlineData("F90001", 5.960464477539063e-8f, null)]
152153
[InlineData("F90400", 0.00006103515625f, null)]
153154
[InlineData("F9C400", -4f, null)]
154-
[InlineData("F97E00", float.NaN, null)]
155155
[InlineData("F97C00", float.PositiveInfinity, null)]
156156
[InlineData("F9FC00", float.NegativeInfinity, null)]
157157
public void ReadHalf(string hexBuffer, float expectedValue, Type expectedExceptionType)
158158
{
159159
Helper.TestRead(nameof(CborReader.ReadHalf), hexBuffer, (Half)expectedValue, expectedExceptionType);
160160
}
161161

162+
[Fact]
163+
public void ReadNaNHalf()
164+
{
165+
Half actualValue = Helper.Read<Half>(nameof(CborReader.ReadHalf), "F97E00");
166+
Assert.True(Half.IsNaN(actualValue));
167+
}
168+
162169
[Theory]
163170
// half
164171
[InlineData("F9E3D0", -1000f, null)]
@@ -225,7 +232,7 @@ public void ReadDecimal(string hexBuffer, decimal expectedValue, Type expectedEx
225232
[InlineData("FCFFFFFFFFFFFFFFFFFFFFFFFF00000000", "79228162514264337593543950335", null)]
226233
public void ReadDecimal2(string hexBuffer, string expectedValue, Type expectedExceptionType)
227234
{
228-
if (!decimal.TryParse(expectedValue, out decimal decimalValue)) throw new InvalidCastException("Specified string cannot be cast to a decimal value");
235+
if (!decimal.TryParse(expectedValue, NumberStyles.Any, CultureInfo.InvariantCulture, out decimal decimalValue)) throw new InvalidCastException("Specified string cannot be cast to a decimal value");
229236

230237
Helper.TestRead(nameof(CborReader.ReadDecimal), hexBuffer, decimalValue, expectedExceptionType);
231238
}

src/Dahomey.Cbor.Tests/CborWriterTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Dahomey.Cbor.Util;
33
using Xunit;
44
using System;
5+
using System.Globalization;
56

67
namespace Dahomey.Cbor.Tests
78
{
@@ -221,7 +222,7 @@ public void WriteDecimal(string hexBuffer, decimal value, Type expectedException
221222
[InlineData("FCFFFFFFFFFFFFFFFFFFFFFFFF00000000", "79228162514264337593543950335", null)]
222223
public void WriteDecimal2(string hexBuffer, string value, Type expectedExceptionType)
223224
{
224-
if (!decimal.TryParse(value, out decimal decimalValue)) throw new InvalidCastException("Specified string cannot be cast to a decimal value");
225+
if (!decimal.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out decimal decimalValue)) throw new InvalidCastException("Specified string cannot be cast to a decimal value");
225226

226227
Helper.TestWrite(nameof(CborWriter.WriteDecimal), decimalValue, hexBuffer, expectedExceptionType);
227228
}

src/Dahomey.Cbor.Tests/Dahomey.Cbor.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net5.0</TargetFrameworks>
55

66
<IsPackable>false</IsPackable>
77

0 commit comments

Comments
 (0)