Skip to content

Commit

Permalink
Target .NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersAbel committed Nov 6, 2023
1 parent 36071ce commit e621d51
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 12 deletions.
8 changes: 5 additions & 3 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"sdk": {
"allowPrerelease": false
}
"sdk": {
"version": "8.0.100-rc.2.23502.2",
"rollForward": "latestMajor",
"allowPrerelease": true
}
}
11 changes: 9 additions & 2 deletions src/Sustainsys.Saml2.AspNetCore/Saml2Handler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Sustainsys.Saml2.AspNetCore.Events;
Expand All @@ -10,6 +9,8 @@

namespace Sustainsys.Saml2.AspNetCore;

// TODO: OTel Metrics + Activities + logging/traces

/// <summary>
/// Saml2 authentication handler
/// </summary>
Expand All @@ -25,9 +26,15 @@ public class Saml2Handler : RemoteAuthenticationHandler<Saml2Options>
public Saml2Handler(
IOptionsMonitor<Saml2Options> options,
ILoggerFactory logger,
UrlEncoder encoder,
UrlEncoder encoder
#if NET8_0_OR_GREATER
)
: base(options, logger, encoder)
#else
,
ISystemClock clock)
: base(options, logger, encoder, clock)
#endif
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion src/Sustainsys.Saml2/Sustainsys.Saml2.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
14 changes: 12 additions & 2 deletions src/Tests/Sustainsys.Saml2.AspNetCore.Tests/Saml2HandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@ public class Saml2HandlerTests

var loggerFactory = Substitute.For<ILoggerFactory>();

#if !NET8_0_OR_GREATER
var systemClock = Substitute.For<ISystemClock>();
systemClock.UtcNow.Returns(CurrentFakeTime);
#endif

var handler = new Saml2Handler(
optionsMonitor,
loggerFactory,
UrlEncoder.Default,
UrlEncoder.Default
#if NET8_0_OR_GREATER
);
#else
,
systemClock);
#endif

var scheme = new AuthenticationScheme("Saml2", "Saml2", typeof(Saml2Handler));

Expand All @@ -58,7 +65,10 @@ private static Saml2Options CreateOptions()
EntityId = "https://idp.example.com",
SsoServiceUrl = "https://idp.example.com/sso",
SsoServiceBinding = Constants.BindingUris.HttpRedirect
}
},
#if NET8_0_OR_GREATER
TimeProvider = new Microsoft.Extensions.Time.Testing.FakeTimeProvider(CurrentFakeTime)
#endif
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -23,6 +23,10 @@
<PackageReference Include="NSubstitute" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="8.0.0-rc.2.23510.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Sustainsys.Saml2.AspNetCore\Sustainsys.Saml2.AspNetCore.csproj" />
<ProjectReference Include="..\Sustainsys.Saml2.Tests.Helpers\Sustainsys.Saml2.Tests.Helpers.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down

0 comments on commit e621d51

Please sign in to comment.