Skip to content

Commit

Permalink
.NET 8 Support (#1188)
Browse files Browse the repository at this point in the history
* Update test projects to use .NET 8.

Signed-off-by: Phillip Hoff <[email protected]>

* Update SDK projects to target .NET 8.

Signed-off-by: Phillip Hoff <[email protected]>

* Update workflows to target .NET 8.

Signed-off-by: Phillip Hoff <[email protected]>

---------

Signed-off-by: Phillip Hoff <[email protected]>
Co-authored-by: halspang <[email protected]>
  • Loading branch information
philliphoff and halspang authored Nov 15, 2023
1 parent 39a38f6 commit 09008bb
Show file tree
Hide file tree
Showing 29 changed files with 52 additions and 81 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/itests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['6.0', '7.0']
dotnet-version: ['6.0', '7.0', '8.0']
include:
- dotnet-version: '6.0'
display-name: '.NET 6.0'
Expand All @@ -31,6 +31,11 @@ jobs:
framework: 'net7'
prefix: 'net7'
install-version: '7.0.x'
- dotnet-version: '8.0'
display-name: '.NET 8.0'
framework: 'net8'
prefix: 'net8'
install-version: '8.0.x'
env:
NUPKG_OUTDIR: bin/Release/nugets
GOVER: 1.20.3
Expand Down Expand Up @@ -101,11 +106,11 @@ jobs:
uses: actions/setup-dotnet@v1
with:
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
if: ${{ matrix.install-version != '7.0.x' }}
if: ${{ matrix.install-version != '8.0.x' }}
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
# disable deterministic builds, just for test run. Deterministic builds break coverage for some reason
run: dotnet build --configuration release /p:GITHUB_ACTIONS=false
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/sdk_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
run: dotnet build --configuration release
- name: Generate Packages
Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ['6.0', '7.0']
dotnet-version: ['6.0', '7.0', '8.0']
include:
- dotnet-version: '6.0'
install-3: false
Expand All @@ -56,6 +56,12 @@ jobs:
framework: 'net7'
prefix: 'net7'
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:
- uses: actions/checkout@v1
- name: Parse release version
Expand All @@ -64,11 +70,11 @@ jobs:
uses: actions/setup-dotnet@v1
with:
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
if: ${{ matrix.install-version != '7.0.x' }}
if: ${{ matrix.install-version != '8.0.x' }}
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Build
# disable deterministic builds, just for test run. Deterministic builds break coverage for some reason
run: dotnet build --configuration release /p:GITHUB_ACTIONS=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private static IEndpointConventionBuilder MapActorMethodEndpoint(this IEndpointR
if (header != string.Empty)
{
// 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
Expand All @@ -118,7 +118,7 @@ private static IEndpointConventionBuilder MapActorMethodEndpoint(this IEndpointR
{
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);
}
finally
Expand Down
3 changes: 0 additions & 3 deletions src/Dapr.Actors.AspNetCore/Dapr.Actors.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<!--
Expand Down
4 changes: 0 additions & 4 deletions src/Dapr.Actors/Dapr.Actors.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>

<!-- Additional Nuget package properties. -->
<PropertyGroup>
<Description>This package contains the reference assemblies for developing Actor services using Dapr.</Description>
Expand Down
4 changes: 0 additions & 4 deletions src/Dapr.AspNetCore/Dapr.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>

<!-- Additional Nuget package properties. -->
<PropertyGroup>
<Description>This package contains the reference assemblies for developing services using Dapr and AspNetCore.</Description>
Expand Down
9 changes: 9 additions & 0 deletions src/Dapr.AspNetCore/DaprAuthenticationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@ internal class DaprAuthenticationHandler : AuthenticationHandler<DaprAuthenticat
{
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(
IOptionsMonitor<DaprAuthenticationOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock) : base(options, logger, encoder, clock)
{
}
#endif

protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
Expand Down
4 changes: 0 additions & 4 deletions src/Dapr.Client/Dapr.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Shared\ArgumentVerifier.cs" />
<Compile Include="..\Shared\DaprDefaults.cs" />
Expand Down
6 changes: 6 additions & 0 deletions src/Dapr.Client/DaprApiException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public DaprApiException(string message, Exception inner, string errorCode, bool
/// </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="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)
: base(info, context)
{
Expand All @@ -115,6 +118,9 @@ protected DaprApiException(SerializationInfo info, StreamingContext context)
public bool IsTransient { get; } = false;

/// <inheritdoc />
#if NET8_0_OR_GREATER
[Obsolete(DiagnosticId = "SYSLIB0051")] // add this attribute to GetObjectData
#endif
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
Expand Down
3 changes: 3 additions & 0 deletions src/Dapr.Client/DaprException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public DaprException(string message, Exception innerException)
/// </summary>
/// <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>
#if NET8_0_OR_GREATER
[Obsolete(DiagnosticId = "SYSLIB0051")] // add this attribute to GetObjectData
#endif
protected DaprException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
3 changes: 2 additions & 1 deletion src/Dapr.Workflow/Dapr.Workflow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<!-- NuGet configuration -->
<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>
<PackageId>Dapr.Workflow</PackageId>
<Title>Dapr Workflow Authoring SDK</Title>
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<Import Project="$(MSBuildThisFileDirectory)..\properties\dapr_nuget.props" />

<PropertyGroup>
<TargetFrameworks>net6;net8</TargetFrameworks>
<OutputPath>$(RepoRoot)bin\$(Configuration)\prod\$(MSBuildProjectName)\</OutputPath>

<DocumentationFile>$(OutputPath)$(MSBuildProjectName).xml</DocumentationFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Dapr.Actors.AspNetCore\Dapr.Actors.AspNetCore.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
<BaseNamespace>Dapr.Actors.AspNetCore</BaseNamespace>
</PropertyGroup>

Expand Down
1 change: 0 additions & 1 deletion test/Dapr.Actors.Test/Dapr.Actors.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
<RootNamespace>Dapr.Actors</RootNamespace>
<DefineConstants>$(DefineConstants);ACTORS</DefineConstants>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
Expand Down
3 changes: 0 additions & 3 deletions test/Dapr.AspNetCore.Test/Dapr.AspNetCore.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
Expand Down
3 changes: 0 additions & 3 deletions test/Dapr.Client.Test/Dapr.Client.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
Expand Down
4 changes: 0 additions & 4 deletions test/Dapr.E2E.Test.Actors/Dapr.E2E.Test.Actors.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Dapr.Actors\Dapr.Actors.csproj" />
</ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions test/Dapr.E2E.Test.App.Grpc/Dapr.E2E.Test.App.Grpc.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.39.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition=" '$(RunConfiguration)' == 'Dapr.E2E.Test.App.ReentrantActor' " />
<ItemGroup>
<ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" />
Expand Down
4 changes: 0 additions & 4 deletions test/Dapr.E2E.Test.App/Dapr.E2E.Test.App.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\Dapr.Actors.AspNetCore\Dapr.Actors.AspNetCore.csproj" />
Expand Down
3 changes: 0 additions & 3 deletions test/Dapr.E2E.Test/Dapr.E2E.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="Google.Protobuf" Version="3.21.12" />
Expand Down
16 changes: 7 additions & 9 deletions test/Dapr.E2E.Test/DaprTestApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,14 @@ public void Stop()
private static string GetTargetFrameworkName()
{
var targetFrameworkName = ((TargetFrameworkAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(TargetFrameworkAttribute), false).FirstOrDefault()).FrameworkName;
string frameworkMoniker;
if (targetFrameworkName == ".NETCoreApp,Version=v6.0")
{
frameworkMoniker = "net6";
}
else

return targetFrameworkName switch
{
frameworkMoniker = "net7";
}
return frameworkMoniker;
".NETCoreApp,Version=v6.0" => "net6",
".NETCoreApp,Version=v7.0" => "net7",
".NETCoreApp,Version=v8.0" => "net8",
_ => throw new InvalidOperationException($"Unsupported target framework: {targetFrameworkName}")
};
}

private static (int, int, int, int) GetFreePorts()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6;net7</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
Expand Down
2 changes: 2 additions & 0 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<Import Project="$(MSBuildThisFileDirectory)..\properties\dapr_managed_netcore.props" />

<PropertyGroup>
<TargetFrameworks>net6;net7;net8</TargetFrameworks>

<!-- Set Output Path for tests-->
<OutputPath>$(RepoRoot)bin\$(Configuration)\test\$(MSBuildProjectName)\</OutputPath>

Expand Down

0 comments on commit 09008bb

Please sign in to comment.