diff --git a/Directory.Build.props b/Directory.Build.props index c162063..e14a4b6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,9 +12,10 @@ - 7.0.0 + 8.0.0 + 7.0.0 6.0.0 - 3.1.26 + 3.1.26 diff --git a/appveyor.yml b/appveyor.yml index 77b803d..b386431 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,6 +8,13 @@ install: - gitversion /l console /output buildserver - choco install opencover.portable -y - choco install codecov -y + # Install 8.0 preview + - ps: $env:DOTNET_INSTALL_DIR = "C:\Program Files\dotnet" + - ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null + - ps: Invoke-WebRequest 'https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1' -OutFile "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Channel 8.0.1xx -Quality preview -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" + - dotnet --list-sdks cache: - C:\ProgramData\chocolatey\bin -> appveyor.yml, codecov.yml - C:\ProgramData\chocolatey\lib -> appveyor.yml, codecov.yml diff --git a/src/Correlate.Abstractions/Correlate.Abstractions.csproj b/src/Correlate.Abstractions/Correlate.Abstractions.csproj index d655a8d..a2373cd 100644 --- a/src/Correlate.Abstractions/Correlate.Abstractions.csproj +++ b/src/Correlate.Abstractions/Correlate.Abstractions.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0;netstandard2.0 + net8.0;net7.0;net6.0;netstandard2.0 Correlate diff --git a/src/Correlate.AspNetCore/Correlate.AspNetCore.csproj b/src/Correlate.AspNetCore/Correlate.AspNetCore.csproj index 2db5675..78c4ff4 100644 --- a/src/Correlate.AspNetCore/Correlate.AspNetCore.csproj +++ b/src/Correlate.AspNetCore/Correlate.AspNetCore.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0;netcoreapp3.1 + net8.0;net7.0;net6.0;netcoreapp3.1 Correlate diff --git a/src/Correlate.Core/Correlate.Core.csproj b/src/Correlate.Core/Correlate.Core.csproj index 24d5444..f5080a6 100644 --- a/src/Correlate.Core/Correlate.Core.csproj +++ b/src/Correlate.Core/Correlate.Core.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0;netstandard2.0 + net8.0;net7.0;net6.0;netstandard2.0 Correlate @@ -20,7 +20,7 @@ - + diff --git a/src/Correlate.DependencyInjection/Correlate.DependencyInjection.csproj b/src/Correlate.DependencyInjection/Correlate.DependencyInjection.csproj index 3fa2c96..79f8877 100644 --- a/src/Correlate.DependencyInjection/Correlate.DependencyInjection.csproj +++ b/src/Correlate.DependencyInjection/Correlate.DependencyInjection.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0;netstandard2.0 + net8.0;net7.0;net6.0;netstandard2.0 diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index d1304b6..9610daa 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -13,10 +13,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Correlate.AspNetCore.Tests/AspNetCore/CorrelateFeatureTests.cs b/test/Correlate.AspNetCore.Tests/AspNetCore/CorrelateFeatureTests.cs index 7b72de7..7ebbd2a 100644 --- a/test/Correlate.AspNetCore.Tests/AspNetCore/CorrelateFeatureTests.cs +++ b/test/Correlate.AspNetCore.Tests/AspNetCore/CorrelateFeatureTests.cs @@ -194,7 +194,7 @@ public async Task Given_that_response_already_contains_correlation_header_when_f _options.RequestHeaders.Should().NotBeNullOrEmpty(); const string existingCorrelationId = "existing-id"; - _responseFeature.Headers.Add(_options.RequestHeaders[0], existingCorrelationId); + _responseFeature.Headers.Append(_options.RequestHeaders[0], existingCorrelationId); var expectedHeader = new KeyValuePair( _options.RequestHeaders[0], diff --git a/test/Correlate.AspNetCore.Tests/Correlate.AspNetCore.Tests.csproj b/test/Correlate.AspNetCore.Tests/Correlate.AspNetCore.Tests.csproj index ebdbcd4..5e1980c 100644 --- a/test/Correlate.AspNetCore.Tests/Correlate.AspNetCore.Tests.csproj +++ b/test/Correlate.AspNetCore.Tests/Correlate.AspNetCore.Tests.csproj @@ -1,17 +1,19 @@  - net7.0;net6.0;netcoreapp3.1 + net8.0;net7.0;net6.0;netcoreapp3.1 true Correlate + - - + + + diff --git a/test/Correlate.Benchmarks/Correlate.Benchmarks.csproj b/test/Correlate.Benchmarks/Correlate.Benchmarks.csproj index d12ac3b..2af9e7a 100644 --- a/test/Correlate.Benchmarks/Correlate.Benchmarks.csproj +++ b/test/Correlate.Benchmarks/Correlate.Benchmarks.csproj @@ -1,12 +1,12 @@ - + Exe - net7.0;net6.0 + net8.0;net7.0;net6.0 enable enable false - true + true @@ -14,8 +14,8 @@ - - + + diff --git a/test/Correlate.Benchmarks/Program.cs b/test/Correlate.Benchmarks/Program.cs index 952cf2f..7220baa 100644 --- a/test/Correlate.Benchmarks/Program.cs +++ b/test/Correlate.Benchmarks/Program.cs @@ -1,39 +1,103 @@ -using BenchmarkDotNet.Configs; +using System.Reflection; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Environments; using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Order; using BenchmarkDotNet.Running; using BenchmarkDotNet.Toolchains; using BenchmarkDotNet.Toolchains.CsProj; using Correlate.Benchmarks; -IToolchain[] toolchains = { CsProjCoreToolchain.NetCoreApp70, CsProjCoreToolchain.NetCoreApp60 }; +Runtime mostCurrentRuntime = CoreRuntime.Core80; +IToolchain mostCurrentToolchain = CsProjCoreToolchain.NetCoreApp80; -IConfig cfg = DefaultConfig.Instance - .ForAllToolchains(toolchains, Job.Default.WithId("Current"), toolchain => toolchain.Equals(CsProjCoreToolchain.NetCoreApp70)) - .ForAllToolchains(toolchains, - Job.Default - .WithId("4.0.0") - .WithToolchain(CsProjCoreToolchain.NetCoreApp70) - .WithNuGet("Correlate.AspNetCore", "4.0.0") - .WithNuGet("Correlate.DependencyInjection", "4.0.0") - .WithArguments(new[] { new MsBuildArgument("/p:Baseline=false") }) - ); +Version[] versions = +{ + new("4.0.0"), new("5.1.0"), new("0.0.0") // Current +}; + +IEnumerable<(Runtime, IToolchain)> runtimes = ConfigExtensions.GetRuntimes(args); +IEnumerable<(Version version, Runtime runtime, IToolchain toolchain)> runs = + ( + from version in versions + from runtime in runtimes + orderby version descending, runtime.Item1.ToString() descending + select (version, runtime.Item1, runtime.Item2) + ).ToList(); #if RELEASE -BenchmarkRunner.Run(cfg); +IConfig cfg = DefaultConfig.Instance; #else -BenchmarkRunner.Run(new DebugInProcessConfig()); +IConfig cfg = new DebugInProcessConfig(); #endif +cfg = runs.Aggregate(cfg, + (current, run) => current + .ForAllRuntimes( + run.version, + run.runtime, + run.toolchain, + (runtime, toolchain) => runtime.Equals(mostCurrentRuntime) && toolchain.Equals(mostCurrentToolchain)) +); + +cfg.WithOrderer(new DefaultOrderer(SummaryOrderPolicy.Declared)); + +BenchmarkRunner.Run(cfg); internal static class ConfigExtensions { - public static IConfig ForAllToolchains(this IConfig config, IEnumerable toolchains, Job job, Func? isBaseline = null) + public static IReadOnlyCollection<(Runtime, IToolchain)> GetRuntimes(string[] args) { - foreach (IToolchain toolchain in toolchains) + const BindingFlags bf = BindingFlags.Public | BindingFlags.Static; + + var argRuntimes = args + .SkipWhile(arg => arg == "--runtimes") + .TakeWhile(arg => arg.StartsWith("net")) + .ToHashSet(StringComparer.OrdinalIgnoreCase); + + IEnumerable runtimes = typeof(CoreRuntime).GetFields(bf) + .Union(typeof(ClrRuntime).GetFields(bf)) + .Select(fi => fi.GetValue(null)) + .OfType() + .Where(rt => argRuntimes.Contains(rt.RuntimeMoniker.ToString())) + .ToList(); + + IEnumerable toolchains = typeof(CsProjCoreToolchain).GetFields(bf) + .Select(fi => fi.GetValue(null)) + .OfType() + .ToList(); + + return runtimes + .Select(rt => (rt, (IToolchain)toolchains.Single(tc => ((CsProjGenerator)tc.Generator).TargetFrameworkMoniker == rt.MsBuildMoniker))) + .ToList(); + } + + public static IConfig ForAllRuntimes(this IConfig config, Version version, Runtime runtime, IToolchain toolchain, Func isBaselineRuntime) + { + bool isCurrentVersion = version.Major == 0; + string label = isCurrentVersion + ? "vNext" + : $"v{version.ToString(3)}"; + + Job job = JobMode.Default + .WithRuntime(runtime) + .WithToolchain(toolchain) + .WithId(label); + + if (!isCurrentVersion) + { + job = job + .WithNuGet("Correlate.AspNetCore", version.ToString(3)) + .WithNuGet("Correlate.DependencyInjection", version.ToString(3)) + .WithArguments(new[] { new MsBuildArgument("/p:CurrentVersion=false") }); + } + else { - Job j = job.WithToolchain(toolchain); - config = config.AddJob(isBaseline?.Invoke(toolchain) ?? false ? j.AsBaseline() : j); + if (isBaselineRuntime(runtime, toolchain)) + { + job = job.AsBaseline(); + } } - return config; + return config.AddJob(job); } } diff --git a/test/Correlate.Benchmarks/README.md b/test/Correlate.Benchmarks/README.md index 5198d84..a04ab83 100644 --- a/test/Correlate.Benchmarks/README.md +++ b/test/Correlate.Benchmarks/README.md @@ -1,25 +1,31 @@ # Benchmark results ``` -BenchmarkDotNet v0.13.7, Windows 10 (10.0.19045.3324/22H2/2022Update) +BenchmarkDotNet v0.13.10, Windows 10 (10.0.19045.3693/22H2/2022Update) Intel Core i7-8700K CPU 3.70GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores -.NET SDK 7.0.400 - [Host] : .NET 7.0.10 (7.0.1023.36312), X64 RyuJIT AVX2 - 4.0.0 : .NET 6.0.21 (6.0.2123.36311), X64 RyuJIT AVX2 - Current : .NET 6.0.21 (6.0.2123.36311), X64 RyuJIT AVX2 +.NET SDK 8.0.100 + [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2 + v4.0.0 : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2 + v5.1.0 : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2 + vNext : .NET 6.0.25 (6.0.2523.51912), X64 RyuJIT AVX2 ``` -| Method | Job | Arguments | NuGetReferences | Toolchain | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | -|-------- |-------- |------------------ |--------------------------------------------------------------- |---------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| -| ApiCall | 4.0.0 | /p:Baseline=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | .NET 6.0 | 148.2 us | 1.95 us | 1.73 us | 1.02 | 0.02 | 0.4883 | 4.33 KB | 1.11 | -| ApiCall | 4.0.0 | /p:Baseline=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | .NET 7.0 | 148.1 us | 0.93 us | 0.87 us | 1.02 | 0.01 | 0.4883 | 4.06 KB | 1.04 | -| ApiCall | Current | Default | Default | .NET 6.0 | 140.2 us | 1.12 us | 1.05 us | 0.96 | 0.01 | 0.4883 | 4.16 KB | 1.07 | -| ApiCall | Current | Default | Default | .NET 7.0 | 145.8 us | 1.07 us | 1.00 us | 1.00 | 0.00 | 0.4883 | 3.91 KB | 1.00 | +| Method | Job | Runtime | Arguments | NuGetReferences | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio | +|-------- |------- |--------- |------------------------ |--------------------------------------------------------------- |---------:|--------:|--------:|------:|--------:|-------:|----------:|------------:| +| ApiCall | v4.0.0 | .NET 6.0 | /p:CurrentVersion=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | 169.6 us | 1.53 us | 1.36 us | 1.04 | 0.01 | 0.4883 | 4.33 KB | 1.15 | +| ApiCall | v4.0.0 | .NET 7.0 | /p:CurrentVersion=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | 174.8 us | 1.96 us | 1.64 us | 1.07 | 0.01 | 0.4883 | 4.06 KB | 1.08 | +| ApiCall | v4.0.0 | .NET 8.0 | /p:CurrentVersion=false | Correlate.AspNetCore 4.0.0,Correlate.DependencyInjection 4.0.0 | 165.5 us | 2.35 us | 2.20 us | 1.02 | 0.02 | 0.4883 | 3.87 KB | 1.03 | +| ApiCall | v5.1.0 | .NET 6.0 | /p:CurrentVersion=false | Correlate.AspNetCore 5.1.0,Correlate.DependencyInjection 5.1.0 | 168.7 us | 2.30 us | 2.15 us | 1.03 | 0.01 | 0.4883 | 4.17 KB | 1.11 | +| ApiCall | v5.1.0 | .NET 7.0 | /p:CurrentVersion=false | Correlate.AspNetCore 5.1.0,Correlate.DependencyInjection 5.1.0 | 169.9 us | 0.78 us | 0.65 us | 1.04 | 0.01 | 0.4883 | 3.91 KB | 1.04 | +| ApiCall | v5.1.0 | .NET 8.0 | /p:CurrentVersion=false | Correlate.AspNetCore 5.1.0,Correlate.DependencyInjection 5.1.0 | 162.6 us | 2.31 us | 2.05 us | 0.99 | 0.01 | 0.4883 | 3.75 KB | 1.00 | +| ApiCall | vNext | .NET 6.0 | Default | Default | 166.2 us | 1.70 us | 1.50 us | 1.02 | 0.02 | 0.4883 | 4.17 KB | 1.11 | +| ApiCall | vNext | .NET 7.0 | Default | Default | 170.6 us | 1.15 us | 1.02 us | 1.05 | 0.01 | 0.4883 | 3.91 KB | 1.04 | +| ApiCall | vNext | .NET 8.0 | Default | Default | 163.2 us | 1.60 us | 1.34 us | 1.00 | 0.00 | 0.4883 | 3.75 KB | 1.00 | ### CLI To run the benchmark: ``` cd ./test/Correlate.Benchmarks -dotnet run -c Release -f net7.0 net6.0 +dotnet run -c Release -f net8.0 --runtimes net80 net70 net60 ``` diff --git a/test/Correlate.Core.Tests/Correlate.Core.Tests.csproj b/test/Correlate.Core.Tests/Correlate.Core.Tests.csproj index ed61729..10f4107 100644 --- a/test/Correlate.Core.Tests/Correlate.Core.Tests.csproj +++ b/test/Correlate.Core.Tests/Correlate.Core.Tests.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0;netcoreapp3.1 + net8.0;net7.0;net6.0;netcoreapp3.1 true Correlate diff --git a/test/Correlate.DependencyInjection.Tests/Correlate.DependencyInjection.Tests.csproj b/test/Correlate.DependencyInjection.Tests/Correlate.DependencyInjection.Tests.csproj index f3d84cd..e8e1eea 100644 --- a/test/Correlate.DependencyInjection.Tests/Correlate.DependencyInjection.Tests.csproj +++ b/test/Correlate.DependencyInjection.Tests/Correlate.DependencyInjection.Tests.csproj @@ -1,7 +1,7 @@  - net7.0;net6.0;netcoreapp3.1 + net8.0;net7.0;net6.0;netcoreapp3.1 true Correlate.DependencyInjection diff --git a/test/Correlate.Testing/Correlate.Testing.csproj b/test/Correlate.Testing/Correlate.Testing.csproj index b6f4201..bb19c3c 100644 --- a/test/Correlate.Testing/Correlate.Testing.csproj +++ b/test/Correlate.Testing/Correlate.Testing.csproj @@ -1,7 +1,7 @@ - + - net7.0;net6.0;netstandard2.1 + net8.0;net7.0;net6.0;netstandard2.1 false @@ -12,8 +12,9 @@ - - + + +