diff --git a/build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj b/build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj index c7b97bc90a..b1daf11601 100644 --- a/build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj +++ b/build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj @@ -1,7 +1,7 @@ Exe - net8.0 + net10.0 $(MSBuildProjectDirectory) enable diff --git a/build/BenchmarkDotNet.Build/Program.cs b/build/BenchmarkDotNet.Build/Program.cs index f18df86a9a..83acf532d9 100644 --- a/build/BenchmarkDotNet.Build/Program.cs +++ b/build/BenchmarkDotNet.Build/Program.cs @@ -62,7 +62,11 @@ public class InstallWasmToolsWorkload : FrostingTask, IHelpProvide { private const string Name = "install-wasm-tools"; - public override void Run(BuildContext context) => context.BuildRunner.InstallWorkload("wasm-tools"); + public override void Run(BuildContext context) + { + context.BuildRunner.InstallWorkload("wasm-tools-net8"); + context.BuildRunner.InstallWorkload("wasm-tools"); + } public HelpInfo GetHelp() { diff --git a/build/common.props b/build/common.props index 869a2abd67..72adb36f5c 100644 --- a/build/common.props +++ b/build/common.props @@ -41,7 +41,7 @@ - 12.0 + 14.0 diff --git a/build/sdk/global.json b/build/sdk/global.json index be5c357f30..59ce830ce6 100644 --- a/build/sdk/global.json +++ b/build/sdk/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.410", + "version": "10.0.100", "rollForward": "disable" } } diff --git a/src/BenchmarkDotNet/Code/DeclarationsProvider.cs b/src/BenchmarkDotNet/Code/DeclarationsProvider.cs index 7528e8ed62..ce697f9422 100644 --- a/src/BenchmarkDotNet/Code/DeclarationsProvider.cs +++ b/src/BenchmarkDotNet/Code/DeclarationsProvider.cs @@ -86,15 +86,15 @@ internal class NonVoidDeclarationsProvider : DeclarationsProvider public NonVoidDeclarationsProvider(Descriptor descriptor) : base(descriptor) { } public override string ConsumeField - => !Consumer.IsConsumable(WorkloadMethodReturnType) && Consumer.HasConsumableField(WorkloadMethodReturnType, out var field) - ? $".{field.Name}" + => !Consumer.IsConsumable(WorkloadMethodReturnType) && Consumer.HasConsumableField(WorkloadMethodReturnType, out var fieldInfo) + ? $".{fieldInfo.Name}" : null; protected override Type OverheadMethodReturnType => Consumer.IsConsumable(WorkloadMethodReturnType) ? WorkloadMethodReturnType - : (Consumer.HasConsumableField(WorkloadMethodReturnType, out var field) - ? field.FieldType + : (Consumer.HasConsumableField(WorkloadMethodReturnType, out var fieldInfo) + ? fieldInfo.FieldType : typeof(int)); // we return this simple type because creating bigger ValueType could take longer than benchmarked method itself public override string OverheadImplementation diff --git a/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs b/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs index 087d146822..25678db5e6 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs @@ -47,7 +47,7 @@ public void BenchmarkCanAllocateMoreThan2Gb() .Any()); Assert.Contains(".NET Framework", summary.AllRuntimes); - Assert.Contains(".NET 8.0", summary.AllRuntimes); + Assert.Contains(DotNetRuntimeHelper.GetExpectedDotNetCoreRuntimeName(), summary.AllRuntimes); } } diff --git a/tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs b/tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs index 50a929bd83..9fc615f091 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs @@ -51,7 +51,7 @@ public void SingleBenchmarkCanBeExecutedForMultipleRuntimes() .Any()); Assert.Contains(".NET Framework", summary.AllRuntimes); - Assert.Contains(".NET 8.0", summary.AllRuntimes); + Assert.Contains(DotNetRuntimeHelper.GetExpectedDotNetCoreRuntimeName(), summary.AllRuntimes); } } diff --git a/tests/BenchmarkDotNet.IntegrationTests/NugetReferenceTests.cs b/tests/BenchmarkDotNet.IntegrationTests/NugetReferenceTests.cs index e9f9469f13..37cd445023 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/NugetReferenceTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/NugetReferenceTests.cs @@ -35,7 +35,12 @@ public void UserCanSpecifyCustomNuGetPackageDependency() // Validate NuGet package version output message var stdout = GetSingleStandardOutput(report); - Assert.Contains($"System.Collections.Immutable: {targetVersion}", stdout); + + // When build oriject with .NET 10 SDK. PackageReference is pruned and SDK version assembly is used instead. + if (RuntimeInformation.IsNetCore && DotNetRuntimeHelper.GetExpectedDotNetCoreRuntimeName() == ".NET 10.0") + Assert.Contains(stdout, x => x.StartsWith("System.Collections.Immutable: 10.0.")); + else + Assert.Contains($"System.Collections.Immutable: {targetVersion}", stdout); } [FactEnvSpecific("Roslyn toolchain does not support .NET Core", EnvRequirement.FullFrameworkOnly)] diff --git a/tests/BenchmarkDotNet.Tests/Helpers/DotNetRuntimeHelper.cs b/tests/BenchmarkDotNet.Tests/Helpers/DotNetRuntimeHelper.cs new file mode 100644 index 0000000000..9a64a8ae7d --- /dev/null +++ b/tests/BenchmarkDotNet.Tests/Helpers/DotNetRuntimeHelper.cs @@ -0,0 +1,15 @@ +using BenchmarkDotNet.Portability; +using System; + +namespace BenchmarkDotNet +{ + public static class DotNetRuntimeHelper + { + public static string GetExpectedDotNetCoreRuntimeName() + { + return Environment.GetEnvironmentVariable("DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX") == "2" + ? ".NET 10.0" + : ".NET 8.0"; + } + } +} diff --git a/tests/BenchmarkDotNet.Tests/RuntimeVersionDetectionTests.cs b/tests/BenchmarkDotNet.Tests/RuntimeVersionDetectionTests.cs index b52030b0cc..081f9e6510 100644 --- a/tests/BenchmarkDotNet.Tests/RuntimeVersionDetectionTests.cs +++ b/tests/BenchmarkDotNet.Tests/RuntimeVersionDetectionTests.cs @@ -120,7 +120,10 @@ public void CurrentRuntimeIsProperlyRecognized() else Assert.True(runtime is MonoRuntime, $"Actual runtime: {runtime}, tfm: {runtime.MsBuildMoniker}, moniker: {runtime.RuntimeMoniker}"); #else - Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.RuntimeMoniker == RuntimeMoniker.Net80, $"Actual runtime: {runtime}, tfm: {runtime.MsBuildMoniker}, moniker: {runtime.RuntimeMoniker}"); + if (DotNetRuntimeHelper.GetExpectedDotNetCoreRuntimeName() == ".NET 10.0") + Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.RuntimeMoniker == RuntimeMoniker.Net10_0, $"Actual runtime: {runtime}, tfm: {runtime.MsBuildMoniker}, moniker: {runtime.RuntimeMoniker}"); + else + Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.RuntimeMoniker == RuntimeMoniker.Net80, $"Actual runtime: {runtime}, tfm: {runtime.MsBuildMoniker}, moniker: {runtime.RuntimeMoniker}"); #endif } }