.NET 8 Support (#1188)

* Update test projects to use .NET 8.

Signed-off-by: Phillip Hoff <phillip@orst.edu>

* Update SDK projects to target .NET 8.

Signed-off-by: Phillip Hoff <phillip@orst.edu>

* Update workflows to target .NET 8.

Signed-off-by: Phillip Hoff <phillip@orst.edu>

---------

Signed-off-by: Phillip Hoff <phillip@orst.edu>
Co-authored-by: halspang <70976921+halspang@users.noreply.github.com>
This commit is contained in:
Phillip Hoff 2023-11-15 10:48:02 -08:00 committed by GitHub
parent 39a38f6e9b
commit 09008bb43b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 52 additions and 81 deletions

View File

@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
dotnet-version: ['6.0', '7.0'] dotnet-version: ['6.0', '7.0', '8.0']
include: include:
- dotnet-version: '6.0' - dotnet-version: '6.0'
display-name: '.NET 6.0' display-name: '.NET 6.0'
@ -31,6 +31,11 @@ jobs:
framework: 'net7' framework: 'net7'
prefix: 'net7' prefix: 'net7'
install-version: '7.0.x' install-version: '7.0.x'
- dotnet-version: '8.0'
display-name: '.NET 8.0'
framework: 'net8'
prefix: 'net8'
install-version: '8.0.x'
env: env:
NUPKG_OUTDIR: bin/Release/nugets NUPKG_OUTDIR: bin/Release/nugets
GOVER: 1.20.3 GOVER: 1.20.3
@ -101,11 +106,11 @@ jobs:
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
with: with:
dotnet-version: ${{ matrix.install-version }} dotnet-version: ${{ matrix.install-version }}
- name: Setup .NET 7.0 # net7 is always required. - name: Setup .NET 8.0 # net8 is always required.
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
if: ${{ matrix.install-version != '7.0.x' }} if: ${{ matrix.install-version != '8.0.x' }}
with: with:
dotnet-version: 7.0.x dotnet-version: 8.0.x
- name: Build - name: Build
# disable deterministic builds, just for test run. Deterministic builds break coverage for some reason # disable deterministic builds, just for test run. Deterministic builds break coverage for some reason
run: dotnet build --configuration release /p:GITHUB_ACTIONS=false run: dotnet build --configuration release /p:GITHUB_ACTIONS=false

View File

@ -26,7 +26,7 @@ jobs:
- name: Setup .NET Core - name: Setup .NET Core
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
with: with:
dotnet-version: 7.0.x dotnet-version: 8.0.x
- name: Build - name: Build
run: dotnet build --configuration release run: dotnet build --configuration release
- name: Generate Packages - name: Generate Packages
@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
dotnet-version: ['6.0', '7.0'] dotnet-version: ['6.0', '7.0', '8.0']
include: include:
- dotnet-version: '6.0' - dotnet-version: '6.0'
install-3: false install-3: false
@ -56,6 +56,12 @@ jobs:
framework: 'net7' framework: 'net7'
prefix: 'net7' prefix: 'net7'
install-version: '7.0.x' install-version: '7.0.x'
- dotnet-version: '8.0'
install-3: false
display-name: '.NET 8.0'
framework: 'net8'
prefix: 'net8'
install-version: '8.0.x'
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Parse release version - name: Parse release version
@ -64,11 +70,11 @@ jobs:
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
with: with:
dotnet-version: ${{ matrix.install-version }} dotnet-version: ${{ matrix.install-version }}
- name: Setup .NET 7.0 # net7 is always required. - name: Setup .NET 8.0 # net8 is always required.
uses: actions/setup-dotnet@v1 uses: actions/setup-dotnet@v1
if: ${{ matrix.install-version != '7.0.x' }} if: ${{ matrix.install-version != '8.0.x' }}
with: with:
dotnet-version: 7.0.x dotnet-version: 8.0.x
- name: Build - name: Build
# disable deterministic builds, just for test run. Deterministic builds break coverage for some reason # disable deterministic builds, just for test run. Deterministic builds break coverage for some reason
run: dotnet build --configuration release /p:GITHUB_ACTIONS=false run: dotnet build --configuration release /p:GITHUB_ACTIONS=false

View File

@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Builder
if (header != string.Empty) if (header != string.Empty)
{ {
// exception case // exception case
context.Response.Headers.Add(Constants.ErrorResponseHeaderName, header); // add error header context.Response.Headers[Constants.ErrorResponseHeaderName] = header; // add error header
} }
await context.Response.Body.WriteAsync(body, 0, body.Length); // add response message body await context.Response.Body.WriteAsync(body, 0, body.Length); // add response message body
@ -118,7 +118,7 @@ namespace Microsoft.AspNetCore.Builder
{ {
var (header, body) = CreateExceptionResponseMessage(ex); var (header, body) = CreateExceptionResponseMessage(ex);
context.Response.Headers.Add(Constants.ErrorResponseHeaderName, header); context.Response.Headers[Constants.ErrorResponseHeaderName] = header;
await context.Response.Body.WriteAsync(body, 0, body.Length); await context.Response.Body.WriteAsync(body, 0, body.Length);
} }
finally finally

View File

@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" /> <FrameworkReference Include="Microsoft.AspNetCore.App" />
<!-- <!--

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>
<!-- Additional Nuget package properties. --> <!-- Additional Nuget package properties. -->
<PropertyGroup> <PropertyGroup>
<Description>This package contains the reference assemblies for developing Actor services using Dapr.</Description> <Description>This package contains the reference assemblies for developing Actor services using Dapr.</Description>

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>
<!-- Additional Nuget package properties. --> <!-- Additional Nuget package properties. -->
<PropertyGroup> <PropertyGroup>
<Description>This package contains the reference assemblies for developing services using Dapr and AspNetCore.</Description> <Description>This package contains the reference assemblies for developing services using Dapr and AspNetCore.</Description>

View File

@ -25,6 +25,14 @@ namespace Dapr.AspNetCore
{ {
const string DaprApiToken = "Dapr-Api-Token"; const string DaprApiToken = "Dapr-Api-Token";
#if NET8_0_OR_GREATER
public DaprAuthenticationHandler(
IOptionsMonitor<DaprAuthenticationOptions> options,
ILoggerFactory logger,
UrlEncoder encoder) : base(options, logger, encoder)
{
}
#else
public DaprAuthenticationHandler( public DaprAuthenticationHandler(
IOptionsMonitor<DaprAuthenticationOptions> options, IOptionsMonitor<DaprAuthenticationOptions> options,
ILoggerFactory logger, ILoggerFactory logger,
@ -32,6 +40,7 @@ namespace Dapr.AspNetCore
ISystemClock clock) : base(options, logger, encoder, clock) ISystemClock clock) : base(options, logger, encoder, clock)
{ {
} }
#endif
protected override Task<AuthenticateResult> HandleAuthenticateAsync() protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{ {

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\Shared\ArgumentVerifier.cs" /> <Compile Include="..\Shared\ArgumentVerifier.cs" />
<Compile Include="..\Shared\DaprDefaults.cs" /> <Compile Include="..\Shared\DaprDefaults.cs" />

View File

@ -92,6 +92,9 @@ namespace Dapr
/// </summary> /// </summary>
/// <param name="info">The <see cref="System.Runtime.Serialization.SerializationInfo" /> object that contains serialized object data of the exception being thrown.</param> /// <param name="info">The <see cref="System.Runtime.Serialization.SerializationInfo" /> object that contains serialized object data of the exception being thrown.</param>
/// <param name="context">The <see cref="System.Runtime.Serialization.StreamingContext" /> object that contains contextual information about the source or destination. The context parameter is reserved for future use and can be null.</param> /// <param name="context">The <see cref="System.Runtime.Serialization.StreamingContext" /> object that contains contextual information about the source or destination. The context parameter is reserved for future use and can be null.</param>
#if NET8_0_OR_GREATER
[Obsolete(DiagnosticId = "SYSLIB0051")] // add this attribute to the serialization ctor
#endif
protected DaprApiException(SerializationInfo info, StreamingContext context) protected DaprApiException(SerializationInfo info, StreamingContext context)
: base(info, context) : base(info, context)
{ {
@ -115,6 +118,9 @@ namespace Dapr
public bool IsTransient { get; } = false; public bool IsTransient { get; } = false;
/// <inheritdoc /> /// <inheritdoc />
#if NET8_0_OR_GREATER
[Obsolete(DiagnosticId = "SYSLIB0051")] // add this attribute to GetObjectData
#endif
public override void GetObjectData(SerializationInfo info, StreamingContext context) public override void GetObjectData(SerializationInfo info, StreamingContext context)
{ {
base.GetObjectData(info, context); base.GetObjectData(info, context);

View File

@ -47,6 +47,9 @@ namespace Dapr
/// </summary> /// </summary>
/// <param name="info">The <see cref="SerializationInfo" /> object that contains serialized object data of the exception being thrown.</param> /// <param name="info">The <see cref="SerializationInfo" /> object that contains serialized object data of the exception being thrown.</param>
/// <param name="context">The <see cref="StreamingContext" /> object that contains contextual information about the source or destination. The context parameter is reserved for future use and can be null.</param> /// <param name="context">The <see cref="StreamingContext" /> object that contains contextual information about the source or destination. The context parameter is reserved for future use and can be null.</param>
#if NET8_0_OR_GREATER
[Obsolete(DiagnosticId = "SYSLIB0051")] // add this attribute to GetObjectData
#endif
protected DaprException(SerializationInfo info, StreamingContext context) protected DaprException(SerializationInfo info, StreamingContext context)
: base(info, context) : base(info, context)
{ {

View File

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@ -2,7 +2,8 @@
<!-- NuGet configuration --> <!-- NuGet configuration -->
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks> <!-- NOTE: Workflows targeted .NET 7 (whereas other packages did not, so we must continue until .NET 7 EOL). -->
<TargetFrameworks>net6;net7;net8</TargetFrameworks>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<PackageId>Dapr.Workflow</PackageId> <PackageId>Dapr.Workflow</PackageId>
<Title>Dapr Workflow Authoring SDK</Title> <Title>Dapr Workflow Authoring SDK</Title>

View File

@ -3,6 +3,7 @@
<Import Project="$(MSBuildThisFileDirectory)..\properties\dapr_nuget.props" /> <Import Project="$(MSBuildThisFileDirectory)..\properties\dapr_nuget.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6;net8</TargetFrameworks>
<OutputPath>$(RepoRoot)bin\$(Configuration)\prod\$(MSBuildProjectName)\</OutputPath> <OutputPath>$(RepoRoot)bin\$(Configuration)\prod\$(MSBuildProjectName)\</OutputPath>
<DocumentationFile>$(OutputPath)$(MSBuildProjectName).xml</DocumentationFile> <DocumentationFile>$(OutputPath)$(MSBuildProjectName).xml</DocumentationFile>

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Dapr.Actors.AspNetCore\Dapr.Actors.AspNetCore.csproj" /> <ProjectReference Include="..\..\src\Dapr.Actors.AspNetCore\Dapr.Actors.AspNetCore.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -1,8 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0"> <PackageReference Include="coverlet.msbuild" Version="2.9.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
<BaseNamespace>Dapr.Actors.AspNetCore</BaseNamespace> <BaseNamespace>Dapr.Actors.AspNetCore</BaseNamespace>
</PropertyGroup> </PropertyGroup>

View File

@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
<RootNamespace>Dapr.Actors</RootNamespace> <RootNamespace>Dapr.Actors</RootNamespace>
<DefineConstants>$(DefineConstants);ACTORS</DefineConstants> <DefineConstants>$(DefineConstants);ACTORS</DefineConstants>
</PropertyGroup> </PropertyGroup>

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" /> <ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0"> <PackageReference Include="coverlet.msbuild" Version="2.9.0">

View File

@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0"> <PackageReference Include="coverlet.msbuild" Version="2.9.0">

View File

@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0"> <PackageReference Include="coverlet.msbuild" Version="2.9.0">

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Dapr.Actors\Dapr.Actors.csproj" /> <ProjectReference Include="..\..\src\Dapr.Actors\Dapr.Actors.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.39.0" /> <PackageReference Include="Grpc.AspNetCore" Version="2.39.0" />
</ItemGroup> </ItemGroup>

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Dapr.E2E.Test.App.ReentrantActor' " /> <PropertyGroup Condition=" '$(RunConfiguration)' == 'Dapr.E2E.Test.App.ReentrantActor' " />
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" /> <ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" />

View File

@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" /> <ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\Dapr.Actors.AspNetCore\Dapr.Actors.AspNetCore.csproj" /> <ProjectReference Include="..\..\src\Dapr.Actors.AspNetCore\Dapr.Actors.AspNetCore.csproj" />

View File

@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.9.0" /> <PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="Google.Protobuf" Version="3.21.12" /> <PackageReference Include="Google.Protobuf" Version="3.21.12" />

View File

@ -132,16 +132,14 @@ namespace Dapr.E2E.Test
private static string GetTargetFrameworkName() private static string GetTargetFrameworkName()
{ {
var targetFrameworkName = ((TargetFrameworkAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(TargetFrameworkAttribute), false).FirstOrDefault()).FrameworkName; var targetFrameworkName = ((TargetFrameworkAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(TargetFrameworkAttribute), false).FirstOrDefault()).FrameworkName;
string frameworkMoniker;
if (targetFrameworkName == ".NETCoreApp,Version=v6.0") return targetFrameworkName switch
{ {
frameworkMoniker = "net6"; ".NETCoreApp,Version=v6.0" => "net6",
} ".NETCoreApp,Version=v7.0" => "net7",
else ".NETCoreApp,Version=v8.0" => "net8",
{ _ => throw new InvalidOperationException($"Unsupported target framework: {targetFrameworkName}")
frameworkMoniker = "net7"; };
}
return frameworkMoniker;
} }
private static (int, int, int, int) GetFreePorts() private static (int, int, int, int) GetFreePorts()

View File

@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0"> <PackageReference Include="coverlet.msbuild" Version="2.9.0">

View File

@ -2,6 +2,8 @@
<Import Project="$(MSBuildThisFileDirectory)..\properties\dapr_managed_netcore.props" /> <Import Project="$(MSBuildThisFileDirectory)..\properties\dapr_managed_netcore.props" />
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6;net7;net8</TargetFrameworks>
<!-- Set Output Path for tests--> <!-- Set Output Path for tests-->
<OutputPath>$(RepoRoot)bin\$(Configuration)\test\$(MSBuildProjectName)\</OutputPath> <OutputPath>$(RepoRoot)bin\$(Configuration)\test\$(MSBuildProjectName)\</OutputPath>