Skip to content

Commit

Permalink
Support .NET 9 (#1404)
Browse files Browse the repository at this point in the history
* Updated build and integration test scripts to include .NET 9

Signed-off-by: Whit Waldo <[email protected]>

* Removed unused matrix values

Signed-off-by: Whit Waldo <[email protected]>

* Reverted some .NET 8 requirement

Signed-off-by: Whit Waldo <[email protected]>

* Updated setup-dotnet to use latest action version + updated script to prefer a GA release, but use RC if available.

Signed-off-by: Whit Waldo <[email protected]>

* Removed unnecessary secondary build step

Signed-off-by: Whit Waldo <[email protected]>

* Updating TFM moniker

Signed-off-by: Whit Waldo <[email protected]>

* Added test to install VStest

Signed-off-by: Whit Waldo <[email protected]>

* Rolling back use of tool as it doesn't independently exist outside of the SDK

Signed-off-by: Whit Waldo <[email protected]>

* Added .NET 9 to build targets

Signed-off-by: Whit Waldo <[email protected]>

* Added .NET 9 to target frameworks across solution

Signed-off-by: Whit Waldo <[email protected]>

* I understand the reason for the required install step now - adding it back with a .NET 9 install step

Signed-off-by: Whit Waldo <[email protected]>

* Placing install steps before build

Signed-off-by: Whit Waldo <[email protected]>

* Updating global.json

Signed-off-by: Whit Waldo <[email protected]>

* Disabled analyzer errors in unit tests

Signed-off-by: Whit Waldo <[email protected]>

* Added .NET 9 to test

Signed-off-by: Whit Waldo <[email protected]>

* Changed from #pragma error to #pragma warning

Signed-off-by: Whit Waldo <[email protected]>

* Fixed unit tests to resolve analyzer warning

Signed-off-by: Whit Waldo <[email protected]>

* Updated integration test to always include .NET 8 and .NET 9 installs

Signed-off-by: Whit Waldo <[email protected]>

* Falling back to add separate .NET 9 support
Signed-off-by: Whit Waldo <[email protected]>

* Updated referenced projects to target appropriate frameworks

Signed-off-by: Whit Waldo <[email protected]>

* Added all target frameworks back to Dapr.Commono

Signed-off-by: Whit Waldo <[email protected]>

* Added warnings to fix nullability analyzer warnings when targeting .NET 6

Signed-off-by: Whit Waldo <[email protected]>

* Updated build step to use .NET 9 instead

Signed-off-by: Whit Waldo <[email protected]>

* Fixed cloud event middleware tests - the ApplicationBuilder requires a non-null ServiceProvider per https://learn.microsoft.com/en-us/dotnet/core/compatibility/extensions/8.0/activatorutilities-createinstance-null-provider

Signed-off-by: Whit Waldo <[email protected]>

* Including target for .NET 6, 7, 8 and 9

Signed-off-by: Whit Waldo <[email protected]>

* Trialing fix to E2E integration test - excluding use of AppWebApplicationFactory in favor of direct use of HttpClient

Signed-off-by: Whit Waldo <[email protected]>

* Reverting as it breaks the other .NET versions

Signed-off-by: Whit Waldo <[email protected]>

* Potentially fixed unit tests in .NET 9

Signed-off-by: Whit Waldo <[email protected]>

* Removed extra line from build definition

Signed-off-by: Whit Waldo <[email protected]>

* Updated documentation to reflect .NET 9 and a note highlighting that .NET 6 and .NET 7 will be deprecated in v1.16

Signed-off-by: Whit Waldo <[email protected]>

* Removed unintentionally added file to commit

Signed-off-by: Whit Waldo <[email protected]>

* Added .NET 9 to E2E test setup

Signed-off-by: Whit Waldo <[email protected]>

* Fixed typo

Signed-off-by: Whit Waldo <[email protected]>

* Removed RC version from .NET 9 build

Signed-off-by: Whit Waldo <[email protected]>

* Apparently the solution file got a minor change

Signed-off-by: Whit Waldo <[email protected]>

* Removed unnecessary null checks

Signed-off-by: Whit Waldo <[email protected]>

* Whoops - didn't mean to commit that project to the solution

Signed-off-by: Whit Waldo <[email protected]>

---------

Signed-off-by: Whit Waldo <[email protected]>
  • Loading branch information
WhitWaldo authored Dec 4, 2024
1 parent 2e0fa80 commit da01dcd
Show file tree
Hide file tree
Showing 21 changed files with 255 additions and 97 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/itests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
dotnet-version: ['6.0', '7.0', '8.0']
dotnet-version: ['6.0', '7.0', '8.0', '9.0']
include:
- dotnet-version: '6.0'
display-name: '.NET 6.0'
Expand All @@ -37,6 +37,11 @@ jobs:
framework: 'net8'
prefix: 'net8'
install-version: '8.0.x'
- dotnet-version: '9.0'
display-name: '.NET 9.0'
framework: 'net9'
prefix: 'net9'
install-version: '9.0.x'
env:
NUPKG_OUTDIR: bin/Release/nugets
GOVER: 1.20.3
Expand Down Expand Up @@ -103,14 +108,22 @@ jobs:
- name: Parse release version
run: python ./.github/scripts/get_release_version.py
- name: Setup ${{ matrix.display-name }}
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.install-version }}
- name: Setup .NET 8.0 # net8 is always required.
uses: actions/setup-dotnet@v1
dotnet-quality: 'ga' # Prefer a GA release, but use the RC if not available
- name: Setup .NET 8 (required)
uses: actions/setup-dotnet@v3
if: ${{ matrix.install-version != '8.0.x' }}
with:
dotnet-version: 8.0.x
dotnet-version: '8.0.x'
dotnet-quality: 'ga'
- name: Setup .NET 9 (required)
uses: actions/setup-dotnet@v3
if: ${{ matrix.install-version != '9.0.x' }}
with:
dotnet-version: '9.0.x'
dotnet-quality: 'ga'
- 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
31 changes: 21 additions & 10 deletions .github/workflows/sdk_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ jobs:
- name: Parse release version
run: python ./.github/scripts/get_release_version.py
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
dotnet-quality: 'ga'
- name: Build
run: dotnet build --configuration release
- name: Generate Packages
Expand All @@ -43,39 +44,49 @@ jobs:
strategy:
fail-fast: false
matrix:
dotnet-version: ['6.0', '7.0', '8.0']
dotnet-version: ['6.0', '7.0', '8.0', '9.0']
include:
- dotnet-version: '6.0'
install-3: false
display-name: '.NET 6.0'
framework: 'net6'
prefix: 'net6'
install-version: '6.0.x'
- dotnet-version: '7.0'
install-3: false
display-name: '.NET 7.0'
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'
- dotnet-version: '9.0'
display-name: '.NET 9.0'
framework: 'net9'
prefix: 'net9'
install-version: '9.0.x'
steps:
- uses: actions/checkout@v1
- name: Parse release version
run: python ./.github/scripts/get_release_version.py
- name: Setup ${{ matrix.display-name }}
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.install-version }}
- name: Setup .NET 8.0 # net8 is always required.
uses: actions/setup-dotnet@v1
dotnet-quality: 'ga' # Prefer a GA release, but use the RC if not available
- name: Setup .NET 8 (required)
uses: actions/setup-dotnet@v3
if: ${{ matrix.install-version != '8.0.x' }}
with:
dotnet-version: 8.0.x
dotnet-version: '8.0.x'
dotnet-quality: 'ga'
- name: Setup .NET 9 (required)
uses: actions/setup-dotnet@v3
if: ${{ matrix.install-version != '9.0.x' }}
with:
dotnet-version: '9.0.x'
dotnet-quality: 'ga'
- 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
4 changes: 2 additions & 2 deletions all.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# 17
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dapr.Actors", "src\Dapr.Actors\Dapr.Actors.csproj", "{C2DB4B64-B7C3-4FED-8753-C040F677C69A}"
Expand Down Expand Up @@ -366,7 +366,7 @@ Global
{290D1278-F613-4DF3-9DF5-F37E38CDC363}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{290D1278-F613-4DF3-9DF5-F37E38CDC363}.Debug|Any CPU.Build.0 = Debug|Any CPU
{290D1278-F613-4DF3-9DF5-F37E38CDC363}.Release|Any CPU.ActiveCfg = Release|Any CPU
{290D1278-F613-4DF3-9DF5-F37E38CDC363}.Release|Any CPU.Build.0 = Release|Any CP
{290D1278-F613-4DF3-9DF5-F37E38CDC363}.Release|Any CPU.Build.0 = Release|Any CPU
{C8BB6A85-A7EA-40C0-893D-F36F317829B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C8BB6A85-A7EA-40C0-893D-F36F317829B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8BB6A85-A7EA-40C0-893D-F36F317829B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
10 changes: 9 additions & 1 deletion daprdocs/content/en/dotnet-sdk-docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ Dapr offers a variety of packages to help with the development of .NET applicati

- [Dapr CLI]({{< ref install-dapr-cli.md >}}) installed
- Initialized [Dapr environment]({{< ref install-dapr-selfhost.md >}})
- [.NET 6](https://dotnet.microsoft.com/download) or [.NET 8+](https://dotnet.microsoft.com/download) installed
- [.NET 6](https://dotnet.microsoft.com/download), [.NET 8](https://dotnet.microsoft.com/download) or [.NET 9](https://dotnet.microsoft.com/download) installed

{{% alert title="Note" color="primary" %}}

Note that while .NET 6 is generally supported as the minimum .NET requirement across the Dapr .NET SDK packages
and .NET 7 is the minimally supported version of .NET by Dapr.Workflows in Dapr v1.15, only .NET 8 and .NET 9 will
continue to be supported by Dapr in v1.16 and later.

{{% /alert %}}

## Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ This project contains the implementation of the actor client which calls MyActor

- [Dapr CLI]({{< ref install-dapr-cli.md >}}) installed.
- Initialized [Dapr environment]({{< ref install-dapr-selfhost.md >}}).
- [.NET 6+](https://dotnet.microsoft.com/download) installed. Dapr .NET SDK uses [ASP.NET Core](https://docs.microsoft.com/aspnet/core/introduction-to-aspnet-core?view=aspnetcore-6.0).
- [.NET 6](https://dotnet.microsoft.com/download), [.NET 8](https://dotnet.microsoft.com/download) or [.NET 9](https://dotnet.microsoft.com/download) installed

{{% alert title="Note" color="primary" %}}

Note that while .NET 6 is generally supported as the minimum .NET requirement across the Dapr .NET SDK packages
and .NET 7 is the minimally supported version of .NET by Dapr.Workflows in Dapr v1.15, only .NET 8 and .NET 9 will
continue to be supported by Dapr in v1.16 and later.

{{% /alert %}}

## Step 0: Prepare

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@ In the .NET example project:
- The main [`Program.cs`](https://github.com/dapr/dotnet-sdk/tree/master/examples/Jobs/JobsSample/Program.cs) file comprises the entirety of this demonstration.

## Prerequisites
- [.NET 6+](https://dotnet.microsoft.com/download) installed
- [Dapr CLI](https://docs.dapr.io/getting-started/install-dapr-cli/)
- [Initialized Dapr environment](https://docs.dapr.io/getting-started/install-dapr-selfhost)
- [Dapr Jobs .NET SDK](https://github.com/dapr/dotnet-sdk)
- [.NET 6](https://dotnet.microsoft.com/download), [.NET 8](https://dotnet.microsoft.com/download) or [.NET 9](https://dotnet.microsoft.com/download) installed

{{% alert title="Note" color="primary" %}}

Note that while .NET 6 is generally supported as the minimum .NET requirement across the Dapr .NET SDK packages
and .NET 7 is the minimally supported version of .NET by Dapr.Workflows in Dapr v1.15, only .NET 8 and .NET 9 will
continue to be supported by Dapr in v1.16 and later.

{{% /alert %}}

## Set up the environment
Clone the [.NET SDK repo](https://github.com/dapr/dotnet-sdk).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@ In the .NET example project:

## Prerequisites

- [.NET 6+](https://dotnet.microsoft.com/download) installed
- [Dapr CLI](https://docs.dapr.io/getting-started/install-dapr-cli/)
- [Initialized Dapr environment](https://docs.dapr.io/getting-started/install-dapr-selfhost/)
- [Dapr .NET SDK](https://github.com/dapr/dotnet-sdk/)
- [.NET 7](https://dotnet.microsoft.com/download), [.NET 8](https://dotnet.microsoft.com/download) or [.NET 9](https://dotnet.microsoft.com/download) installed

{{% alert title="Note" color="primary" %}}

Note that while .NET 6 is generally supported as the minimum .NET requirement across the Dapr .NET SDK packages
and .NET 7 is the minimally supported version of .NET by Dapr.Workflows in Dapr v1.15, only .NET 8 and .NET 9 will
continue to be supported by Dapr in v1.16 and later.

{{% /alert %}}

## Set up the environment

Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"_comment": "This policy allows the 8.0.100 SDK or patches in that family.",
"sdk": {
"version": "8.0.100",
"rollForward": "minor"
"version": "9.0.100",
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion src/Dapr.Common/Dapr.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6;net7;net8</TargetFrameworks> <!-- Supports .NET 7 for Dapr.Workflow -->
<TargetFrameworks>net6;net7;net8;net9</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion src/Dapr.Jobs/Dapr.Jobs.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6;net8</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>Dapr.Jobs</PackageId>
Expand Down
4 changes: 2 additions & 2 deletions src/Dapr.Jobs/Models/DaprJobSchedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public static DaprJobSchedule FromCronExpression(CronExpressionBuilder builder)
/// <returns></returns>
public static DaprJobSchedule FromDateTime(DateTimeOffset scheduledTime)
{
ArgumentNullException.ThrowIfNull(scheduledTime, nameof(scheduledTime));
return new DaprJobSchedule(scheduledTime.ToString("O"));
}

Expand All @@ -77,7 +76,9 @@ public static DaprJobSchedule FromDateTime(DateTimeOffset scheduledTime)
/// <param name="expression">The systemd Cron-like expression indicating when the job should be triggered.</param>
public static DaprJobSchedule FromExpression(string expression)
{
#if NET6_0
ArgumentNullException.ThrowIfNull(expression, nameof(expression));
#endif
return new DaprJobSchedule(expression);
}

Expand All @@ -87,7 +88,6 @@ public static DaprJobSchedule FromExpression(string expression)
/// <param name="duration">The duration interval.</param>
public static DaprJobSchedule FromDuration(TimeSpan duration)
{
ArgumentNullException.ThrowIfNull(duration, nameof(duration));
return new DaprJobSchedule(duration.ToDurationString());
}

Expand Down
1 change: 1 addition & 0 deletions src/Dapr.Protos/Dapr.Protos.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6;net7;net8;net9</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Description>This package contains the reference protos used by develop services using Dapr.</Description>
Expand Down
1 change: 1 addition & 0 deletions src/Dapr.Workflow/Dapr.Workflow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- NuGet configuration -->
<PropertyGroup>
<!-- NOTE: Workflows targeted .NET 7 (whereas other packages did not, so we must continue until .NET 7 EOL). -->
<TargetFrameworks>net6;net7;net8;net9</TargetFrameworks>
<Nullable>enable</Nullable>
<PackageId>Dapr.Workflow</PackageId>
<Title>Dapr Workflow Authoring SDK</Title>
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Import Project="$(MSBuildThisFileDirectory)..\properties\dapr_nuget.props" />

<PropertyGroup>
<TargetFrameworks>net6;net8</TargetFrameworks>
<TargetFrameworks>net6;net8;net9</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
Expand Up @@ -34,6 +34,8 @@ public Test()
7;
#elif NET8_0
8;
#elif NET9_0
9;
#endif

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public async Task CanSendBinaryCloudEvent_WithContentType()
using (var factory = new AppWebApplicationFactory())
{
var httpClient = factory.CreateClient(new Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactoryClientOptions { HandleCookies = false });

var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/register-user")
{
Content = new StringContent(
Expand All @@ -158,10 +158,10 @@ public async Task CanSendBinaryCloudEvent_WithContentType()
Encoding.UTF8)
};
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();

var userInfo = await JsonSerializer.DeserializeAsync<UserInfo>(await response.Content.ReadAsStreamAsync(), this.options);
userInfo.Name.Should().Be("jimmy");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,36 @@
</PackageReference>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<!-- <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />-->
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Hosting" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />


</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9'">
<PackageReference Update="Microsoft.AspNetCore.Mvc.Testing" VersionOverride="9.0.0" />
<PackageReference Update="Microsoft.AspNetCore.TestHost" VersionOverride="9.0.0"/>
<PackageReference Update="Microsoft.Extensions.Configuration" VersionOverride="9.0.0"/>
<PackageReference Update="Microsoft.Extensions.Configuration.Abstractions" VersionOverride="9.0.0"/>
<PackageReference Update="Microsoft.Extensions.DependencyInjection" VersionOverride="9.0.0"/>
<PackageReference Update="Microsoft.Extensions.DependencyInjection.Abstractions" VersionOverride="9.0.0"/>
<PackageReference Update="Microsoft.Extensions.Hosting" VersionOverride="9.0.0" />
<PackageReference Update="Microsoft.Extensions.Logging" VersionOverride="9.0.0"/>
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" VersionOverride="9.0.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Dapr.AspNetCore\Dapr.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\Dapr.Protos\Dapr.Protos.csproj" />
Expand Down
Loading

0 comments on commit da01dcd

Please sign in to comment.