-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.NET 8 Upgrade (Multi Framework targetting) (#2181)
## Why make this change? - Closes #2140 ## What is this change? - Updates all `.csproj` files to target both .NET8 and .NET6. (source: [How to multi target](https://learn.microsoft.com/dotnet/core/tutorials/libraries#how-to-multitarget) ```xml <TargetFrameworks>net8.0;net6.0</TargetFrameworks> ``` - Update **Directory.Packages.Props** to include framework specific sections targeting dependency versions compatible with .NET6 - Ref: https://josef.codes/multi-targeting-your-nuget-packages/ ```xml <ItemGroup Condition="'$(TargetFramework)' == 'net8.0'"> <PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="8.0.4" /> </ItemGroup> <ItemGroup Condition="'$(TargetFramework)' == 'net6.0'"> <PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="6.0.29" /> </ItemGroup> ``` - Added framework specific constructors for EasyAuth/Simulator AuthenticationHandlers because `ISystemClock` was deprecated in .NET8 and is a required constructor parameter when overriding `AuthenticationHandler` dotnet class used for custom authentication handlers. - https://learn.microsoft.com/en-us/dotnet/core/compatibility/aspnet-core/8.0/isystemclock-obsolete - [Multi target dotnet project && code](https://learn.microsoft.com/nuget/create-packages/multiple-target-frameworks-project-file#create-a-project-that-supports-multiple-net-framework-versions) - Updated instances of pulling client role header value (GraphQLFilterParser, SqlMutationEngine) due to stricter nullability checks (now errors) in .NET 8. The following original code "possibly returns null" and needs to be handled. ```csharp GetHttpContext().Request.Headers[AuthorizationResolver.CLIENT_ROLE_HEADER]; ``` Changed to be a conditional check: ```csharp if (!GetHttpContext().Request.Headers.TryGetValue(AuthorizationResolver.CLIENT_ROLE_HEADER, out StringValues headerValues) && headerValues.Count != 1) ``` - Due to stricter .NET 8 nullability checks, DabCacheService specification of return type now specifies nullable jsonElement? to be consistent with method signature. ```csharp async (FusionCacheFactoryExecutionContext<JsonElement?> ctx, CancellationToken ct) => ``` - Startup class also gets a fix for stricter nullability when processing config file name. Previously a null value was possible according to the compiler: OLD: ```csharp string configFileName = Configuration.GetValue<string>("ConfigFileName", FileSystemRuntimeConfigLoader.DEFAULT_CONFIG_FILE_NAME); ``` NEW ```csharp string configFileName = Configuration.GetValue<string>("ConfigFileName") ?? FileSystemRuntimeConfigLoader.DEFAULT_CONFIG_FILE_NAME; ``` ## How was this tested? This isn't a feature addition, but ensure that all existing tests pass. - [x] Integration Tests - [x] Unit Tests
- Loading branch information
1 parent
7804517
commit 85323c7
Showing
37 changed files
with
373 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"sdk": { | ||
"version": "6.0.100", | ||
"version": "8.0.100", | ||
"rollForward": "latestFeature" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.