From 51599b32c876a4ee94c7124822997181b65c0704 Mon Sep 17 00:00:00 2001 From: Brice SCHUMACHER Date: Mon, 7 Jul 2025 19:06:09 +0200 Subject: [PATCH 1/2] feat : (NotoriousClient) Passage en NEt9 et remplacement de newtonsoft par System.Text.Json --- .github/workflows/prerelease.yml | 36 +++++++++++++++++++ .github/workflows/release.yml | 30 ++++++++++++++++ .../Builder/RequestBuilder.Body.cs | 2 +- NotoriousClient/Clients/BaseClient.cs | 3 +- .../Clients/BasicAuthBaseClient.cs | 8 ++--- ...ializer.cs => SystemTextJsonSerializer.cs} | 9 ++--- NotoriousClient/NotoriousClient.csproj | 5 ++- 7 files changed, 77 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/prerelease.yml create mode 100644 .github/workflows/release.yml rename NotoriousClient/Converters/{NewtonsoftJsonSerializer.cs => SystemTextJsonSerializer.cs} (50%) diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml new file mode 100644 index 0000000..cc3d8ee --- /dev/null +++ b/.github/workflows/prerelease.yml @@ -0,0 +1,36 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: PreRelease Workflow + +on: + push: + branches: + - develop + pull_request: + branches: + - develop + +jobs: + publish: + env: + CONFIGURATION: 'Release' + DOTNET_VERSION: '9.0' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --configuration ${{ env.CONFIGURATION }} --no-restore + - name: Test + run: dotnet test NotoriousClient.Tests.Unit --no-build --verbosity normal + - name: Pack + run: dotnet pack -c ${{ env.CONFIGURATION }} -o out --version-suffix "beta.${{ github.run_number }}" + - name: Push + if: github.event_name == 'push' && github.ref == 'refs/heads/develop' + run: dotnet nuget push out/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b89179c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: Release Worflow + +on: + release: + types: [created] +jobs: + publish: + env: + CONFIGURATION: 'Release' + DOTNET_VERSION: '9.0' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --configuration ${{ env.CONFIGURATION }} --no-restore + - name: Test + run: dotnet test NotoriousClient.Tests.Unit --no-build --verbosity normal + - name: Pack + run: dotnet pack -c ${{ env.CONFIGURATION }} -o out + - name: Push + run: dotnet nuget push out/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate diff --git a/NotoriousClient/Builder/RequestBuilder.Body.cs b/NotoriousClient/Builder/RequestBuilder.Body.cs index bbc1af6..f27dd7d 100644 --- a/NotoriousClient/Builder/RequestBuilder.Body.cs +++ b/NotoriousClient/Builder/RequestBuilder.Body.cs @@ -8,7 +8,7 @@ public partial class RequestBuilder : IRequestBuilder /// /// Default JSON Converter. /// - protected IJsonSerializer DefaultJsonConverter = new NewtonsoftJsonSerializer(); + protected IJsonSerializer DefaultJsonConverter = new SystemTextJsonSerializer(); private List _bodies = new List(); private bool? _isMultipartRequest = null; diff --git a/NotoriousClient/Clients/BaseClient.cs b/NotoriousClient/Clients/BaseClient.cs index 29b34ab..f4815ee 100644 --- a/NotoriousClient/Clients/BaseClient.cs +++ b/NotoriousClient/Clients/BaseClient.cs @@ -23,7 +23,8 @@ public abstract class BaseClient protected BaseClient(IRequestSender sender, string url) { ArgumentNullException.ThrowIfNull(sender, nameof(sender)); - if(string.IsNullOrWhiteSpace(url)) throw new ArgumentNullException(nameof(url)); + ArgumentException.ThrowIfNullOrEmpty(url, nameof(url)); + Sender = sender; _url = url; } diff --git a/NotoriousClient/Clients/BasicAuthBaseClient.cs b/NotoriousClient/Clients/BasicAuthBaseClient.cs index ef2252a..cb694c8 100644 --- a/NotoriousClient/Clients/BasicAuthBaseClient.cs +++ b/NotoriousClient/Clients/BasicAuthBaseClient.cs @@ -12,7 +12,7 @@ public abstract class BasicAuthBaseClient : BaseClient private readonly string _password; /// - /// Initialize a new instance of . + /// Initialize a new instance of . /// /// Class used to send . /// Base URL of api (ex: https://myapi.com/). @@ -20,11 +20,9 @@ public abstract class BasicAuthBaseClient : BaseClient /// User's password. protected BasicAuthBaseClient(IRequestSender sender, string url, string login, string password) : base(sender, url) { - if (string.IsNullOrEmpty(url)) throw new ArgumentNullException(nameof(url)); - if (string.IsNullOrEmpty(login)) throw new ArgumentNullException(nameof(login)); - if (string.IsNullOrEmpty(password)) throw new ArgumentNullException(nameof(password)); - ArgumentNullException.ThrowIfNull(sender, nameof(sender)); + ArgumentException.ThrowIfNullOrEmpty(login, nameof(login)); + ArgumentException.ThrowIfNullOrEmpty(password, nameof(password)); _login = login; _password = password; diff --git a/NotoriousClient/Converters/NewtonsoftJsonSerializer.cs b/NotoriousClient/Converters/SystemTextJsonSerializer.cs similarity index 50% rename from NotoriousClient/Converters/NewtonsoftJsonSerializer.cs rename to NotoriousClient/Converters/SystemTextJsonSerializer.cs index 812b0da..a863c5c 100644 --- a/NotoriousClient/Converters/NewtonsoftJsonSerializer.cs +++ b/NotoriousClient/Converters/SystemTextJsonSerializer.cs @@ -1,18 +1,15 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Text; +using System.Text.Json; namespace NotoriousClient.Converters { /// /// Serialize object to JSON using NewtonsoftJson. /// - public class NewtonsoftJsonSerializer : IJsonSerializer + public class SystemTextJsonSerializer : IJsonSerializer { public string ConvertToJson(object obj) { - return JsonConvert.SerializeObject(obj); + return JsonSerializer.Serialize(obj); } } } diff --git a/NotoriousClient/NotoriousClient.csproj b/NotoriousClient/NotoriousClient.csproj index fcaa79b..0ce1d75 100644 --- a/NotoriousClient/NotoriousClient.csproj +++ b/NotoriousClient/NotoriousClient.csproj @@ -1,12 +1,12 @@  - net6.0 + net9.0 A fluent HTTPResponseMessage builder with fully extendable API Client implementation. NotoriousClient enable enable - 1.0.1 + 2.0.0 README.md Brice SCHUMACHER https://github.com/Notorious-Coding/Notorious-Client/ @@ -17,7 +17,6 @@ - From 64f802249dd41ab4244853f1c683e1bbdba06102 Mon Sep 17 00:00:00 2001 From: Brice SCHUMACHER Date: Mon, 7 Jul 2025 19:13:39 +0200 Subject: [PATCH 2/2] =?UTF-8?q?feat=20:=20(NotoriousClient)=20Mise=20a=20j?= =?UTF-8?q?our=20des=20d=C3=A9pendences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NotoriousClient.Sample/NotoriousClient.Sample.csproj | 2 +- .../NotoriousClient.Tests.Unit.csproj | 10 +++++----- NotoriousClient.sln | 8 ++++++++ NotoriousClient/NotoriousClient.csproj | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/NotoriousClient.Sample/NotoriousClient.Sample.csproj b/NotoriousClient.Sample/NotoriousClient.Sample.csproj index 61d35b0..eec75d0 100644 --- a/NotoriousClient.Sample/NotoriousClient.Sample.csproj +++ b/NotoriousClient.Sample/NotoriousClient.Sample.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net9.0 enable enable diff --git a/NotoriousClient.Tests.Unit/NotoriousClient.Tests.Unit.csproj b/NotoriousClient.Tests.Unit/NotoriousClient.Tests.Unit.csproj index 69f88ec..3902634 100644 --- a/NotoriousClient.Tests.Unit/NotoriousClient.Tests.Unit.csproj +++ b/NotoriousClient.Tests.Unit/NotoriousClient.Tests.Unit.csproj @@ -1,7 +1,7 @@  - net6.0 + net9.0 enable enable @@ -15,13 +15,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/NotoriousClient.sln b/NotoriousClient.sln index 05b63d3..e8bc920 100644 --- a/NotoriousClient.sln +++ b/NotoriousClient.sln @@ -9,6 +9,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotoriousClient.Sample", "N EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotoriousClient.Tests.Unit", "NotoriousClient.Tests.Unit\NotoriousClient.Tests.Unit.csproj", "{8F832E05-5A6C-4289-AB1E-2CD644E521DF}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Deployment", "Deployment", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Éléments de solution", "Éléments de solution", "{9C8CB701-102D-CF49-A3E0-89AC09D42C2C}" + ProjectSection(SolutionItems) = preProject + .github\workflows\prerelease.yml = .github\workflows\prerelease.yml + .github\workflows\release.yml = .github\workflows\release.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/NotoriousClient/NotoriousClient.csproj b/NotoriousClient/NotoriousClient.csproj index 0ce1d75..12dc05c 100644 --- a/NotoriousClient/NotoriousClient.csproj +++ b/NotoriousClient/NotoriousClient.csproj @@ -15,7 +15,7 @@ - +