Skip to content

Commit

Permalink
chore: support net8.0 preview (arcus-azure#455)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
stijnmoreels authored Dec 15, 2023
1 parent c78b6b8 commit b6ec764
Show file tree
Hide file tree
Showing 29 changed files with 113 additions and 233 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions build/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'

Expand Down
3 changes: 3 additions & 0 deletions build/nuget-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'

Expand Down
32 changes: 18 additions & 14 deletions build/templates/run-docker-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
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'
port: '$(Arcus.AzureFunctions.Isolated.HttpPort)'
- 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'
Expand Down
4 changes: 2 additions & 2 deletions build/variables/build.yml
Original file line number Diff line number Diff line change
@@ -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'
22 changes: 0 additions & 22 deletions docs/preview/03-Features/hosting/formatting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
});
```

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<RepositoryType>Git</RepositoryType>
Expand All @@ -26,14 +26,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker.Core" Version="1.6.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
<PackageReference Include="Guard.Net" Version="3.0.0" />
</ItemGroup>

</Project>
10 changes: 3 additions & 7 deletions src/Arcus.WebApi.Hosting/Arcus.WebApi.Hosting.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<RepositoryType>Git</RepositoryType>
Expand All @@ -28,12 +28,8 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramwork)' == 'net6.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramwork)' != 'net6.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
<ItemGroup>
<PackageReference Include="Guard.Net" Version="3.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -35,18 +36,19 @@ public static MvcOptions OnlyAllowJsonFormatting(this MvcOptions options)

return options;
}

/// <summary>
/// Configure the MVC JSON formatters for both receiving and sending.
/// </summary>
/// <param name="options">The MVC options where the JSON formatters will be configured.</param>
/// <param name="configureOptions">The function to configure the input and output JSON formatters in the MVC <paramref name="options"/>.</param>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="options"/> or <paramref name="configureOptions"/> is <c>null</c>.</exception>
[Obsolete("Use the " + nameof(MvcCoreMvcBuilderExtensions) + "." + nameof(MvcCoreMvcBuilderExtensions.AddJsonOptions) + " instead to configure the JSON formatters")]
public static MvcOptions ConfigureJsonFormatting(this MvcOptions options, Action<JsonSerializerOptions> 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<SystemTextJsonInputFormatter>()
.ToArray();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netcoreapp3.1;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<RepositoryType>Git</RepositoryType>
Expand All @@ -18,15 +18,20 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<!-- Allows (for now) preview packages, as we are referencing Arcus' preview .NET 8 package. -->
<NoWarn>NU5104</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<None Include="..\..\LICENSE" Pack="true" PackagePath="\" />
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\"/>
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[2.6.0,3.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.AzureFunctions" Version="[2.6.0,3.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[3.0.0-preview-1-net8.0,4.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.AzureFunctions" Version="[3.0.0-preview-1-net8.0,4.0.0)" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Core" Version="1.6.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.33" />
Expand Down
22 changes: 10 additions & 12 deletions src/Arcus.WebApi.Logging.Core/Arcus.WebApi.Logging.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<RepositoryType>Git</RepositoryType>
Expand All @@ -18,6 +18,11 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<!-- Allows (for now) preview packages, as we are referencing Arcus' preview .NET 8 package. -->
<NoWarn>NU5104</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<None Include="..\..\LICENSE" Pack="true" PackagePath="\" />
Expand All @@ -34,18 +39,11 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[2.6.0,3.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.Serilog.Enrichers" Version="[2.6.0,3.0.0)" />
<PackageReference Include="Arcus.Observability.Correlation" Version="[2.6.0,3.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[3.0.0-preview-1-net8.0,4.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.Serilog.Enrichers" Version="[3.0.0-preview-1-net8.0,4.0.0)" />
<PackageReference Include="Arcus.Observability.Correlation" Version="[3.0.0-preview-1-net8.0,4.0.0)" />
<PackageReference Include="Guard.Net" Version="3.0.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
</ItemGroup>

Expand Down
24 changes: 11 additions & 13 deletions src/Arcus.WebApi.Logging/Arcus.WebApi.Logging.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<RepositoryType>Git</RepositoryType>
Expand All @@ -18,6 +18,11 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<!-- Allows (for now) preview packages, as we are referencing Arcus' preview .NET 8 package. -->
<NoWarn>NU5104</NoWarn>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
<None Include="..\..\LICENSE" Pack="true" PackagePath="\" />
Expand All @@ -36,19 +41,12 @@
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[2.6.0,3.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.AspNetCore" Version="[2.6.0,3.0.0)" />
<PackageReference Include="Arcus.Observability.Correlation" Version="[2.6.0,3.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.Serilog.Enrichers" Version="[2.6.0,3.0.0)" />
<PackageReference Include="Guard.Net" Version="3.0.0" />
<PackageReference Include="Arcus.Observability.Telemetry.Core" Version="[3.0.0-preview-1-net8.0,4.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.AspNetCore" Version="[3.0.0-preview-1-net8.0,4.0.0)" />
<PackageReference Include="Arcus.Observability.Correlation" Version="[3.0.0-preview-1-net8.0,4.0.0)" />
<PackageReference Include="Arcus.Observability.Telemetry.Serilog.Enrichers" Version="[3.0.0-preview-1-net8.0,4.0.0)" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Arcus.WebApi.Logging/ExceptionHandlingMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;netstandard2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.1</TargetFrameworks>
<Authors>Arcus</Authors>
<Company>Arcus</Company>
<RepositoryType>Git</RepositoryType>
Expand All @@ -26,15 +26,13 @@
<None Include="..\..\docs\static\img\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Guard.Net" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" Condition="'$(TargetFramework)' != 'netstandard2.1'" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" Condition="'$(TargetFramework)' == 'netstandard2.1'" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0'">
<PackageReference Include="Guard.Net" Version="1.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" Condition="'$(TargetFramework)' == 'netstandard2.1'" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" Condition="'$(TargetFramework)' != 'netstandard2.1'" />
<ItemGroup>
<PackageReference Include="Guard.Net" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit b6ec764

Please sign in to comment.