Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
6 changes: 5 additions & 1 deletion build/BenchmarkDotNet.Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ public class InstallWasmToolsWorkload : FrostingTask<BuildContext>, 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()
{
Expand Down
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</PropertyGroup>

<PropertyGroup Condition=" '$(IsVisualBasic)' != 'true' AND '$(IsFsharp)' != 'true' ">
<LangVersion>12.0</LangVersion>
<LangVersion>14.0</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(VersionPrefix)' == '' ">
Expand Down
2 changes: 1 addition & 1 deletion build/sdk/global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.410",
"version": "10.0.100",
"rollForward": "disable"
}
}
8 changes: 4 additions & 4 deletions src/BenchmarkDotNet/Code/DeclarationsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
15 changes: 15 additions & 0 deletions tests/BenchmarkDotNet.Tests/Helpers/DotNetRuntimeHelper.cs
Original file line number Diff line number Diff line change
@@ -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";
}
}
}
5 changes: 4 additions & 1 deletion tests/BenchmarkDotNet.Tests/RuntimeVersionDetectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down