diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 5a1025e..75fcdfe 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -6,20 +6,36 @@ on: pull_request: branches: [ master ] +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + jobs: build: - runs-on: ubuntu-latest - + steps: - - uses: actions/checkout@v2 + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 3.1.x + dotnet-version: '9.0.x' + + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} + restore-keys: | + ${{ runner.os }}-nuget- + - name: Restore dependencies run: dotnet restore + - name: Build - run: dotnet build --no-restore + run: dotnet build --no-restore --configuration Release + - name: Test - run: dotnet test --no-build --verbosity normal + run: dotnet test --no-build --configuration Release --verbosity normal \ No newline at end of file diff --git a/NEventSocket.Tests/Applications/BridgeTests.cs b/NEventSocket.Tests/Applications/BridgeTests.cs index 0b11124..4f87d4d 100644 --- a/NEventSocket.Tests/Applications/BridgeTests.cs +++ b/NEventSocket.Tests/Applications/BridgeTests.cs @@ -1,7 +1,6 @@ namespace NEventSocket.Tests.Applications { - using System.IO; - using System.Runtime.Serialization.Formatters.Binary; + using System.Text.Json; using NEventSocket.FreeSwitch; @@ -24,7 +23,6 @@ public void can_format_BridgeOptions() RingBack = "${uk-ring}" }; - // channel variables have no effect on ToString(), they're set on the a-leg of the call before initiating the bridge. // todo: allow exporting variables? options.ChannelVariables.Add("foo", "bar"); options.ChannelVariables.Add("baz", "widgets"); @@ -37,32 +35,26 @@ public void can_format_BridgeOptions() [Fact] public void can_serialize_and_deserialize_BridgeOptions() { - using (var ms = new MemoryStream()) + var options = new BridgeOptions() { - var formatter = new BinaryFormatter(); - - var options = new BridgeOptions() - { - UUID = "985cea12-4e70-4c03-8a2c-2c4b4502bbbb", - TimeoutSeconds = 20, - CallerIdName = "Dan B Leg", - CallerIdNumber = "987654321", - HangupAfterBridge = false, - IgnoreEarlyMedia = true, - ContinueOnFail = true, - RingBack = "${uk-ring}" - }; - - options.ChannelVariables.Add("foo", "bar"); - options.ChannelVariables.Add("baz", "widgets"); - - formatter.Serialize(ms, options); + UUID = "985cea12-4e70-4c03-8a2c-2c4b4502bbbb", + TimeoutSeconds = 20, + CallerIdName = "Dan B Leg", + CallerIdNumber = "987654321", + HangupAfterBridge = false, + IgnoreEarlyMedia = true, + ContinueOnFail = true, + RingBack = "${uk-ring}" + }; - ms.Seek(0, SeekOrigin.Begin); + options.ChannelVariables.Add("foo", "bar"); + options.ChannelVariables.Add("baz", "widgets"); - var fromStream = formatter.Deserialize(ms) as BridgeOptions; - Assert.Equal(options, fromStream); - } + var json = JsonSerializer.Serialize(options); + + var fromJson = JsonSerializer.Deserialize(json); + + Assert.Equal(options, fromJson); } } } \ No newline at end of file diff --git a/NEventSocket.Tests/Applications/OriginateTests.cs b/NEventSocket.Tests/Applications/OriginateTests.cs index 9a15c59..0e52dd4 100644 --- a/NEventSocket.Tests/Applications/OriginateTests.cs +++ b/NEventSocket.Tests/Applications/OriginateTests.cs @@ -1,8 +1,7 @@ namespace NEventSocket.Tests.Applications { using System.Collections.Generic; - using System.IO; - using System.Runtime.Serialization.Formatters.Binary; + using System.Text.Json; using NEventSocket.FreeSwitch; @@ -73,30 +72,23 @@ public void can_set_privacy() [Fact] public void can_serialize_and_deserialize_OriginateOptions() { - using (var ms = new MemoryStream()) - { - var formatter = new BinaryFormatter(); - var options = new OriginateOptions() - { - CallerIdName = "Dan", - CallerIdNumber = "0123457890", - ExecuteOnOriginate = "my_app::my_arg", - Retries = 5, - RetrySleepMs = 200, - ReturnRingReady = true, - TimeoutSeconds = 60, - UUID = "83fe4f3d-b957-4b26-b6bf-3879d7e21972", - IgnoreEarlyMedia = true, - }; - - formatter.Serialize(ms, options); - - ms.Seek(0, SeekOrigin.Begin); + { + CallerIdName = "Dan", + CallerIdNumber = "0123457890", + ExecuteOnOriginate = "my_app::my_arg", + Retries = 5, + RetrySleepMs = 200, + ReturnRingReady = true, + TimeoutSeconds = 60, + UUID = "83fe4f3d-b957-4b26-b6bf-3879d7e21972", + IgnoreEarlyMedia = true, + }; - var fromStream = formatter.Deserialize(ms) as OriginateOptions; - Assert.Equal(options, fromStream); - } + var json = JsonSerializer.Serialize(options); + var fromJson = JsonSerializer.Deserialize(json); + + Assert.Equal(options, fromJson); } } } \ No newline at end of file diff --git a/NEventSocket.Tests/NEventSocket.Tests.csproj b/NEventSocket.Tests/NEventSocket.Tests.csproj index 079c537..6bd9e86 100644 --- a/NEventSocket.Tests/NEventSocket.Tests.csproj +++ b/NEventSocket.Tests/NEventSocket.Tests.csproj @@ -1,17 +1,23 @@  - netcoreapp3.1 + net9.0 false - - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/NEventSocket.sln.DotSettings b/NEventSocket.sln.DotSettings index 8db27b2..dd5bffa 100644 --- a/NEventSocket.sln.DotSettings +++ b/NEventSocket.sln.DotSettings @@ -267,6 +267,7 @@ True True True + True True True True diff --git a/NEventSocket/NEventSocket.csproj b/NEventSocket/NEventSocket.csproj index 9db4ff8..4f1e32d 100644 --- a/NEventSocket/NEventSocket.csproj +++ b/NEventSocket/NEventSocket.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + net9.0 NEventSocket.DotNetCore iamkinetic iamkinetic @@ -12,19 +12,13 @@ FreeSwitch NEventSocket DotNetCore - Fix a few issues with the ObservableSocket. https://github.com/iamkinetic/NEventSocket - - - - - - 2.2.1.0 2.2.1.0 - - + +