Skip to content

Commit e196fec

Browse files
committed
chore: update langversion to 14
1 parent d2be797 commit e196fec

File tree

10 files changed

+39
-12
lines changed

10 files changed

+39
-12
lines changed

build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

build/BenchmarkDotNet.Build/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ public class InstallWasmToolsWorkload : FrostingTask<BuildContext>, IHelpProvide
6262
{
6363
private const string Name = "install-wasm-tools";
6464

65-
public override void Run(BuildContext context) => context.BuildRunner.InstallWorkload("wasm-tools");
65+
public override void Run(BuildContext context)
66+
{
67+
context.BuildRunner.InstallWorkload("wasm-tools-net8");
68+
context.BuildRunner.InstallWorkload("wasm-tools");
69+
}
6670

6771
public HelpInfo GetHelp()
6872
{

build/common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</PropertyGroup>
4242

4343
<PropertyGroup Condition=" '$(IsVisualBasic)' != 'true' AND '$(IsFsharp)' != 'true' ">
44-
<LangVersion>12.0</LangVersion>
44+
<LangVersion>14.0</LangVersion>
4545
</PropertyGroup>
4646

4747
<PropertyGroup Condition=" '$(VersionPrefix)' == '' ">

build/sdk/global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.410",
3+
"version": "10.0.100",
44
"rollForward": "disable"
55
}
66
}

src/BenchmarkDotNet/Code/DeclarationsProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ internal class NonVoidDeclarationsProvider : DeclarationsProvider
8686
public NonVoidDeclarationsProvider(Descriptor descriptor) : base(descriptor) { }
8787

8888
public override string ConsumeField
89-
=> !Consumer.IsConsumable(WorkloadMethodReturnType) && Consumer.HasConsumableField(WorkloadMethodReturnType, out var field)
90-
? $".{field.Name}"
89+
=> !Consumer.IsConsumable(WorkloadMethodReturnType) && Consumer.HasConsumableField(WorkloadMethodReturnType, out var fieldInfo)
90+
? $".{fieldInfo.Name}"
9191
: null;
9292

9393
protected override Type OverheadMethodReturnType
9494
=> Consumer.IsConsumable(WorkloadMethodReturnType)
9595
? WorkloadMethodReturnType
96-
: (Consumer.HasConsumableField(WorkloadMethodReturnType, out var field)
97-
? field.FieldType
96+
: (Consumer.HasConsumableField(WorkloadMethodReturnType, out var fieldInfo)
97+
? fieldInfo.FieldType
9898
: typeof(int)); // we return this simple type because creating bigger ValueType could take longer than benchmarked method itself
9999

100100
public override string OverheadImplementation

tests/BenchmarkDotNet.IntegrationTests/LargeAddressAwareTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void BenchmarkCanAllocateMoreThan2Gb()
4747
.Any());
4848

4949
Assert.Contains(".NET Framework", summary.AllRuntimes);
50-
Assert.Contains(".NET 8.0", summary.AllRuntimes);
50+
Assert.Contains(DotNetRuntimeHelper.GetExpectedDotNetCoreRuntimeName(), summary.AllRuntimes);
5151
}
5252
}
5353

tests/BenchmarkDotNet.IntegrationTests/MultipleRuntimesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void SingleBenchmarkCanBeExecutedForMultipleRuntimes()
5151
.Any());
5252

5353
Assert.Contains(".NET Framework", summary.AllRuntimes);
54-
Assert.Contains(".NET 8.0", summary.AllRuntimes);
54+
Assert.Contains(DotNetRuntimeHelper.GetExpectedDotNetCoreRuntimeName(), summary.AllRuntimes);
5555
}
5656
}
5757

tests/BenchmarkDotNet.IntegrationTests/NugetReferenceTests.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ public void UserCanSpecifyCustomNuGetPackageDependency()
3535

3636
// Validate NuGet package version output message
3737
var stdout = GetSingleStandardOutput(report);
38-
Assert.Contains($"System.Collections.Immutable: {targetVersion}", stdout);
38+
39+
// When build oriject with .NET 10 SDK. PackageReference is pruned and SDK version assembly is used instead.
40+
if (RuntimeInformation.IsNetCore && DotNetRuntimeHelper.GetExpectedDotNetCoreRuntimeName() == ".NET 10.0")
41+
Assert.Contains(stdout, x => x.StartsWith("System.Collections.Immutable: 10.0."));
42+
else
43+
Assert.Contains($"System.Collections.Immutable: {targetVersion}", stdout);
3944
}
4045

4146
[FactEnvSpecific("Roslyn toolchain does not support .NET Core", EnvRequirement.FullFrameworkOnly)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using BenchmarkDotNet.Portability;
2+
using System;
3+
4+
namespace BenchmarkDotNet
5+
{
6+
public static class DotNetRuntimeHelper
7+
{
8+
public static string GetExpectedDotNetCoreRuntimeName()
9+
{
10+
return Environment.GetEnvironmentVariable("DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX") == "2"
11+
? ".NET 10.0"
12+
: ".NET 8.0";
13+
}
14+
}
15+
}

tests/BenchmarkDotNet.Tests/RuntimeVersionDetectionTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ public void CurrentRuntimeIsProperlyRecognized()
120120
else
121121
Assert.True(runtime is MonoRuntime, $"Actual runtime: {runtime}, tfm: {runtime.MsBuildMoniker}, moniker: {runtime.RuntimeMoniker}");
122122
#else
123-
Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.RuntimeMoniker == RuntimeMoniker.Net80, $"Actual runtime: {runtime}, tfm: {runtime.MsBuildMoniker}, moniker: {runtime.RuntimeMoniker}");
123+
if (DotNetRuntimeHelper.GetExpectedDotNetCoreRuntimeName() == ".NET 10.0")
124+
Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.RuntimeMoniker == RuntimeMoniker.Net10_0, $"Actual runtime: {runtime}, tfm: {runtime.MsBuildMoniker}, moniker: {runtime.RuntimeMoniker}");
125+
else
126+
Assert.True(runtime is CoreRuntime coreRuntime && coreRuntime.RuntimeMoniker == RuntimeMoniker.Net80, $"Actual runtime: {runtime}, tfm: {runtime.MsBuildMoniker}, moniker: {runtime.RuntimeMoniker}");
124127
#endif
125128
}
126129
}

0 commit comments

Comments
 (0)