Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion NotoriousClient.Sample/NotoriousClient.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
10 changes: 5 additions & 5 deletions NotoriousClient.Tests.Unit/NotoriousClient.Tests.Unit.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -15,13 +15,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
8 changes: 8 additions & 0 deletions NotoriousClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion NotoriousClient/Builder/RequestBuilder.Body.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial class RequestBuilder : IRequestBuilder
/// <summary>
/// Default JSON Converter.
/// </summary>
protected IJsonSerializer DefaultJsonConverter = new NewtonsoftJsonSerializer();
protected IJsonSerializer DefaultJsonConverter = new SystemTextJsonSerializer();

private List<Body> _bodies = new List<Body>();
private bool? _isMultipartRequest = null;
Expand Down
3 changes: 2 additions & 1 deletion NotoriousClient/Clients/BaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
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;
}
Expand All @@ -48,7 +49,7 @@
/// </summary>
/// <param name="route">Request's Route.</param>
/// <param name="method">Request's Method (GET, POST, PUT, DELETE...).</param>
protected virtual async Task<IRequestBuilder> GetBuilderAsync(string route, Method method = Method.Get)

Check warning on line 52 in NotoriousClient/Clients/BaseClient.cs

View workflow job for this annotation

GitHub Actions / publish

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
=> new RequestBuilder(_url, route, method);

/// <summary>
Expand Down
8 changes: 3 additions & 5 deletions NotoriousClient/Clients/BasicAuthBaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,17 @@ public abstract class BasicAuthBaseClient : BaseClient
private readonly string _password;

/// <summary>
/// Initialize a new instance of <see cref="SynchronousBaseClient"/>.
/// Initialize a new instance of <see cref="BasicAuthBaseClient"/>.
/// </summary>
/// <param name="sender">Class used to send <see cref="HttpRequestMessage"/>.</param>
/// <param name="url">Base URL of api (ex: https://myapi.com/).</param>
/// <param name="login">User's login.</param>
/// <param name="password">User's password.</param>
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;

namespace NotoriousClient.Converters
{
/// <summary>
/// Serialize object to JSON using NewtonsoftJson.
/// </summary>
public class NewtonsoftJsonSerializer : IJsonSerializer
public class SystemTextJsonSerializer : IJsonSerializer
{
public string ConvertToJson(object obj)
{
return JsonConvert.SerializeObject(obj);
return JsonSerializer.Serialize(obj);
}
}
}
7 changes: 3 additions & 4 deletions NotoriousClient/NotoriousClient.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Description>A fluent HTTPResponseMessage builder with fully extendable API Client implementation.</Description>
<PackageId>NotoriousClient</PackageId>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.0.1</Version>
<Version>2.0.0</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Authors>Brice SCHUMACHER</Authors>
<RepositoryUrl>https://github.com/Notorious-Coding/Notorious-Client/</RepositoryUrl>
Expand All @@ -15,9 +15,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading