diff --git a/.github/workflows/Build_&_Test.yml b/.github/workflows/Build_&_Test.yml index 3b5643e..467dfb1 100644 --- a/.github/workflows/Build_&_Test.yml +++ b/.github/workflows/Build_&_Test.yml @@ -5,7 +5,7 @@ # # - To turn off auto-generation set: # -# [GitHubActions (AutoGenerate = false)] +# [GithubActionsExtended (AutoGenerate = false)] # # - To trigger manual generation invoke: # @@ -31,7 +31,17 @@ jobs: steps: - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9' + dotnet-version: | + 8.0 + 9.0 + 10.0 - uses: actions/checkout@v4 + - name: 'Cache: .nuke/temp, ~/.nuget/packages' + uses: actions/cache@v4 + with: + path: | + .nuke/temp + ~/.nuget/packages + key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} - name: 'Run: Test' run: ./build.cmd Test diff --git a/.github/workflows/Manual_Nuget_Push.yml b/.github/workflows/Manual_Nuget_Push.yml index 1fce492..53b14ab 100644 --- a/.github/workflows/Manual_Nuget_Push.yml +++ b/.github/workflows/Manual_Nuget_Push.yml @@ -5,7 +5,7 @@ # # - To turn off auto-generation set: # -# [GitHubActions (AutoGenerate = false)] +# [GithubActionsExtended (AutoGenerate = false)] # # - To trigger manual generation invoke: # @@ -25,8 +25,18 @@ jobs: steps: - uses: actions/setup-dotnet@v4 with: - dotnet-version: '9' + dotnet-version: | + 8.0 + 9.0 + 10.0 - uses: actions/checkout@v4 + - name: 'Cache: .nuke/temp, ~/.nuget/packages' + uses: actions/cache@v4 + with: + path: | + .nuke/temp + ~/.nuget/packages + key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} - name: 'Run: NugetPush' run: ./build.cmd NugetPush env: diff --git a/build/Build.cs b/build/Build.cs index 2d0a350..4490319 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -14,20 +14,18 @@ using static Nuke.Common.Tools.DotNet.DotNetTasks; -[GitHubActions( +[GithubActionsExtended( "Build & Test", GitHubActionsImage.UbuntuLatest, - OnPushBranches = new []{ "main" }, - OnPullRequestBranches = new []{ "main" }, - InvokedTargets = new[] { nameof(Test) }, - AutoGenerate = false)] -[GitHubActions( + OnPushBranches = ["main"], + OnPullRequestBranches = ["main"], + InvokedTargets = [nameof(Test)])] +[GithubActionsExtended( "Manual Nuget Push", GitHubActionsImage.UbuntuLatest, - On = new[] { GitHubActionsTrigger.WorkflowDispatch }, - InvokedTargets = new[] { nameof(NugetPush) }, - ImportSecrets = new[] { nameof(NugetApiKey) }, - AutoGenerate = false)] + On = [GitHubActionsTrigger.WorkflowDispatch], + InvokedTargets = [nameof(NugetPush)], + ImportSecrets = [nameof(NugetApiKey)])] class Build : NukeBuild { /// Support plugins are available for: diff --git a/build/GithubActionsExtendedAttribute.cs b/build/GithubActionsExtendedAttribute.cs new file mode 100644 index 0000000..cbce162 --- /dev/null +++ b/build/GithubActionsExtendedAttribute.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using Nuke.Common.CI.GitHubActions; +using Nuke.Common.CI.GitHubActions.Configuration; +using Nuke.Common.Execution; +using Nuke.Common.Utilities; + +public class GitHubActionsSetupDotNetStep : GitHubActionsStep +{ + public GitHubActionsSetupDotNetStep(string[] versions) + { + Versions = versions; + } + + string[] Versions { get; } + + public override void Write(CustomFileWriter writer) + { + writer.WriteLine("- uses: actions/setup-dotnet@v4"); + + using (writer.Indent()) + { + writer.WriteLine("with:"); + using (writer.Indent()) + { + writer.WriteLine("dotnet-version: |"); + using (writer.Indent()) + { + foreach (var version in Versions) + { + writer.WriteLine(version); + } + } + } + } + } +} + +public class GithubActionsExtendedAttribute : GitHubActionsAttribute +{ + public GithubActionsExtendedAttribute(string name, GitHubActionsImage image, params GitHubActionsImage[] images) : base(name, image, images) + { + } + + protected override GitHubActionsJob GetJobs(GitHubActionsImage image, + IReadOnlyCollection relevantTargets) + { + var job = base.GetJobs(image, relevantTargets); + + var newSteps = new List(job.Steps); + newSteps.Insert(0, new GitHubActionsSetupDotNetStep([ + "8.0", "9.0", "10.0" + ])); + + job.Steps = newSteps.ToArray(); + + return job; + } +} \ No newline at end of file diff --git a/src/Auth0Net.DependencyInjection/Auth0Extensions.cs b/src/Auth0Net.DependencyInjection/Auth0Extensions.cs index c4b7fc6..9d65e31 100644 --- a/src/Auth0Net.DependencyInjection/Auth0Extensions.cs +++ b/src/Auth0Net.DependencyInjection/Auth0Extensions.cs @@ -91,15 +91,16 @@ private static IHttpClientBuilder AddAuth0AuthenticationClientInternal(this ISer services.AddSingleton(); return services.AddHttpClient() -#if !NETFRAMEWORK - // TODO drop this code with the release of .NET 10 +#if NET8_0 .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler() { PooledConnectionLifetime = TimeSpan.FromMinutes(2) }) + .SetHandlerLifetime(Timeout.InfiniteTimeSpan) #endif - .SetHandlerLifetime(Timeout.InfiniteTimeSpan); + ; + } @@ -117,14 +118,15 @@ public static IHttpClientBuilder AddAuth0ManagementClient(this IServiceCollectio services.AddSingleton(); return services.AddHttpClient() -#if !NETFRAMEWORK +#if NET8_0 .ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler() { PooledConnectionLifetime = TimeSpan.FromMinutes(2) }) + .SetHandlerLifetime(Timeout.InfiniteTimeSpan) #endif - .SetHandlerLifetime(Timeout.InfiniteTimeSpan); + ; } /// diff --git a/src/Auth0Net.DependencyInjection/Auth0Net.DependencyInjection.csproj b/src/Auth0Net.DependencyInjection/Auth0Net.DependencyInjection.csproj index 0c72019..17907ec 100644 --- a/src/Auth0Net.DependencyInjection/Auth0Net.DependencyInjection.csproj +++ b/src/Auth0Net.DependencyInjection/Auth0Net.DependencyInjection.csproj @@ -1,16 +1,16 @@  - net48;net8.0;net9.0 + net48;net8.0;net9.0;net10.0 true enable enable - 5.1.0 + 5.2.0 Hawxy Dependency Injection, HttpClientFactory & ASP.NET Core extensions for Auth0.NET latest true - Hawxy (JT) 2020-2025 + Hawxy (JT) 2020-2026 icon.png MIT https://github.com/Hawxy/Auth0Net.DependencyInjection @@ -21,29 +21,38 @@ - - - - - + + + + - + + + - - - + + + + + + + + + + + diff --git a/src/Auth0Net.DependencyInjection/Auth0ResilienceExtensions.cs b/src/Auth0Net.DependencyInjection/Auth0ResilienceExtensions.cs index 0b2eb44..8019dbd 100644 --- a/src/Auth0Net.DependencyInjection/Auth0ResilienceExtensions.cs +++ b/src/Auth0Net.DependencyInjection/Auth0ResilienceExtensions.cs @@ -17,7 +17,7 @@ public static class Auth0ResilienceExtensions /// The underlying /// The max number of retry attempts to Auth0. Defaults to 10. /// - public static IHttpResiliencePipelineBuilder AddAuth0RateLimitResilience(this IHttpClientBuilder builder, int maxRetryAttempts = 10) + public static IHttpResiliencePipelineBuilder AddAuth0RateLimitResilience(this IHttpClientBuilder builder, int maxRetryAttempts = 4) { return builder.AddResilienceHandler("RateLimitRetry", pipelineBuilder => diff --git a/tests/Auth0Net.DependencyInjection.Tests/Auth0Net.DependencyInjection.Tests.csproj b/tests/Auth0Net.DependencyInjection.Tests/Auth0Net.DependencyInjection.Tests.csproj index 34deecd..c35a0f1 100644 --- a/tests/Auth0Net.DependencyInjection.Tests/Auth0Net.DependencyInjection.Tests.csproj +++ b/tests/Auth0Net.DependencyInjection.Tests/Auth0Net.DependencyInjection.Tests.csproj @@ -1,23 +1,16 @@  - false - net8.0;net9.0 + Exe + net8.0;net9.0;net10.0 latest + true - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + +