Skip to content

Commit 6f8aa53

Browse files
authored
Upgrade solution to .NET 10.0 and modernize test infrastructure (#278)
* Upgrade solution to .NET 10.0 and modernize test infrastructure * All projects now target .NET 10.0, with NuGet packages the target .NET 10.0 only. * Replaced types marked as obsolete in .NET 10.0 (see below) * Integration tests have been refactored to use WebApplicationFactory instead of TestServer, and test helpers have been modernized. * Obsolete package references were removed. Service registration and Razor runtime compilation setup were updated to align with .NET 10 best practices. * Documentation and type references were clarified. ## Obsolete Types Replaced ### 1. **TestServer & WebHostBuilder** (Test Infrastructure) - **Obsolete:** `Microsoft.AspNetCore.TestHost.TestServer` + `Microsoft.AspNetCore.Hosting.WebHostBuilder` - **Replaced with:** `Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TProgram>` - **Files affected:** - `League.Tests\TestComponents\UnitTestHelpers.cs` — removed `GetLeagueTestServer()` method - `League.Tests\IntegrationTests\BasicIntegrationTests.cs` — refactored to use `WebApplicationFactory<League.WebApp.Program>` ### 2. **IActionContextAccessor & ActionContextAccessor** (Dependency Injection) - **Obsolete:** `Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor` - **Obsolete:** `Microsoft.AspNetCore.Mvc.Infrastructure.ActionContextAccessor` - **Replaced with:** Direct `ActionContext` creation from `IHttpContextAccessor` - **Files affected:** - `League\LeagueStartup.cs` — removed registration, now inline `ActionContext` factory in `IUrlHelper` scoped service ### 3. **MvcRazorRuntimeCompilationOptions** (View Compilation) - **Obsolete:** `Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.MvcRazorRuntimeCompilationOptions` - **Replaced with:** Direct `AddRazorRuntimeCompilation()` without explicit `FileProviders` configuration (auto-discovery) - **Files affected:** - `League.Demo\WebAppStartup.cs` — removed `services.Configure<MvcRazorRuntimeCompilationOptions>(...)` block - Removed unnecessary `using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;` and `using Microsoft.Extensions.FileProviders;` * Upgrade solution to .NET 10.0 and modernize test infrastructure * All projects now target .NET 10.0, with NuGet packages the target .NET 10.0 only. * Replaced types marked as obsolete in .NET 10.0 (see below) * Integration tests have been refactored to use WebApplicationFactory instead of TestServer, and test helpers have been modernized. * Obsolete package references were removed. Service registration and Razor runtime compilation setup were updated to align with .NET 10 best practices. * Documentation and type references were clarified. ## Obsolete Types Replaced ### 1. **TestServer & WebHostBuilder** (Test Infrastructure) - **Obsolete:** `Microsoft.AspNetCore.TestHost.TestServer` + `Microsoft.AspNetCore.Hosting.WebHostBuilder` - **Replaced with:** `Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory<TProgram>` - **Files affected:** - `League.Tests\TestComponents\UnitTestHelpers.cs` — removed `GetLeagueTestServer()` method - `League.Tests\IntegrationTests\BasicIntegrationTests.cs` — refactored to use `WebApplicationFactory<League.WebApp.Program>` ### 2. **IActionContextAccessor & ActionContextAccessor** (Dependency Injection) - **Obsolete:** `Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor` - **Obsolete:** `Microsoft.AspNetCore.Mvc.Infrastructure.ActionContextAccessor` - **Replaced with:** Direct `ActionContext` creation from `IHttpContextAccessor` - **Files affected:** - `League\LeagueStartup.cs` — removed registration, now inline `ActionContext` factory in `IUrlHelper` scoped service ### 3. **MvcRazorRuntimeCompilationOptions** (View Compilation) - **Obsolete:** `Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.MvcRazorRuntimeCompilationOptions` - **Replaced with:** Direct `AddRazorRuntimeCompilation()` without explicit `FileProviders` configuration (auto-discovery) - **Files affected:** - `League.Demo\WebAppStartup.cs` — removed `services.Configure<MvcRazorRuntimeCompilationOptions>(...)` block - Removed unnecessary `using Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation;` and `using Microsoft.Extensions.FileProviders;` * Bump version 9.0.0
1 parent 95ca0c7 commit 6f8aa53

File tree

20 files changed

+97
-81
lines changed

20 files changed

+97
-81
lines changed

Axuno.BackgroundTask.Test/Axuno.BackgroundTask.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<IsPackable>false</IsPackable>
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>

Axuno.BackgroundTask/Axuno.BackgroundTask.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Product>Axuno.BackgroundTask</Product>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<NoWarn>1591</NoWarn>
77
<ImplicitUsings>enable</ImplicitUsings>
@@ -17,6 +17,6 @@
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageReference>
20-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
20+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
2121
</ItemGroup>
2222
</Project>

Axuno.BackgroundTask/IBackgroundTask.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public interface IBackgroundTask
1616
/// <summary>
1717
/// Gets or sets the timeout, after which e.g. a <see cref="TimeoutException"/> should be thrown by the calling <see cref="IBackgroundQueue"/>
1818
/// (or any other appropriate action).
19-
/// Set the timeout to <see cref="TimeSpan.FromMilliseconds"/> with value -1 indicating an infinite timeout.
19+
/// Set the timeout to <see cref="TimeSpan.FromMilliseconds(double)"/> with value -1 indicating an infinite timeout.
2020
/// </summary>
2121
TimeSpan Timeout { get; set; }
22-
}
22+
}

