From b6ec764bd3822cb0178a39b43c0149363585f77d Mon Sep 17 00:00:00 2001
From: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com>
Date: Fri, 15 Dec 2023 09:14:58 +0100
Subject: [PATCH] chore: support net8.0 preview (#455)
* chore: support net8.0 preview
* pr-fix: update w/ correct az func version
* pr-fix: deprecate unnecessary extension
* pr-revert: az func json configure formatters
* pr-fix: add net8.0 docker support
* pr-fix: docker az func in-process image
* pr-fix: install preview net 8.0 sdk in docker build
* pr-fix: use bc dotnet version
* pr-fix: skip currently not-supported in-process az func docker
* pr-fix: correct overall preview .net version
* pr-fix: stabelize logging assertion
* pr-fix: skip az func in-process tests
* pr-fix: remove unnecessary built-in json test
* pr-fix: remove built-in json test
---
.github/workflows/code-coverage.yml | 4 ++
.github/workflows/codeql-analysis.yml | 4 ++
build/ci-build.yml | 3 +
build/nuget-release.yml | 3 +
.../run-docker-integration-tests.yml | 32 +++++----
build/variables/build.yml | 4 +-
.../preview/03-Features/hosting/formatting.md | 22 ------
...Arcus.WebApi.Hosting.AzureFunctions.csproj | 11 +--
.../Arcus.WebApi.Hosting.csproj | 10 +--
.../Extensions/MvcOptionsExtensions.cs | 6 +-
...Arcus.WebApi.Logging.AzureFunctions.csproj | 13 ++--
.../Arcus.WebApi.Logging.Core.csproj | 22 +++---
.../Arcus.WebApi.Logging.csproj | 24 +++----
.../ExceptionHandlingMiddleware.cs | 2 +-
.../Arcus.WebApi.OpenApi.Extensions.csproj | 14 ++--
.../Arcus.WebApi.Security.csproj | 25 +++----
.../Arcus.WebApi.Tests.Core.csproj | 4 +-
.../Arcus.WebApi.Tests.Integration.csproj | 4 +-
.../Formatting/MvcOptionsExtensionsTests.cs | 70 -------------------
.../AzureFunctionCorrelationDockerTests.cs | 6 +-
...ryApplicationInsightsTelemetryConverter.cs | 2 +-
...sts.Runtimes.AzureFunction.Isolated.csproj | 11 ++-
.../Dockerfile | 4 +-
...WebApi.Tests.Runtimes.AzureFunction.csproj | 2 +-
.../Dockerfile | 4 +-
.../Arcus.WebApi.Tests.Unit.csproj | 2 +-
.../Formatting/MvcOptionsExtensionsTests.cs | 30 --------
.../AzureFunctionsRequestTrackingTests.cs | 6 +-
.../AuthenticationBuilderExtensionsTests.cs | 2 +
29 files changed, 113 insertions(+), 233 deletions(-)
diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml
index 71cd2c32..4da2b460 100644
--- a/.github/workflows/code-coverage.yml
+++ b/.github/workflows/code-coverage.yml
@@ -23,6 +23,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
+ - uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: '8.0.x'
+ dotnet-quality: 'preview'
- name: Coverlet coverage unit test
run: dotnet test -c Debug -p:coverletOutput=coverage.json -p:CollectCoverage=true -p:CoverletOutputFormat=\"opencover,json\" -p:ExcludeByAttribute=\"Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute\" -p:Exclude=\"[Arcus.WebApi.Tests.*]*,[Arcus.WebApi.Security]*,[Arcus.WebApi.OpenApi.Extensions]*\" src/Arcus.WebApi.Tests.Unit/Arcus.WebApi.Tests.Unit.csproj
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index e06e4885..ace3264c 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -39,6 +39,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
+ - uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: '8.0.x'
+ dotnet-quality: 'preview'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
diff --git a/build/ci-build.yml b/build/ci-build.yml
index 1ce31117..e08fa70e 100644
--- a/build/ci-build.yml
+++ b/build/ci-build.yml
@@ -52,6 +52,7 @@ stages:
- template: 'build/build-solution.yml@templates'
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
+ includePreviewVersions: true
versionSuffix: '$(packageVersion)'
- task: CopyFiles@2
displayName: 'Copy build artifacts'
@@ -82,6 +83,7 @@ stages:
- template: test/run-unit-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
+ includePreviewVersions: true
projectName: '$(Project).Tests.Unit'
- stage: DockerIntegrationTests
@@ -119,6 +121,7 @@ stages:
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
+ includePreviewVersions: true
projectName: '$(Project).Tests.Integration'
category: 'Integration'
diff --git a/build/nuget-release.yml b/build/nuget-release.yml
index b8a5189a..161d8cfd 100644
--- a/build/nuget-release.yml
+++ b/build/nuget-release.yml
@@ -37,6 +37,7 @@ stages:
- template: build/build-solution.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
+ includePreviewVersions: true
version: $(Build.BuildNumber)
- task: CopyFiles@2
displayName: 'Copy build artifacts'
@@ -72,6 +73,7 @@ stages:
- template: test/run-unit-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
+ includePreviewVersions: true
projectName: '$(Project).Tests.Unit'
- stage: DockerIntegrationTests
@@ -109,6 +111,7 @@ stages:
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
+ includePreviewVersions: true
projectName: '$(Project).Tests.Integration'
category: 'Integration'
diff --git a/build/templates/run-docker-integration-tests.yml b/build/templates/run-docker-integration-tests.yml
index 70345248..9d7a1d13 100644
--- a/build/templates/run-docker-integration-tests.yml
+++ b/build/templates/run-docker-integration-tests.yml
@@ -1,13 +1,15 @@
steps:
- task: UseDotNet@2
- displayName: 'Import .NET Core SDK ($(DotNet.Sdk.VersionBC))'
+ displayName: 'Import .NET Core SDK ($(DotNet.Sdk.Version))'
inputs:
packageType: 'sdk'
- version: '$(DotNet.Sdk.VersionBC)'
- - template: start-docker-project.yml
- parameters:
- dockerProjectName: '$(Project).Tests.Runtimes.AzureFunction'
- port: '$(Arcus.AzureFunctions.InProcess.HttpPort)'
+ version: '$(DotNet.Sdk.Version)'
+ includePreviewVersions: true
+ # .NET 8 not available yet for Azure Functions in-process
+ # - template: start-docker-project.yml
+ # parameters:
+ # dockerProjectName: '$(Project).Tests.Runtimes.AzureFunction'
+ # port: '$(Arcus.AzureFunctions.InProcess.HttpPort)'
- template: start-docker-project.yml
parameters:
dockerProjectName: '$(Project).Tests.Runtimes.AzureFunction.Isolated'
@@ -15,16 +17,18 @@ steps:
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
+ includePreviewVersions: true
projectName: '$(Project).Tests.Integration'
category: 'Docker'
- - task: Bash@3
- inputs:
- targetType: 'inline'
- script: |
- docker logs $(Project).Tests.Runtimes.AzureFunction
- failOnStderr: true
- displayName: Show $(Project).Tests.Runtimes.AzureFunction logs
- condition: always()
+ # .NET 8 not available yet for Azure Functions in-process
+ # - task: Bash@3
+ # inputs:
+ # targetType: 'inline'
+ # script: |
+ # docker logs $(Project).Tests.Runtimes.AzureFunction
+ # failOnStderr: true
+ # displayName: Show $(Project).Tests.Runtimes.AzureFunction logs
+ # condition: always()
- task: Bash@3
inputs:
targetType: 'inline'
diff --git a/build/variables/build.yml b/build/variables/build.yml
index 73ecba9d..6a520dac 100644
--- a/build/variables/build.yml
+++ b/build/variables/build.yml
@@ -1,6 +1,6 @@
variables:
- DotNet.Sdk.Version: '6.0.100'
+ DotNet.Sdk.Version: '8.0.x'
# Backwards compatible .NET SDK version
- DotNet.Sdk.VersionBC: '3.1.201'
+ DotNet.Sdk.VersionBC: '6.0.100'
Project: 'Arcus.WebApi'
Vm.Image: 'ubuntu-latest'
\ No newline at end of file
diff --git a/docs/preview/03-Features/hosting/formatting.md b/docs/preview/03-Features/hosting/formatting.md
index 0f9371fc..892dce67 100644
--- a/docs/preview/03-Features/hosting/formatting.md
+++ b/docs/preview/03-Features/hosting/formatting.md
@@ -30,25 +30,3 @@ builder.Services.AddControllers(mvcOptions =>
mvcOptions.OnlyAllowJsonFormatting();
});
```
-
-## Configure JSON format
-We have provided an extension that will allow you to configure the input and output JSON formatting in one go. This means that any options you configure in this extension will automatically apply to the incoming model as well as the outgoing model. This makes the JSON formatting more streamlined and easier to maintain.
-
-Following example shows you how you can configure these options:
-
-```csharp
-using System.Text.Json.Serialization;
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Mvc;
-
-WebApplicationBuilder builder = WebApplication.CreateBuilder();
-
-builder.Services.AddControllers(mvcOptions =>
-{
- mvcOptions.ConfigureJsonFormatting(jsonOptions =>
- {
- jsonOptions.Converters.Add(new JsonStringEnumConverter());
- });
-});
-```
-
diff --git a/src/Arcus.WebApi.Hosting.AzureFunctions/Arcus.WebApi.Hosting.AzureFunctions.csproj b/src/Arcus.WebApi.Hosting.AzureFunctions/Arcus.WebApi.Hosting.AzureFunctions.csproj
index c84cecc0..b6e4bc4e 100644
--- a/src/Arcus.WebApi.Hosting.AzureFunctions/Arcus.WebApi.Hosting.AzureFunctions.csproj
+++ b/src/Arcus.WebApi.Hosting.AzureFunctions/Arcus.WebApi.Hosting.AzureFunctions.csproj
@@ -1,7 +1,7 @@
- net6.0;netcoreapp3.1
+ net8.0;net6.0
Arcus
Arcus
Git
@@ -26,14 +26,7 @@
-
-
-
-
-
-
-
-
+
diff --git a/src/Arcus.WebApi.Hosting/Arcus.WebApi.Hosting.csproj b/src/Arcus.WebApi.Hosting/Arcus.WebApi.Hosting.csproj
index ed778615..7c0576a7 100644
--- a/src/Arcus.WebApi.Hosting/Arcus.WebApi.Hosting.csproj
+++ b/src/Arcus.WebApi.Hosting/Arcus.WebApi.Hosting.csproj
@@ -1,7 +1,7 @@
- net6.0;netcoreapp3.1
+ net8.0;net6.0
Arcus
Arcus
Git
@@ -28,12 +28,8 @@
-
-
-
-
-
-
+
+
diff --git a/src/Arcus.WebApi.Hosting/Formatting/Extensions/MvcOptionsExtensions.cs b/src/Arcus.WebApi.Hosting/Formatting/Extensions/MvcOptionsExtensions.cs
index d8654665..bf41937e 100644
--- a/src/Arcus.WebApi.Hosting/Formatting/Extensions/MvcOptionsExtensions.cs
+++ b/src/Arcus.WebApi.Hosting/Formatting/Extensions/MvcOptionsExtensions.cs
@@ -3,6 +3,7 @@
using System.Text.Json;
using GuardNet;
using Microsoft.AspNetCore.Mvc.Formatters;
+using Microsoft.Extensions.DependencyInjection;
// ReSharper disable once CheckNamespace
namespace Microsoft.AspNetCore.Mvc
@@ -35,18 +36,19 @@ public static MvcOptions OnlyAllowJsonFormatting(this MvcOptions options)
return options;
}
-
+
///
/// Configure the MVC JSON formatters for both receiving and sending.
///
/// The MVC options where the JSON formatters will be configured.
/// The function to configure the input and output JSON formatters in the MVC .
/// Thrown when the or is null.
+ [Obsolete("Use the " + nameof(MvcCoreMvcBuilderExtensions) + "." + nameof(MvcCoreMvcBuilderExtensions.AddJsonOptions) + " instead to configure the JSON formatters")]
public static MvcOptions ConfigureJsonFormatting(this MvcOptions options, Action configureOptions)
{
Guard.NotNull(options, nameof(options), "Requires MVC options to configure the JSON formatters");
Guard.NotNull(configureOptions, nameof(configureOptions), "Requires a function to configure the JSON formatters in the MVC options");
-
+
SystemTextJsonInputFormatter[] onlyJsonInputFormatters =
options.InputFormatters.OfType()
.ToArray();
diff --git a/src/Arcus.WebApi.Logging.AzureFunctions/Arcus.WebApi.Logging.AzureFunctions.csproj b/src/Arcus.WebApi.Logging.AzureFunctions/Arcus.WebApi.Logging.AzureFunctions.csproj
index 6087fbe3..62ff5f03 100644
--- a/src/Arcus.WebApi.Logging.AzureFunctions/Arcus.WebApi.Logging.AzureFunctions.csproj
+++ b/src/Arcus.WebApi.Logging.AzureFunctions/Arcus.WebApi.Logging.AzureFunctions.csproj
@@ -1,7 +1,7 @@
- net6.0;netcoreapp3.1;netstandard2.1
+ net8.0;net6.0;netstandard2.1
Arcus
Arcus
Git
@@ -18,15 +18,20 @@
true
+
+
+ NU5104
+
+
-
+
-
-
+
+
diff --git a/src/Arcus.WebApi.Logging.Core/Arcus.WebApi.Logging.Core.csproj b/src/Arcus.WebApi.Logging.Core/Arcus.WebApi.Logging.Core.csproj
index 52649a9f..3e31a578 100644
--- a/src/Arcus.WebApi.Logging.Core/Arcus.WebApi.Logging.Core.csproj
+++ b/src/Arcus.WebApi.Logging.Core/Arcus.WebApi.Logging.Core.csproj
@@ -1,7 +1,7 @@
- net6.0;netstandard2.1;netcoreapp3.1
+ net8.0;net6.0;netstandard2.1
Arcus
Arcus
Git
@@ -18,6 +18,11 @@
true
+
+
+ NU5104
+
+
@@ -34,18 +39,11 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/src/Arcus.WebApi.Logging/Arcus.WebApi.Logging.csproj b/src/Arcus.WebApi.Logging/Arcus.WebApi.Logging.csproj
index 9eda4f67..5187079a 100644
--- a/src/Arcus.WebApi.Logging/Arcus.WebApi.Logging.csproj
+++ b/src/Arcus.WebApi.Logging/Arcus.WebApi.Logging.csproj
@@ -1,7 +1,7 @@
- net6.0;netstandard2.1;netcoreapp3.1
+ net8.0;net6.0;netstandard2.1
Arcus
Arcus
Git
@@ -18,6 +18,11 @@
true
+
+
+ NU5104
+
+
@@ -36,19 +41,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/src/Arcus.WebApi.Logging/ExceptionHandlingMiddleware.cs b/src/Arcus.WebApi.Logging/ExceptionHandlingMiddleware.cs
index 7fb6d73d..bba462ba 100644
--- a/src/Arcus.WebApi.Logging/ExceptionHandlingMiddleware.cs
+++ b/src/Arcus.WebApi.Logging/ExceptionHandlingMiddleware.cs
@@ -63,7 +63,7 @@ public async Task Invoke(HttpContext context, ILoggerFactory loggerFactory)
{
await _next(context);
}
-#if NET6_0
+#if !NETSTANDARD2_1
catch (Microsoft.AspNetCore.Http.BadHttpRequestException exception)
#else
catch (Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException exception)
diff --git a/src/Arcus.WebApi.OpenApi.Extensions/Arcus.WebApi.OpenApi.Extensions.csproj b/src/Arcus.WebApi.OpenApi.Extensions/Arcus.WebApi.OpenApi.Extensions.csproj
index 4bd0195d..10bc60a1 100644
--- a/src/Arcus.WebApi.OpenApi.Extensions/Arcus.WebApi.OpenApi.Extensions.csproj
+++ b/src/Arcus.WebApi.OpenApi.Extensions/Arcus.WebApi.OpenApi.Extensions.csproj
@@ -1,7 +1,7 @@
- net6.0;netstandard2.1;netcoreapp3.1
+ net8.0;net6.0;netstandard2.1
Arcus
Arcus
Git
@@ -26,15 +26,13 @@
-
-
-
+
+
+
-
-
-
-
+
+
diff --git a/src/Arcus.WebApi.Security/Arcus.WebApi.Security.csproj b/src/Arcus.WebApi.Security/Arcus.WebApi.Security.csproj
index dcd323a0..6031da44 100644
--- a/src/Arcus.WebApi.Security/Arcus.WebApi.Security.csproj
+++ b/src/Arcus.WebApi.Security/Arcus.WebApi.Security.csproj
@@ -1,7 +1,7 @@
- net6.0;netstandard2.1;netcoreapp3.1
+ net8.0;net6.0;netstandard2.1
Arcus
Arcus
Git
@@ -18,6 +18,11 @@
true
+
+
+ NU5104
+
+
@@ -26,6 +31,7 @@
+
@@ -33,21 +39,10 @@
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
diff --git a/src/Arcus.WebApi.Tests.Core/Arcus.WebApi.Tests.Core.csproj b/src/Arcus.WebApi.Tests.Core/Arcus.WebApi.Tests.Core.csproj
index beb8701a..77410530 100644
--- a/src/Arcus.WebApi.Tests.Core/Arcus.WebApi.Tests.Core.csproj
+++ b/src/Arcus.WebApi.Tests.Core/Arcus.WebApi.Tests.Core.csproj
@@ -1,14 +1,14 @@
- net6.0;netcoreapp3.1
+ net8.0;net6.0
false
false
-
+
diff --git a/src/Arcus.WebApi.Tests.Integration/Arcus.WebApi.Tests.Integration.csproj b/src/Arcus.WebApi.Tests.Integration/Arcus.WebApi.Tests.Integration.csproj
index db075a9a..550d5d9f 100644
--- a/src/Arcus.WebApi.Tests.Integration/Arcus.WebApi.Tests.Integration.csproj
+++ b/src/Arcus.WebApi.Tests.Integration/Arcus.WebApi.Tests.Integration.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net8.0
true
false
true
@@ -19,7 +19,7 @@
-
+
diff --git a/src/Arcus.WebApi.Tests.Integration/Hosting/Formatting/MvcOptionsExtensionsTests.cs b/src/Arcus.WebApi.Tests.Integration/Hosting/Formatting/MvcOptionsExtensionsTests.cs
index 32343744..21eaac35 100644
--- a/src/Arcus.WebApi.Tests.Integration/Hosting/Formatting/MvcOptionsExtensionsTests.cs
+++ b/src/Arcus.WebApi.Tests.Integration/Hosting/Formatting/MvcOptionsExtensionsTests.cs
@@ -123,75 +123,5 @@ public async Task IncomingJson_WithOnlyAllowJsonFormatting_Succeeds()
}
}
}
-
- [Fact]
- public async Task IncomingModel_WithoutConfigureJsonFormattingOnEnums_SerializesAsIntegers()
- {
- // Arrange
- var options = new TestApiServerOptions()
- .ConfigureServices(services => services.AddMvc(mvcOptions =>
- {
- mvcOptions.ConfigureJsonFormatting(jsonOptions => { });
- }));
-
- var country = new Country
- {
- Name = BogusGenerator.Address.Country(),
- Code = BogusGenerator.Random.Enum()
- };
-
- string json = JsonSerializer.Serialize(country);
-
- await using (var server = await TestApiServer.StartNewAsync(options, _logger))
- {
- var request = HttpRequestBuilder
- .Get(CountryController.GetJsonRoute)
- .WithJsonBody(json);
-
- // Act
- using (HttpResponseMessage response = await server.SendAsync(request))
- {
- // Assert
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
- string actual = await response.Content.ReadAsStringAsync();
- Assert.Contains($"{(int)country.Code}", actual);
- }
- }
- }
-
- [Fact]
- public async Task IncomingModel_WithConfigureJsonFormattingOnEnums_SerializeAsStrings()
- {
- // Arrange
- var options = new TestApiServerOptions()
- .ConfigureServices(services => services.AddMvc(mvcOptions =>
- {
- mvcOptions.ConfigureJsonFormatting(jsonOptions => jsonOptions.Converters.Add(new JsonStringEnumConverter()));
- }));
-
- var country = new Country
- {
- Name = BogusGenerator.Address.Country(),
- Code = BogusGenerator.Random.Enum()
- };
-
- string json = JsonSerializer.Serialize(country);
-
- await using (var server = await TestApiServer.StartNewAsync(options, _logger))
- {
- var request = HttpRequestBuilder
- .Get(CountryController.GetJsonRoute)
- .WithJsonBody(json);
-
- // Act
- using (HttpResponseMessage response = await server.SendAsync(request))
- {
- // Assert
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
- string actual = await response.Content.ReadAsStringAsync();
- Assert.Contains(country.Code.ToString(), actual);
- }
- }
- }
}
}
diff --git a/src/Arcus.WebApi.Tests.Integration/Logging/AzureFunctionCorrelationDockerTests.cs b/src/Arcus.WebApi.Tests.Integration/Logging/AzureFunctionCorrelationDockerTests.cs
index ea488451..04757869 100644
--- a/src/Arcus.WebApi.Tests.Integration/Logging/AzureFunctionCorrelationDockerTests.cs
+++ b/src/Arcus.WebApi.Tests.Integration/Logging/AzureFunctionCorrelationDockerTests.cs
@@ -36,7 +36,7 @@ public AzureFunctionCorrelationDockerTests(ITestOutputHelper outputWriter)
HttpClient.DefaultRequestHeaders.Remove("traceparent");
}
- [Fact]
+ [Fact(Skip = ".NET 8 not available yet for Azure Functions in-process")]
public async Task SendRequestInProcess_WithoutCorrelationHeaders_ResponseWithCorrelationHeadersAndCorrelationAccess()
{
// Act
@@ -82,7 +82,7 @@ public async Task SendRequestIsolated_WithoutCorrelationHeaders_ResponseWithCorr
}
}
- [Fact]
+ [Fact(Skip = ".NET 8 not available yet for Azure Functions in-process")]
public async Task SendRequestInProcess_WithTransactionIdHeader_ResponseWithSameCorrelationHeader()
{
// Arrange
@@ -136,7 +136,7 @@ public async Task SendRequestIsolated_WithTransactionIdHeader_ResponseWithSameCo
}
}
- [Fact]
+ [Fact(Skip = ".NET 8 not available yet for Azure Functions in-process")]
public async Task SendRequestInProcess_WithRequestIdHeader_ResponseWithSameRequestIdHeader()
{
// Arrange
diff --git a/src/Arcus.WebApi.Tests.Integration/Logging/Fixture/InMemoryApplicationInsightsTelemetryConverter.cs b/src/Arcus.WebApi.Tests.Integration/Logging/Fixture/InMemoryApplicationInsightsTelemetryConverter.cs
index 2739f61c..7bc5d1c5 100644
--- a/src/Arcus.WebApi.Tests.Integration/Logging/Fixture/InMemoryApplicationInsightsTelemetryConverter.cs
+++ b/src/Arcus.WebApi.Tests.Integration/Logging/Fixture/InMemoryApplicationInsightsTelemetryConverter.cs
@@ -6,7 +6,7 @@
using Arcus.Observability.Telemetry.Serilog.Sinks.ApplicationInsights.Converters;
using Microsoft.ApplicationInsights.Channel;
using Serilog.Events;
-using Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters;
+using Serilog.Sinks.ApplicationInsights.TelemetryConverters;
namespace Arcus.WebApi.Tests.Integration.Logging.Fixture
{
diff --git a/src/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated.csproj b/src/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated.csproj
index d8802711..7036fe12 100644
--- a/src/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated.csproj
+++ b/src/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net8.0
v4
Exe
enable
@@ -9,11 +9,10 @@
Linux
-
-
-
-
-
+
+
+
+
diff --git a/src/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Dockerfile b/src/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Dockerfile
index 93c7f922..1e1d21b0 100644
--- a/src/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Dockerfile
+++ b/src/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Dockerfile
@@ -1,10 +1,10 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
-FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated6.0 AS base
+FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0 AS base
WORKDIR /home/site/wwwroot
EXPOSE 80
-FROM mcr.microsoft.com/dotnet/sdk:6.0.400-bullseye-slim AS build
+FROM mcr.microsoft.com/dotnet/sdk:8.0.100-preview.7-alpine3.18 AS build
WORKDIR /src
COPY ["Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated.csproj", "Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/"]
RUN dotnet restore "Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated/Arcus.WebApi.Tests.Runtimes.AzureFunction.Isolated.csproj"
diff --git a/src/Arcus.WebApi.Tests.Runtimes.AzureFunction/Arcus.WebApi.Tests.Runtimes.AzureFunction.csproj b/src/Arcus.WebApi.Tests.Runtimes.AzureFunction/Arcus.WebApi.Tests.Runtimes.AzureFunction.csproj
index 0cb8ae57..ded97bbd 100644
--- a/src/Arcus.WebApi.Tests.Runtimes.AzureFunction/Arcus.WebApi.Tests.Runtimes.AzureFunction.csproj
+++ b/src/Arcus.WebApi.Tests.Runtimes.AzureFunction/Arcus.WebApi.Tests.Runtimes.AzureFunction.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net8.0
v4
diff --git a/src/Arcus.WebApi.Tests.Runtimes.AzureFunction/Dockerfile b/src/Arcus.WebApi.Tests.Runtimes.AzureFunction/Dockerfile
index 519c2995..d5a169fa 100644
--- a/src/Arcus.WebApi.Tests.Runtimes.AzureFunction/Dockerfile
+++ b/src/Arcus.WebApi.Tests.Runtimes.AzureFunction/Dockerfile
@@ -1,10 +1,10 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
-FROM mcr.microsoft.com/azure-functions/dotnet:4.0 AS base
+FROM mcr.microsoft.com/azure-functions/dotnet:4 AS base
WORKDIR /home/site/wwwroot
EXPOSE 80
-FROM mcr.microsoft.com/dotnet/sdk:6.0.402-bullseye-slim AS build
+FROM mcr.microsoft.com/dotnet/sdk:8.0.100-preview.7-alpine3.18 AS build
WORKDIR /src
COPY ["Arcus.WebApi.Tests.Runtimes.AzureFunction/Arcus.WebApi.Tests.Runtimes.AzureFunction.csproj", "Arcus.WebApi.Tests.Runtimes.AzureFunction/"]
RUN dotnet restore "Arcus.WebApi.Tests.Runtimes.AzureFunction/Arcus.WebApi.Tests.Runtimes.AzureFunction.csproj"
diff --git a/src/Arcus.WebApi.Tests.Unit/Arcus.WebApi.Tests.Unit.csproj b/src/Arcus.WebApi.Tests.Unit/Arcus.WebApi.Tests.Unit.csproj
index 79f26ab2..0dc97dab 100644
--- a/src/Arcus.WebApi.Tests.Unit/Arcus.WebApi.Tests.Unit.csproj
+++ b/src/Arcus.WebApi.Tests.Unit/Arcus.WebApi.Tests.Unit.csproj
@@ -1,7 +1,7 @@
- net6.0
+ net8.0
true
false
Arcus.WebApi.Tests.Unit.Open-Api.xml
diff --git a/src/Arcus.WebApi.Tests.Unit/Formatting/MvcOptionsExtensionsTests.cs b/src/Arcus.WebApi.Tests.Unit/Formatting/MvcOptionsExtensionsTests.cs
index 4fa4bfea..af1f90da 100644
--- a/src/Arcus.WebApi.Tests.Unit/Formatting/MvcOptionsExtensionsTests.cs
+++ b/src/Arcus.WebApi.Tests.Unit/Formatting/MvcOptionsExtensionsTests.cs
@@ -1,5 +1,4 @@
using System.Collections.Generic;
-using System.Text.Json;
using Bogus;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Formatters;
@@ -37,35 +36,6 @@ public void OnlyAllowJsonFormatting_WithDefault_ConfiguresFormatters()
Assert.Empty(options.OutputFormatters);
}
- [Fact]
- public void ConfigureJsonFormatting_WithOptions_ConfiguresFormatters()
- {
- // Arrange
- var options = new MvcOptions();
- IEnumerable inputFormatters =
- CreateRandomSubset(new SystemTextJsonInputFormatter(new JsonOptions(), NullLogger.Instance));
- Assert.All(inputFormatters, formatter => options.InputFormatters.Add(formatter));
- IEnumerable outputFormatters =
- CreateRandomSubset(new SystemTextJsonOutputFormatter(new JsonSerializerOptions()));
- Assert.All(outputFormatters, formatter => options.OutputFormatters.Add(formatter));
- bool allowTrailingCommas = BogusGenerator.Random.Bool();
-
- // Act
- options.ConfigureJsonFormatting(opt => opt.AllowTrailingCommas = allowTrailingCommas);
-
- // Assert
- Assert.All(options.InputFormatters, formatter =>
- {
- var jsonFormatter = Assert.IsType(formatter);
- Assert.Equal(allowTrailingCommas, jsonFormatter.SerializerOptions.AllowTrailingCommas);
- });
- Assert.All(options.OutputFormatters, formatter =>
- {
- var jsonFormatter = Assert.IsType(formatter);
- Assert.Equal(allowTrailingCommas, jsonFormatter.SerializerOptions.AllowTrailingCommas);
- });
- }
-
private static IEnumerable CreateRandomSubset(params T[] formatters)
{
int count = BogusGenerator.Random.Int(5, 10);
diff --git a/src/Arcus.WebApi.Tests.Unit/Logging/AzureFunctionsRequestTrackingTests.cs b/src/Arcus.WebApi.Tests.Unit/Logging/AzureFunctionsRequestTrackingTests.cs
index b729849f..c46002df 100644
--- a/src/Arcus.WebApi.Tests.Unit/Logging/AzureFunctionsRequestTrackingTests.cs
+++ b/src/Arcus.WebApi.Tests.Unit/Logging/AzureFunctionsRequestTrackingTests.cs
@@ -145,8 +145,7 @@ public async Task SendRequest_WithOmittedStatusCode_IgnoresRequest()
await middleware.Invoke(context, async ctx => await CreateHttpResponse(ctx, notTrackedStatusCode));
// Assert
- string message = Assert.Single(spyLogger.Messages);
- Assert.Contains("Request tracking for this endpoint is disallowed as the response status code", message);
+ Assert.Contains(spyLogger.Messages, msg => msg.Contains("Request tracking for this endpoint is disallowed as the response status code"));
}
[Fact]
@@ -164,8 +163,7 @@ public async Task SendRequest_WithOmittedStatusCodeRange_IgnoresRequest()
await middleware.Invoke(context, async ctx => await CreateHttpResponse(ctx, status));
// Assert
- string message = Assert.Single(spyLogger.Messages);
- Assert.Contains("Request tracking for this endpoint is disallowed as the response status code", message);
+ Assert.Contains(spyLogger.Messages, msg => msg.Contains("Request tracking for this endpoint is disallowed as the response status code"));
}
[Fact]
diff --git a/src/Arcus.WebApi.Tests.Unit/Security/Authentication/AuthenticationBuilderExtensionsTests.cs b/src/Arcus.WebApi.Tests.Unit/Security/Authentication/AuthenticationBuilderExtensionsTests.cs
index 4b0ca855..f5078b26 100644
--- a/src/Arcus.WebApi.Tests.Unit/Security/Authentication/AuthenticationBuilderExtensionsTests.cs
+++ b/src/Arcus.WebApi.Tests.Unit/Security/Authentication/AuthenticationBuilderExtensionsTests.cs
@@ -22,6 +22,7 @@ public void AddJwtBearer_WithServiceProvider_Succeeds()
services.AddSingleton(Mock.Of());
services.AddSingleton(UrlEncoder.Default);
services.AddSecretStore(stores => stores.AddInMemory());
+ services.AddSingleton(Mock.Of());
var builder = new AuthenticationBuilder(services);
// Act
@@ -47,6 +48,7 @@ public void AddJwtBearer_WithoutOptions_Succeeds()
services.AddLogging();
services.AddSingleton(Mock.Of());
services.AddSingleton(UrlEncoder.Default);
+ services.AddSingleton(Mock.Of());
var builder = new AuthenticationBuilder(services);
// Act