From 43764cc3f3d39214b833c3f78b3d3dd143fdd26d Mon Sep 17 00:00:00 2001 From: Valters Melnalksnis Date: Wed, 9 Nov 2022 21:57:31 +0200 Subject: [PATCH] feat: Add .NET Standard 2.0 target --- .github/workflows/test.yml | 48 ++++++++++--------- Directory.Build.props | 13 +++++ global.json | 2 +- .../ServiceCollectionExtensions.cs | 4 ++ ....NordigenDotNet.DependencyInjection.csproj | 2 - .../HttpResponseMessageExtensions.cs | 4 ++ .../VMelnalksnis.NordigenDotNet.csproj | 8 +++- tests/Directory.Build.props | 6 +++ ...genDotNet.DependencyInjection.Tests.csproj | 4 -- .../Agreements/AgreementClientTests.cs | 13 ++++- .../Requisitions/RequisitionsClientTests.cs | 7 ++- ...is.NordigenDotNet.Tests.Integration.csproj | 1 - .../VMelnalksnis.NordigenDotNet.Tests.csproj | 1 - 13 files changed, 76 insertions(+), 37 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5e6bf41..1128516 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,39 +26,41 @@ jobs: steps: - uses: actions/checkout@v3.1.0 - uses: actions/setup-dotnet@v3.0.3 + with: + dotnet-version: | + 3.1.x + 5.0.x + 6.0.x + 7.0.x - run: dotnet restore - - - name: Build - run: > - dotnet build - --configuration Release - --no-restore - /warnAsError - /nologo - /clp:NoSummary + - run: dotnet build --configuration Release --no-restore /warnAsError /nologo /clp:NoSummary - name: Run Tests - run: > - dotnet test - -p:CollectCoverage=true - -p:CoverletOutput=TestResults/ - -p:CoverletOutputFormat=opencover - --configuration Release - --no-build + run: dotnet test -p:CollectCoverage=true --configuration Release --no-build env: Nordigen__SecretId: ${{ secrets.NORDIGEN_SECRET_ID }} Nordigen__SecretKey: ${{ secrets.NORDIGEN_SECRET_KEY }} - - name: ReSharper annotations - uses: VMelnalksnis/resharper-inspect-action@v0.2.5 - with: - solution: NordigenDotNet.sln - resharper-version: 2022.1.2 - treat-warnings-as-errors: true - - name: Gather Code Coverage if: github.event.schedule == null uses: codecov/codecov-action@v3.1.1 with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true + + resharper: + name: Resharper + runs-on: ubuntu-latest + if: false #ReSharper currently does not support .NET 7 + steps: + - uses: actions/checkout@v3.1.0 + - uses: actions/setup-dotnet@v3.0.3 + - run: dotnet restore + - run: dotnet build --configuration Release --no-restore /warnAsError /nologo /clp:NoSummary + + - name: ReSharper annotations + uses: VMelnalksnis/resharper-inspect-action@v0.2.5 + with: + solution: NordigenDotNet.sln + resharper-version: 2022.1.2 + treat-warnings-as-errors: true diff --git a/Directory.Build.props b/Directory.Build.props index 4436359..4b39e0a 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,7 @@ + netstandard2.0;net6.0 + latest enable true portable @@ -31,6 +33,17 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + stylecop.json diff --git a/global.json b/global.json index 1703d4a..b9d66c8 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.400", + "version": "7.0.100", "rollForward": "latestFeature", "allowPrerelease": false } diff --git a/source/VMelnalksnis.NordigenDotNet.DependencyInjection/ServiceCollectionExtensions.cs b/source/VMelnalksnis.NordigenDotNet.DependencyInjection/ServiceCollectionExtensions.cs index 86cafe6..f01de09 100644 --- a/source/VMelnalksnis.NordigenDotNet.DependencyInjection/ServiceCollectionExtensions.cs +++ b/source/VMelnalksnis.NordigenDotNet.DependencyInjection/ServiceCollectionExtensions.cs @@ -40,7 +40,11 @@ public static class ServiceCollectionExtensions /// The service collection in which to register the services. /// The configuration to which to bind options models. /// The for the used by . +#if NET6_0_OR_GREATER [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026", Justification = $"{nameof(NordigenOptions)} contains only system types.")] +#else + [SuppressMessage("Trimming", "IL2026", Justification = $"{nameof(NordigenOptions)} contains only system types.")] +#endif public static IHttpClientBuilder AddNordigenDotNet( this IServiceCollection serviceCollection, IConfiguration configuration) diff --git a/source/VMelnalksnis.NordigenDotNet.DependencyInjection/VMelnalksnis.NordigenDotNet.DependencyInjection.csproj b/source/VMelnalksnis.NordigenDotNet.DependencyInjection/VMelnalksnis.NordigenDotNet.DependencyInjection.csproj index 41edbcc..6c98975 100644 --- a/source/VMelnalksnis.NordigenDotNet.DependencyInjection/VMelnalksnis.NordigenDotNet.DependencyInjection.csproj +++ b/source/VMelnalksnis.NordigenDotNet.DependencyInjection/VMelnalksnis.NordigenDotNet.DependencyInjection.csproj @@ -1,8 +1,6 @@ - net6.0 - VMelnalksnis.NordigenDotNet.DependencyInjection VMelnalksnis.NordigenDotNet.DependencyInjection Dependency injection configuration for VMelnalksnis.NordigenDotNet diff --git a/source/VMelnalksnis.NordigenDotNet/Serialization/HttpResponseMessageExtensions.cs b/source/VMelnalksnis.NordigenDotNet/Serialization/HttpResponseMessageExtensions.cs index 9c0578d..64d66b0 100644 --- a/source/VMelnalksnis.NordigenDotNet/Serialization/HttpResponseMessageExtensions.cs +++ b/source/VMelnalksnis.NordigenDotNet/Serialization/HttpResponseMessageExtensions.cs @@ -17,6 +17,10 @@ internal static class HttpResponseMessageExtensions } var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); +#if NET6_0_OR_GREATER throw new HttpRequestException(content, null, response.StatusCode); +#else + throw new HttpRequestException(content); +#endif } } diff --git a/source/VMelnalksnis.NordigenDotNet/VMelnalksnis.NordigenDotNet.csproj b/source/VMelnalksnis.NordigenDotNet/VMelnalksnis.NordigenDotNet.csproj index d551fe2..fee4b2e 100644 --- a/source/VMelnalksnis.NordigenDotNet/VMelnalksnis.NordigenDotNet.csproj +++ b/source/VMelnalksnis.NordigenDotNet/VMelnalksnis.NordigenDotNet.csproj @@ -1,8 +1,6 @@ - net6.0 - VMelnalksnis.NordigenDotNet VMelnalksnis.NordigenDotNet .NET API client for Nordigen @@ -20,6 +18,12 @@ + + + + + + diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index ddc8278..3760e83 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -2,9 +2,15 @@ + netcoreapp3.1;net5.0;net6.0;net7.0 false false false + true + NETSDK1138 + + opencover + $(MSBuildThisFileDirectory)TestResults/$(AssemblyName)/$(TargetFramework)/ diff --git a/tests/VMelnalksnis.NordigenDotNet.DependencyInjection.Tests/VMelnalksnis.NordigenDotNet.DependencyInjection.Tests.csproj b/tests/VMelnalksnis.NordigenDotNet.DependencyInjection.Tests/VMelnalksnis.NordigenDotNet.DependencyInjection.Tests.csproj index 131abce..56c9283 100644 --- a/tests/VMelnalksnis.NordigenDotNet.DependencyInjection.Tests/VMelnalksnis.NordigenDotNet.DependencyInjection.Tests.csproj +++ b/tests/VMelnalksnis.NordigenDotNet.DependencyInjection.Tests/VMelnalksnis.NordigenDotNet.DependencyInjection.Tests.csproj @@ -1,9 +1,5 @@ - - net6.0 - - diff --git a/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/Agreements/AgreementClientTests.cs b/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/Agreements/AgreementClientTests.cs index 3c39739..0ff1ac0 100644 --- a/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/Agreements/AgreementClientTests.cs +++ b/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/Agreements/AgreementClientTests.cs @@ -3,7 +3,6 @@ // See LICENSE file in the project root for full license information. using System.Linq; -using System.Net; using System.Net.Http; using System.Threading.Tasks; @@ -13,6 +12,10 @@ using VMelnalksnis.NordigenDotNet.Agreements; using Xunit.Abstractions; +#if NET6_0_OR_GREATER +using System.Net; +#endif + using static VMelnalksnis.NordigenDotNet.Tests.Integration.ServiceProviderFixture; namespace VMelnalksnis.NordigenDotNet.Tests.Integration.Agreements; @@ -57,8 +60,12 @@ public sealed class AgreementClientTests : IClassFixture .Awaiting(() => _nordigenClient.Agreements.Put(createdAgreement.Id, acceptance)) .Should() .ThrowExactlyAsync()) +#if NET6_0_OR_GREATER .Which.StatusCode.Should() .Be(HttpStatusCode.Forbidden, "test company cannot create agreements"); +#else + .Which.Should().NotBeNull("test company cannot create agreements"); +#endif await _nordigenClient.Agreements.Delete(createdAgreement.Id); @@ -66,7 +73,11 @@ public sealed class AgreementClientTests : IClassFixture .Awaiting(() => _nordigenClient.Agreements.Get(createdAgreement.Id)) .Should() .ThrowExactlyAsync()) +#if NET6_0_OR_GREATER .Which.StatusCode.Should() .Be(HttpStatusCode.NotFound); +#else + .Which.Should().NotBeNull("test company cannot create agreements"); +#endif } } diff --git a/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/Requisitions/RequisitionsClientTests.cs b/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/Requisitions/RequisitionsClientTests.cs index ca80518..97e8f3c 100644 --- a/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/Requisitions/RequisitionsClientTests.cs +++ b/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/Requisitions/RequisitionsClientTests.cs @@ -87,8 +87,11 @@ public sealed class RequisitionsClientTests : IClassFixture _nordigenClient.Requisitions.Get(requisition.Id)) .Should() .ThrowExactlyAsync()) - .Which.StatusCode - .Should() +#if NET6_0_OR_GREATER + .Which.StatusCode.Should() .Be(HttpStatusCode.NotFound); +#else + .Which.Should().NotBeNull("test company cannot create agreements"); +#endif } } diff --git a/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/VMelnalksnis.NordigenDotNet.Tests.Integration.csproj b/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/VMelnalksnis.NordigenDotNet.Tests.Integration.csproj index 42a088a..57097f0 100644 --- a/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/VMelnalksnis.NordigenDotNet.Tests.Integration.csproj +++ b/tests/VMelnalksnis.NordigenDotNet.Tests.Integration/VMelnalksnis.NordigenDotNet.Tests.Integration.csproj @@ -1,7 +1,6 @@ - net6.0 471f5b3c-5334-4315-8d06-7bcfb17af644 diff --git a/tests/VMelnalksnis.NordigenDotNet.Tests/VMelnalksnis.NordigenDotNet.Tests.csproj b/tests/VMelnalksnis.NordigenDotNet.Tests/VMelnalksnis.NordigenDotNet.Tests.csproj index 320cfe1..e885215 100644 --- a/tests/VMelnalksnis.NordigenDotNet.Tests/VMelnalksnis.NordigenDotNet.Tests.csproj +++ b/tests/VMelnalksnis.NordigenDotNet.Tests/VMelnalksnis.NordigenDotNet.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 true key.snk