Axuno.Tools.Tests/Axuno.Tools.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net8.0</TargetFramework>
3+
<TargetFramework>net10.0</TargetFramework>
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<IsPackable>false</IsPackable>

Axuno.Tools/Axuno.Tools.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Product>Axuno.Tools</Product>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<Nullable>enable</Nullable>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>

Axuno.Web/Axuno.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<Product>Axuno.Web</Product>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<NoWarn>1591</NoWarn>
77
<ImplicitUsings>enable</ImplicitUsings>

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<Copyright>Copyright 2011-$(CurrentYear) axuno gGmbH</Copyright>
88
<RepositoryUrl>https://github.com/axuno/Volleyball-League</RepositoryUrl>
99
<PublishRepositoryUrl>true</PublishRepositoryUrl>
10-
<Version>8.3.1</Version>
11-
<FileVersion>8.3.1</FileVersion>
12-
<AssemblyVersion>8.0.0.0</AssemblyVersion> <!--only update AssemblyVersion with major releases -->
10+
<Version>9.0.0</Version>
11+
<FileVersion>9.0.0</FileVersion>
12+
<AssemblyVersion>9.0.0.0</AssemblyVersion> <!--only update AssemblyVersion with major releases -->
1313
<LangVersion>latest</LangVersion>
1414
<Nullable>enable</Nullable>
1515
<EnableNETAnalyzers>true</EnableNETAnalyzers>

League.Demo/League.Demo.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
33
<Product>League.Demo</Product>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<NeutralLanguage>en</NeutralLanguage>
66
<!-- With dotnet, add parameter: -p:SatelliteResourceLanguages="""en;de""" -->
77
<SatelliteResourceLanguages>en;de</SatelliteResourceLanguages>

League.Demo/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static async Task Main(string[] args)
2525

2626
try
2727
{
28-
logger.Trace($"Configuration of {nameof(Microsoft.AspNetCore.WebHost)} starting.");
28+
logger.Trace($"Configuration of {nameof(WebApplicationBuilder)} starting.");
2929
logger.Info($"This app runs as {(Environment.Is64BitProcess ? "64-bit" : "32-bit")} process.\n\n");
3030

3131
var builder = SetupBuilder(args);

League.Demo/WebAppStartup.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ public static void ConfigureServices(WebApplicationBuilder builder, ILoggerFacto
4040

4141
// If you want to enable runtime compilation for other view components, you can use the following code:
4242
services.AddMvc().AddRazorRuntimeCompilation();
43-
44-
// Add runtime compilation for the League RCL
45-
services.Configure<MvcRazorRuntimeCompilationOptions>(options =>
46-
{
47-
var leagueLibraryPath = Path.GetFullPath(
48-
Path.Combine(environment.ContentRootPath, "..", nameof(League)));
49-
50-
options.FileProviders.Add(new PhysicalFileProvider(leagueLibraryPath));
51-
});
5243
}
5344
}
5445

0 commit comments

Comments
 (0)