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.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/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..12dc05c 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/
@@ -15,9 +15,8 @@
-
+
-