From 795dcf42e25cedf9809f2604c153991b3377273e Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sat, 3 Dec 2022 11:03:57 +0100 Subject: [PATCH] Add .Net 7 (#853) * Add .NET 7 * UseDotNet * 7 * Ubuntu 6 * 'Use .NET 7' * 67 * . * use 7 * use 7 * test = 7 * coverage.7.0.opencover.xml --- azure-pipelines-ci-linux.yml | 10 ++++++- azure-pipelines-ci.yml | 30 +++++++++++-------- azure-pipelines-linux.yml | 6 ++++ azure-pipelines-nuget.yml | 6 ++++ .../Matchers/CSharpCodeMatcher.cs | 4 +-- .../WireMock.Net.Matchers.CSharpCode.csproj | 4 +-- .../WireMock.Net.StandAlone.csproj | 2 +- src/WireMock.Net/Http/HttpClientBuilder.cs | 2 +- .../Owin/AspNetCoreSelfHost.NETCore.cs | 2 +- src/WireMock.Net/Owin/AspNetCoreSelfHost.cs | 6 ++-- src/WireMock.Net/WireMock.Net.csproj | 6 ++-- .../dotnet-WireMock.csproj | 6 ++-- .../WireMock.Net.Tests.csproj | 2 +- .../WireMock.Net.Tests/WireMockServerTests.cs | 4 +-- 14 files changed, 59 insertions(+), 31 deletions(-) diff --git a/azure-pipelines-ci-linux.yml b/azure-pipelines-ci-linux.yml index 44136841..d9b89730 100644 --- a/azure-pipelines-ci-linux.yml +++ b/azure-pipelines-ci-linux.yml @@ -5,8 +5,16 @@ variables: buildConfiguration: 'Release' steps: +- task: UseDotNet@2 + displayName: 'Use .NET 7' + inputs: + packageType: sdk + version: 7.0.x + - script: | - dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration $(buildConfiguration) --framework net6.0 --logger trx + dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --configuration $(buildConfiguration) --framework net7.0 --logger trx + displayName: 'Test' + - task: PublishTestResults@2 inputs: testRunner: VSTest diff --git a/azure-pipelines-ci.yml b/azure-pipelines-ci.yml index d1ca4c6d..cf5ee734 100644 --- a/azure-pipelines-ci.yml +++ b/azure-pipelines-ci.yml @@ -14,6 +14,12 @@ jobs: echo "BuildId = $(buildId)" displayName: 'Print buildId' + - task: UseDotNet@2 + displayName: Use .NET 7.0 + inputs: + packageType: 'sdk' + version: '7.0.x' + - task: PowerShell@2 displayName: "Use JDK11 by default" inputs: @@ -35,18 +41,18 @@ jobs: projectKey: 'WireMock-Net_WireMock.Net' projectName: 'WireMock.Net' extraProperties: | - sonar.cs.opencover.reportsPaths=**/coverage.net6.0.opencover.xml + sonar.cs.opencover.reportsPaths=**/coverage.net7.0.opencover.xml - task: DotNetCoreCLI@2 displayName: 'Build Unit tests' inputs: command: 'build' projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' - arguments: '--configuration Debug --framework net6.0' + arguments: '--configuration Debug --framework net7.0' - task: CmdLine@2 inputs: - script: 'dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --no-build --configuration Debug --framework net6.0' + script: 'dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --no-build --configuration Debug --framework net7.0' displayName: 'Execute Unit Tests with Coverage' - task: SonarCloudAnalyze@1 @@ -62,7 +68,7 @@ jobs: condition: and(succeeded(), eq(variables['RUN_WHITESOURCE'], 'yes')) - script: | - bash <(curl https://codecov.io/bash) -t $(CODECOV_TOKEN) -f ./test/WireMock.Net.Tests/coverage.net6.0.opencover.xml + bash <(curl https://codecov.io/bash) -t $(CODECOV_TOKEN) -f ./test/WireMock.Net.Tests/coverage.7.0.opencover.xml displayName: 'codecov' - task: PublishTestResults@2 @@ -74,7 +80,7 @@ jobs: - task: PublishBuildArtifacts@1 displayName: Publish coverage file inputs: - PathtoPublish: './test/WireMock.Net.Tests/coverage.net6.0.opencover.xml' + PathtoPublish: './test/WireMock.Net.Tests/coverage.net7.0.opencover.xml' - job: Windows_Build_Test @@ -83,24 +89,24 @@ jobs: steps: - task: UseDotNet@2 - displayName: Use .NET 6.0 + displayName: Use .NET 7.0 inputs: packageType: 'sdk' - version: '6.0.x' + version: '7.0.x' - task: DotNetCoreCLI@2 displayName: 'Build Unit tests' inputs: command: 'build' projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' - arguments: '--configuration Debug --framework net6.0' + arguments: '--configuration Debug --framework net7.0' - task: DotNetCoreCLI@2 - displayName: 'Execute Unit tests' + displayName: 'Execute Unit Tests with Coverage' inputs: command: 'test' projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj' - arguments: '--no-build --configuration Debug --framework net6.0 --collect:"XPlat Code Coverage" --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover' + arguments: '--no-build --configuration Debug --framework net7.0 --collect:"XPlat Code Coverage" --logger trx' - job: Windows_Release_to_MyGet dependsOn: Windows_Build_Test @@ -110,10 +116,10 @@ jobs: steps: - task: UseDotNet@2 - displayName: Use .NET 6.0 + displayName: Use .NET 7.0 inputs: packageType: 'sdk' - version: '6.0.x' + version: '7.0.x' - task: DotNetCoreCLI@2 displayName: Build Release diff --git a/azure-pipelines-linux.yml b/azure-pipelines-linux.yml index ee7a9a42..4ad88c40 100644 --- a/azure-pipelines-linux.yml +++ b/azure-pipelines-linux.yml @@ -9,6 +9,12 @@ variables: buildConfiguration: 'Release' steps: +- task: UseDotNet@2 + displayName: 'Use .NET 7' + inputs: + packageType: sdk + version: 7.0.x + - task: DotNetCoreCLI@2 displayName: Build Release inputs: diff --git a/azure-pipelines-nuget.yml b/azure-pipelines-nuget.yml index 5f42a41a..13bfe81d 100644 --- a/azure-pipelines-nuget.yml +++ b/azure-pipelines-nuget.yml @@ -12,6 +12,12 @@ steps: echo "BuildId = $(buildId)" displayName: 'Print buildId' +- task: UseDotNet@2 + displayName: 'Use .NET 7' + inputs: + packageType: sdk + version: 7.0.x + # Based on https://whereslou.com/2018/09/versioning-and-publishing-nuget-packages-automatically-using-azure-devops-pipelines/ - task: DotNetCoreCLI@2 displayName: Build Release diff --git a/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs b/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs index c50acd20..c8b8d0f2 100644 --- a/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs +++ b/src/WireMock.Net.Matchers.CSharpCode/Matchers/CSharpCodeMatcher.cs @@ -154,8 +154,8 @@ internal class CSharpCodeMatcher : ICSharpCodeMatcher throw new WireMockException("CSharpCodeMatcher: Problem calling method 'IsMatch' in WireMock.CodeHelper", ex); } -#elif (NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0 || NET6_0) - Assembly assembly; +#elif (NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP3_1 || NET5_0 || NET6_0 || NET7_0) + Assembly assembly; try { assembly = CSScriptLib.CSScript.Evaluator.CompileCode(source); diff --git a/src/WireMock.Net.Matchers.CSharpCode/WireMock.Net.Matchers.CSharpCode.csproj b/src/WireMock.Net.Matchers.CSharpCode/WireMock.Net.Matchers.CSharpCode.csproj index 27f7ad7d..420f2a4b 100644 --- a/src/WireMock.Net.Matchers.CSharpCode/WireMock.Net.Matchers.CSharpCode.csproj +++ b/src/WireMock.Net.Matchers.CSharpCode/WireMock.Net.Matchers.CSharpCode.csproj @@ -4,7 +4,7 @@ A CSharpCodeMatcher which can be used to match WireMock.Net Requests using C# code. WireMock.Net.Matchers.CSharpCode Stef Heyenrath - net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0 + net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0 true wiremock;matchers;matcher;csharp;csharpcode WireMock @@ -45,7 +45,7 @@ - + diff --git a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj index 79b4208c..2ae8e957 100644 --- a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj +++ b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj @@ -3,7 +3,7 @@ Lightweight StandAlone Http Mocking Server for .Net. WireMock.Net.StandAlone Stef Heyenrath - net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0 + net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0 true WireMock.Net.StandAlone WireMock.Net.StandAlone diff --git a/src/WireMock.Net/Http/HttpClientBuilder.cs b/src/WireMock.Net/Http/HttpClientBuilder.cs index 70142cc2..6e9e6a17 100644 --- a/src/WireMock.Net/Http/HttpClientBuilder.cs +++ b/src/WireMock.Net/Http/HttpClientBuilder.cs @@ -9,7 +9,7 @@ internal static class HttpClientBuilder { public static HttpClient Build(HttpClientSettings settings) { -#if NETSTANDARD || NETCOREAPP3_1 || NET5_0 || NET6_0 +#if NETSTANDARD || NETCOREAPP3_1 || NET5_0 || NET6_0 || NET7_0 var handler = new HttpClientHandler { CheckCertificateRevocationList = false, diff --git a/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETCore.cs b/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETCore.cs index 1a5c85e9..c5fcc131 100644 --- a/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETCore.cs +++ b/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETCore.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_1 || NET5_0 || NET6_0 +#if NETCOREAPP3_1 || NET5_0 || NET6_0 || NET7_0 using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; using WireMock.Types; diff --git a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs index 1a168868..151c7d1b 100644 --- a/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs +++ b/src/WireMock.Net/Owin/AspNetCoreSelfHost.cs @@ -69,7 +69,7 @@ namespace WireMock.Owin services.AddSingleton(); services.AddSingleton(); -#if NETCOREAPP3_1 || NET5_0 || NET6_0 +#if NETCOREAPP3_1 || NET5_0 || NET6_0 || NET7_0 AddCors(services); #endif _wireMockMiddlewareOptions.AdditionalServiceRegistration?.Invoke(services); @@ -78,7 +78,7 @@ namespace WireMock.Owin { appBuilder.UseMiddleware(); -#if NETCOREAPP3_1 || NET5_0 || NET6_0 +#if NETCOREAPP3_1 || NET5_0 || NET6_0 || NET7_0 UseCors(appBuilder); #endif _wireMockMiddlewareOptions.PreWireMockMiddlewareInit?.Invoke(appBuilder); @@ -137,6 +137,8 @@ namespace WireMock.Owin _logger.Info("Server using .NET 5.0"); #elif NET6_0 _logger.Info("Server using .NET 6.0"); +#elif NET7_0 + _logger.Info("Server using .NET 7.0"); #elif NET46 _logger.Info("Server using .NET Framework 4.6.1 or higher"); #endif diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 4aa6fce6..7d2952e5 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -3,7 +3,7 @@ Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape. WireMock.Net Stef Heyenrath - net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0 + net451;net452;net46;net461;netstandard1.3;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0;net7.0 true WireMock.Net WireMock.Net @@ -38,7 +38,7 @@ NETSTANDARD;USE_ASPNETCORE - + USE_ASPNETCORE @@ -135,7 +135,7 @@ - + diff --git a/src/dotnet-WireMock.Net/dotnet-WireMock.csproj b/src/dotnet-WireMock.Net/dotnet-WireMock.csproj index e836f871..6f3ef9ff 100644 --- a/src/dotnet-WireMock.Net/dotnet-WireMock.csproj +++ b/src/dotnet-WireMock.Net/dotnet-WireMock.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 true dotnet-wiremock A dotnet commandline tool for WireMock.Net (A Lightweight Http Mocking Server for .NET) @@ -16,8 +16,8 @@ - - + + diff --git a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj index 794e4038..dd563ece 100644 --- a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj +++ b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj @@ -2,7 +2,7 @@ Stef Heyenrath - net452;net461;netcoreapp3.1;net5.0;net6.0 + net452;net461;netcoreapp3.1;net6.0;net7.0 false full WireMock.Net.Tests diff --git a/test/WireMock.Net.Tests/WireMockServerTests.cs b/test/WireMock.Net.Tests/WireMockServerTests.cs index 7eb75665..a50bb8e2 100644 --- a/test/WireMock.Net.Tests/WireMockServerTests.cs +++ b/test/WireMock.Net.Tests/WireMockServerTests.cs @@ -110,8 +110,8 @@ public partial class WireMockServerTests server.Stop(); } -#if NETCOREAPP3_1 || NET5_0 || NET6_0 -[Fact] +#if NETCOREAPP3_1 || NET5_0 || NET6_0 || NET7_0 + [Fact] public async Task WireMockServer_WithCorsPolicyOptions_Should_Work_Correct() { // Arrange