You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 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
0 commit comments