From e1b5c82f636336fd21b491f5e5a45cd40e0ac7e4 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 7 Mar 2026 16:43:10 +0900 Subject: [PATCH 01/25] chore: update xunit related package version to v3 with mtp v2 --- .../BenchmarkDotNet.Analyzers.Tests.csproj | 67 +++++++++---------- .../Fixtures/Serializable/ValueTupleDouble.cs | 2 - .../Fixtures/Serializable/ValueTupleTriple.cs | 4 +- ...markDotNet.Exporters.Plotting.Tests.csproj | 9 +-- .../ScottPlotExporterTests.cs | 3 + ....IntegrationTests.ConfigPerAssembly.csproj | 4 ++ ...DotNet.IntegrationTests.CustomPaths.csproj | 4 ++ ...egrationTests.DisabledOptimizations.csproj | 6 +- ...tegrationTests.EnabledOptimizations.csproj | 6 +- ...hmarkDotNet.IntegrationTests.FSharp.fsproj | 4 ++ ...ts.ManualRunning.MultipleFrameworks.csproj | 3 +- ...tNet.IntegrationTests.ManualRunning.csproj | 11 +-- .../DotMemoryTests.cs | 1 + .../DotTraceTests.cs | 1 + .../MsBuildArgumentTests.cs | 1 + ...hmarkDotNet.IntegrationTests.Static.csproj | 4 ++ ...DotNet.IntegrationTests.VisualBasic.vbproj | 4 ++ .../AsyncBenchmarksTests.cs | 4 -- .../BenchmarkDotNet.IntegrationTests.csproj | 11 +-- .../CopyToOutputTests.cs | 1 + .../CustomBuildConfigurationTests.cs | 4 +- .../GcModeTests.cs | 3 +- .../InProcessTest.cs | 1 - .../MemoryDiagnoserTests.cs | 0 .../ReferencesTests.cs | 1 - .../Shared/BenchmarkTestExecutor.cs | 1 + .../TailCallDiagnoserTests.cs | 1 + .../ThreadingDiagnoserTests.cs | 2 + .../WasmTests.cs | 2 +- .../BenchmarkDotNet.Tests.csproj | 11 +-- .../Detectors/Cpu/LinuxCpuInfoParserTests.cs | 2 +- .../Cpu/PowershellWmiCpuInfoParserTests.cs | 6 +- .../Shared/Loggers/OutputLogger.cs | 1 + .../Shared/XUnit/InlineDataEnvSpecific.cs | 1 + .../XUnit/InlineDataEnvSpecificDiscoverer.cs | 1 + 35 files changed, 95 insertions(+), 92 deletions(-) mode change 100755 => 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj mode change 100755 => 100644 tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs mode change 100755 => 100644 tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/BenchmarkDotNet.Analyzers.Tests.csproj b/tests/BenchmarkDotNet.Analyzers.Tests/BenchmarkDotNet.Analyzers.Tests.csproj index f17417cc6f..e9efa8570a 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/BenchmarkDotNet.Analyzers.Tests.csproj +++ b/tests/BenchmarkDotNet.Analyzers.Tests/BenchmarkDotNet.Analyzers.Tests.csproj @@ -1,39 +1,34 @@ - - - - BenchmarkDotNet.Analyzers.Tests - net472;net8.0;net10.0 - true - true - true - true - $(NoWarn);CS1591 + + + + BenchmarkDotNet.Analyzers.Tests + net472;net8.0;net10.0 + Exe + true + true + true + true + $(NoWarn);CS1591 - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs index 5642d4c615..4802092df4 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs @@ -1,5 +1,3 @@ -using Xunit.Abstractions; - namespace BenchmarkDotNet.Analyzers.Tests.Fixtures; public class ValueTupleDouble : IXunitSerializable diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs index 0b19f5c211..7bc8fe044c 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs @@ -1,5 +1,3 @@ -using Xunit.Abstractions; - namespace BenchmarkDotNet.Analyzers.Tests.Fixtures; public class ValueTupleTriple : IXunitSerializable @@ -29,4 +27,4 @@ public static implicit operator ValueTupleTriple((T1, T2, T3) valueT public override string ToString() => Value1 == null || Value2 == null || Value3 == null ? "" : $"{Value1} · {Value2} · {Value3}"; -} \ No newline at end of file +} diff --git a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj index 9aa9ef524b..36f4d39330 100644 --- a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj +++ b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/BenchmarkDotNet.Exporters.Plotting.Tests.csproj @@ -2,12 +2,12 @@ net8.0;net472 + Exe true false - @@ -18,12 +18,7 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/ScottPlotExporterTests.cs b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/ScottPlotExporterTests.cs index bb481d3ea8..1d5118dc69 100644 --- a/tests/BenchmarkDotNet.Exporters.Plotting.Tests/ScottPlotExporterTests.cs +++ b/tests/BenchmarkDotNet.Exporters.Plotting.Tests/ScottPlotExporterTests.cs @@ -3,6 +3,9 @@ using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Tests.Mocks; using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Linq; +using Xunit; namespace BenchmarkDotNet.Exporters.Plotting.Tests { diff --git a/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj b/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj index 5b849298b3..3b0d827f1c 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly/BenchmarkDotNet.IntegrationTests.ConfigPerAssembly.csproj @@ -3,6 +3,7 @@ BenchmarkDotNet.IntegrationTests.ConfigPerAssembly net472;net8.0 + Exe true BenchmarkDotNet.IntegrationTests.ConfigPerAssembly BenchmarkDotNet.IntegrationTests.ConfigPerAssembly @@ -13,6 +14,9 @@ + + + diff --git a/tests/BenchmarkDotNet.IntegrationTests.CustomPaths/BenchmarkDotNet.IntegrationTests.CustomPaths.csproj b/tests/BenchmarkDotNet.IntegrationTests.CustomPaths/BenchmarkDotNet.IntegrationTests.CustomPaths.csproj index ffea2b8a5f..f5eadf834b 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.CustomPaths/BenchmarkDotNet.IntegrationTests.CustomPaths.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.CustomPaths/BenchmarkDotNet.IntegrationTests.CustomPaths.csproj @@ -3,6 +3,7 @@ BenchmarkDotNet.IntegrationTests.CustomPaths net472 + Exe true BenchmarkDotNet.IntegrationTests.CustomPaths BenchmarkDotNet.IntegrationTests.CustomPaths @@ -13,6 +14,9 @@ + + + diff --git a/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj b/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj index fdb5400397..2d7c912a5b 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.DisabledOptimizations/BenchmarkDotNet.IntegrationTests.DisabledOptimizations.csproj @@ -3,18 +3,22 @@ BenchmarkDotNet.IntegrationTests.DisabledOptimizations net472;net8.0 + Exe true BenchmarkDotNet.IntegrationTests.DisabledOptimizations BenchmarkDotNet.IntegrationTests.DisabledOptimizations true false AnyCPU - + false + + + diff --git a/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj b/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj index 7bfa81d814..16a00547ad 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.EnabledOptimizations/BenchmarkDotNet.IntegrationTests.EnabledOptimizations.csproj @@ -3,18 +3,22 @@ BenchmarkDotNet.IntegrationTests.EnabledOptimizations net472;net8.0 + Exe true BenchmarkDotNet.IntegrationTests.EnabledOptimizations BenchmarkDotNet.IntegrationTests.EnabledOptimizations true false AnyCPU - + true + + + diff --git a/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj b/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj index aa75712391..f407047971 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj +++ b/tests/BenchmarkDotNet.IntegrationTests.FSharp/BenchmarkDotNet.IntegrationTests.FSharp.fsproj @@ -2,6 +2,7 @@ net472;net8.0 + Exe false @@ -10,6 +11,9 @@ + + + diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj index d7e229b621..e7c0a02a75 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj @@ -1,4 +1,4 @@ - + BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks @@ -17,7 +17,6 @@ - diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj old mode 100755 new mode 100644 index 6a05e2c1b7..e1b8af85f7 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj @@ -3,6 +3,7 @@ BenchmarkDotNet.IntegrationTests.ManualRunning net472;net8.0 + Exe true BenchmarkDotNet.IntegrationTests.ManualRunning BenchmarkDotNet.IntegrationTests.ManualRunning @@ -14,7 +15,6 @@ - @@ -24,7 +24,7 @@ $(DefineConstants);$(ExtraDefineConstants) - + @@ -43,12 +43,7 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotMemoryTests.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotMemoryTests.cs index efb02f0aea..0020481687 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotMemoryTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotMemoryTests.cs @@ -5,6 +5,7 @@ using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Portability; using BenchmarkDotNet.Toolchains.InProcess.Emit; +using Xunit; namespace BenchmarkDotNet.IntegrationTests.ManualRunning { diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotTraceTests.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotTraceTests.cs index dc11404f9f..4a240100c4 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotTraceTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/DotTraceTests.cs @@ -5,6 +5,7 @@ using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Portability; using BenchmarkDotNet.Toolchains.InProcess.Emit; +using Xunit; namespace BenchmarkDotNet.IntegrationTests.ManualRunning { diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/MsBuildArgumentTests.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/MsBuildArgumentTests.cs index 6592e76047..434af9df6c 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/MsBuildArgumentTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/MsBuildArgumentTests.cs @@ -2,6 +2,7 @@ using BenchmarkDotNet.Configs; using BenchmarkDotNet.Environments; using BenchmarkDotNet.Jobs; +using Xunit; namespace BenchmarkDotNet.IntegrationTests.ManualRunning { diff --git a/tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj b/tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj index 268340278e..4018d35038 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.Static/BenchmarkDotNet.IntegrationTests.Static.csproj @@ -3,6 +3,7 @@ BenchmarkDotNet.IntegrationTests.Static net472;net8.0 + Exe true BenchmarkDotNet.IntegrationTests.Static BenchmarkDotNet.IntegrationTests.Static @@ -13,6 +14,9 @@ + + + diff --git a/tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj b/tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj index 65ac132061..af80ee9f6c 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj +++ b/tests/BenchmarkDotNet.IntegrationTests.VisualBasic/BenchmarkDotNet.IntegrationTests.VisualBasic.vbproj @@ -2,9 +2,13 @@ net472;net8.0 + Exe + + + \ No newline at end of file diff --git a/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs b/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs index 52345b585d..53230ade6c 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs @@ -1,8 +1,4 @@ using BenchmarkDotNet.Attributes; -using BenchmarkDotNet.Jobs; -using BenchmarkDotNet.Toolchains; -using BenchmarkDotNet.Toolchains.InProcess.Emit; -using BenchmarkDotNet.Toolchains.InProcess.NoEmit; using System.Threading.Tasks.Sources; namespace BenchmarkDotNet.IntegrationTests diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj index 9da34e4662..e17785c5cc 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj @@ -4,6 +4,7 @@ BenchmarkDotNet.IntegrationTests net472;net8.0 net8.0 + Exe true BenchmarkDotNet.IntegrationTests BenchmarkDotNet.IntegrationTests @@ -16,7 +17,6 @@ - @@ -39,14 +39,7 @@ - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/BenchmarkDotNet.IntegrationTests/CopyToOutputTests.cs b/tests/BenchmarkDotNet.IntegrationTests/CopyToOutputTests.cs index bd8da25d01..3d88695806 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/CopyToOutputTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/CopyToOutputTests.cs @@ -1,5 +1,6 @@ #if NETFRAMEWORK using BenchmarkDotNet.IntegrationTests.CustomPaths; +using Xunit; namespace BenchmarkDotNet.IntegrationTests { diff --git a/tests/BenchmarkDotNet.IntegrationTests/CustomBuildConfigurationTests.cs b/tests/BenchmarkDotNet.IntegrationTests/CustomBuildConfigurationTests.cs index 6581960e2c..2e4e317692 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/CustomBuildConfigurationTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/CustomBuildConfigurationTests.cs @@ -1,12 +1,10 @@ -using System.Reflection; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Extensions; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Portability; using BenchmarkDotNet.Tests.XUnit; -#if !DEBUG -#endif +using System.Reflection; namespace BenchmarkDotNet.IntegrationTests { diff --git a/tests/BenchmarkDotNet.IntegrationTests/GcModeTests.cs b/tests/BenchmarkDotNet.IntegrationTests/GcModeTests.cs index 8d2558ebe3..ccd5f365fe 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/GcModeTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/GcModeTests.cs @@ -1,7 +1,8 @@ -using System.Runtime; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Configs; using BenchmarkDotNet.Jobs; +using System.Runtime; + #if NETFRAMEWORK using BenchmarkDotNet.Environments; #endif diff --git a/tests/BenchmarkDotNet.IntegrationTests/InProcessTest.cs b/tests/BenchmarkDotNet.IntegrationTests/InProcessTest.cs index f6868a1681..3b33f7745c 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/InProcessTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/InProcessTest.cs @@ -17,7 +17,6 @@ using System.Reflection; using System.Runtime.CompilerServices; - namespace BenchmarkDotNet.IntegrationTests { public class InProcessTest : BenchmarkTestExecutor diff --git a/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/MemoryDiagnoserTests.cs old mode 100755 new mode 100644 diff --git a/tests/BenchmarkDotNet.IntegrationTests/ReferencesTests.cs b/tests/BenchmarkDotNet.IntegrationTests/ReferencesTests.cs index 9daa2db80a..3adec4f6cb 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/ReferencesTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/ReferencesTests.cs @@ -1,4 +1,3 @@ - namespace BenchmarkDotNet.IntegrationTests { public class ReferencesTests : BenchmarkTestExecutor diff --git a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs index e3413c5e4a..795127c130 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs @@ -6,6 +6,7 @@ using BenchmarkDotNet.Reports; using BenchmarkDotNet.Running; using BenchmarkDotNet.Tests.Loggers; +using Xunit; namespace BenchmarkDotNet.IntegrationTests { diff --git a/tests/BenchmarkDotNet.IntegrationTests/TailCallDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/TailCallDiagnoserTests.cs index c224cbd47f..8d34d90724 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/TailCallDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/TailCallDiagnoserTests.cs @@ -11,6 +11,7 @@ using BenchmarkDotNet.Tests.XUnit; using System.Collections.Generic; using System.Linq; +using Xunit; namespace BenchmarkDotNet.IntegrationTests { diff --git a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs index c1f0160278..d478fe14b7 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/ThreadingDiagnoserTests.cs @@ -13,6 +13,8 @@ using BenchmarkDotNet.Toolchains.NativeAot; using BenchmarkDotNet.Detectors; using BenchmarkDotNet.IntegrationTests.Xunit; +using BenchmarkDotNet.Portability; +using Xunit; namespace BenchmarkDotNet.IntegrationTests { diff --git a/tests/BenchmarkDotNet.IntegrationTests/WasmTests.cs b/tests/BenchmarkDotNet.IntegrationTests/WasmTests.cs index a438cd5e56..3cce2158d2 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/WasmTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/WasmTests.cs @@ -98,4 +98,4 @@ public void Check() } } } -} +} \ No newline at end of file diff --git a/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj b/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj old mode 100755 new mode 100644 index a72dd579a3..c256243142 --- a/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj +++ b/tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj @@ -3,6 +3,7 @@ BenchmarkDotNet.Tests net8.0;net10.0;net472 + Exe BenchmarkDotNet.Tests BenchmarkDotNet.Tests true @@ -11,7 +12,6 @@ - @@ -20,13 +20,8 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/tests/BenchmarkDotNet.Tests/Detectors/Cpu/LinuxCpuInfoParserTests.cs b/tests/BenchmarkDotNet.Tests/Detectors/Cpu/LinuxCpuInfoParserTests.cs index 393bd2798b..e907ffa9aa 100644 --- a/tests/BenchmarkDotNet.Tests/Detectors/Cpu/LinuxCpuInfoParserTests.cs +++ b/tests/BenchmarkDotNet.Tests/Detectors/Cpu/LinuxCpuInfoParserTests.cs @@ -138,7 +138,7 @@ public void AmdRyzen9_7950X() CPU max MHz: 5881.0000 CPU min MHz: 400.0000 BogoMIPS: 8983.23 - Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl + Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512 cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local user_shstk avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean diff --git a/tests/BenchmarkDotNet.Tests/Detectors/Cpu/PowershellWmiCpuInfoParserTests.cs b/tests/BenchmarkDotNet.Tests/Detectors/Cpu/PowershellWmiCpuInfoParserTests.cs index 307a994ef6..1c6bbe6b2b 100644 --- a/tests/BenchmarkDotNet.Tests/Detectors/Cpu/PowershellWmiCpuInfoParserTests.cs +++ b/tests/BenchmarkDotNet.Tests/Detectors/Cpu/PowershellWmiCpuInfoParserTests.cs @@ -35,13 +35,13 @@ public void RealTwoProcessorEightCoresTest() Name:Intel(R) Xeon(R) CPU E5-2630 v3 NumberOfCores:8 NumberOfLogicalProcessors:16 - - + + MaxClockSpeed:2400 Name:Intel(R) Xeon(R) CPU E5-2630 v3 NumberOfCores:8 NumberOfLogicalProcessors:16 - + """; CpuInfo? actual = PowershellWmiCpuInfoParser.Parse(cpuInfo); diff --git a/tests/BenchmarkDotNet.Tests/Shared/Loggers/OutputLogger.cs b/tests/BenchmarkDotNet.Tests/Shared/Loggers/OutputLogger.cs index 2a83781f14..e9020d6e24 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/Loggers/OutputLogger.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/Loggers/OutputLogger.cs @@ -1,5 +1,6 @@ using BenchmarkDotNet.Loggers; using System.Runtime.CompilerServices; +using Xunit; namespace BenchmarkDotNet.Tests.Loggers { diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs index 65acf07295..79a720b6b1 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs @@ -1,5 +1,6 @@ using System.Reflection; using Xunit.Sdk; +using Xunit.v3; namespace BenchmarkDotNet.Tests.XUnit; diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs index dba7caa4c2..a9a73f20a3 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs @@ -1,3 +1,4 @@ +using Xunit; using Xunit.Sdk; namespace BenchmarkDotNet.Tests.XUnit; From 70e9ca10e158af84322b4099b5ff617c081cd81e Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 7 Mar 2026 16:58:34 +0900 Subject: [PATCH 02/25] chore: add using Xunit.Sdk statement for XunitSerializable --- .../Fixtures/Serializable/ValueTupleDouble.cs | 2 ++ .../Fixtures/Serializable/ValueTupleTriple.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs index 4802092df4..56819e9cf2 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleDouble.cs @@ -1,3 +1,5 @@ +using Xunit.Sdk; + namespace BenchmarkDotNet.Analyzers.Tests.Fixtures; public class ValueTupleDouble : IXunitSerializable diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs index 7bc8fe044c..82b871d3a3 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Serializable/ValueTupleTriple.cs @@ -1,3 +1,5 @@ +using Xunit.Sdk; + namespace BenchmarkDotNet.Analyzers.Tests.Fixtures; public class ValueTupleTriple : IXunitSerializable From 623c6f5f7e7b88fb96aef5e915f548a3a0e03eb5 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 7 Mar 2026 16:59:12 +0900 Subject: [PATCH 03/25] chore: fix xUnit3003 analyzer errors --- .../BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs | 7 +++++++ .../Shared/XUnit/TheoryEnvSpecific.cs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs index 6c57f08078..a0e02d4c07 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/FactEnvSpecific.cs @@ -1,3 +1,5 @@ +using System.Runtime.CompilerServices; +using Xunit; namespace BenchmarkDotNet.Tests.XUnit; @@ -14,4 +16,9 @@ public FactEnvSpecificAttribute(string reason, params EnvRequirement[] requireme if (skip != null) Skip = $"{skip} ({reason})"; } + + public FactEnvSpecificAttribute([CallerFilePath] string? sourceFilePath = null, [CallerLineNumber] int sourceLineNumber = -1) + : base(sourceFilePath, sourceLineNumber) + { + } } \ No newline at end of file diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/TheoryEnvSpecific.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/TheoryEnvSpecific.cs index 3303797884..92f039f030 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/TheoryEnvSpecific.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/TheoryEnvSpecific.cs @@ -1,3 +1,5 @@ +using System.Runtime.CompilerServices; +using Xunit; namespace BenchmarkDotNet.Tests.XUnit; @@ -14,4 +16,9 @@ public TheoryEnvSpecificAttribute(string reason, params EnvRequirement[] require if (skip != null) Skip = $"{skip} ({reason})"; } + + public TheoryEnvSpecificAttribute([CallerFilePath] string? sourceFilePath = null, [CallerLineNumber] int sourceLineNumber = -1) + : base(sourceFilePath, sourceLineNumber) + { + } } \ No newline at end of file From 8bb19b975522ee15ec0fe585a21e9d3babc38999 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 7 Mar 2026 17:45:03 +0900 Subject: [PATCH 04/25] chore: remove unittests project dependency from integration tests project --- .../BenchmarkDotNet.IntegrationTests.csproj | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj index e17785c5cc..52b42e81a2 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj @@ -33,10 +33,20 @@ + + - + + + + + + + From 6681ab8d956d23459d919b9ee379ca58b06a3fe7 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 7 Mar 2026 17:50:12 +0900 Subject: [PATCH 05/25] chore: modify theorydata related incompatible codes --- .../ArgumentsAttributeAnalyzerTests.cs | 4 +- ...GeneralParameterAttributesAnalyzerTests.cs | 42 +++++++++---------- .../ParamsAllValuesAttributeAnalyzerTests.cs | 12 ++---- .../ParamsAttributeAnalyzerTests.cs | 38 +++++++---------- .../BenchmarkRunner/RunAnalyzerTests.cs | 4 +- .../Extensions/TheoryDataExtensions.cs | 2 +- .../AsyncBenchmarksTests.cs | 8 +++- .../CallerThreadTests.cs | 4 +- .../EngineTests.cs | 4 +- .../RunAsyncTests.cs | 4 +- 10 files changed, 54 insertions(+), 68 deletions(-) diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs index 34d687adb4..68437e5eb5 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ArgumentsAttributeAnalyzerTests.cs @@ -555,7 +555,7 @@ public async Task Providing_expected_value_type_should_not_trigger_diagnostic( { var testCode = /* lang=c#-test */ $$""" using DifferentNamespace; - + using BenchmarkDotNet.Attributes; public class BenchmarkClass @@ -1110,7 +1110,7 @@ public void BenchmarkMethod({{integerValueAndType.Value2}} a) } public static IEnumerable DummyAttributeUsage - => DummyAttributeUsageTheoryData; + => DummyAttributeUsageTheoryData.Select(x => x.Data); public static TheoryData EmptyArgumentsAttributeUsagesWithMismatchingValueCount() { diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs index 16bf923259..3249f36163 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/GeneralParameterAttributesAnalyzerTests.cs @@ -159,7 +159,7 @@ public class BenchmarkClass } public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static TheoryData DuplicateSameParameterAttributeUsages => DuplicateSameAttributeUsagesTheoryData; @@ -321,7 +321,7 @@ public class BenchmarkClass await RunAsync(); } - public static TheoryData UniqueParameterAttributeUsages => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + public static TheoryData UniqueParameterAttributeUsages => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static TheoryData DuplicateSameParameterAttributeUsages => DuplicateSameAttributeUsagesTheoryData; @@ -480,21 +480,19 @@ public static IEnumerable DuplicateAttributeUsageCountsAndNonPublicCla => CombinationsGenerator.CombineArguments(DuplicateParameterAttributeUsageCounts, NonPublicClassMemberAccessModifiers); public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static IEnumerable<(string AttributeName, string AttributeUsage)> UniqueParameterAttributes - => UniqueParameterAttributesTheoryData.Select(tdr => ((tdr[0] as string)!, (tdr[1] as string)!)); + => UniqueParameterAttributesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2)); public static IEnumerable NonPublicClassMemberAccessModifiers -#pragma warning disable IDE0028 // Simplify collection initialization - => new NonPublicClassMemberAccessModifiersTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new NonPublicClassMemberAccessModifiersTheoryData().Select(x => x.Data); public static IEnumerable<(string CurrentUniqueAttributeUsage, int CurrentUniqueAttributeUsagePosition, int[] Counts)> DuplicateSameParameterAttributeUsages - => DuplicateSameAttributeUsagesTheoryData.Select(tdr => ((tdr[0] as string)!, (int)tdr[1], (tdr[2] as int[])!)); + => DuplicateSameAttributeUsagesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2, tdr.Data.Item3)); public static IEnumerable DuplicateParameterAttributeUsageCounts - => DuplicateAttributeUsageCountsTheoryData; + => DuplicateAttributeUsageCountsTheoryData.Select(x => x.Data); } public class PropertyMustBePublic : AnalyzerTestFixture @@ -649,18 +647,16 @@ public static IEnumerable DuplicateAttributeUsageCountsAndNonPublicCla => CombinationsGenerator.CombineArguments(DuplicateParameterAttributeUsageCounts, NonPublicClassMemberAccessModifiers); public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static IEnumerable<(string AttributeName, string AttributeUsage)> UniqueParameterAttributes - => UniqueParameterAttributesTheoryData.Select(tdr => ((tdr[0] as string)!, (tdr[1] as string)!)); + => UniqueParameterAttributesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2)); public static IEnumerable NonPublicClassMemberAccessModifiers -#pragma warning disable IDE0028 // Simplify collection initialization - => new NonPublicClassMemberAccessModifiersTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new NonPublicClassMemberAccessModifiersTheoryData().Select(x => x.Data); public static IEnumerable<(string CurrentUniqueAttributeUsage, int CurrentUniqueAttributeUsagePosition, int[] Counts)> DuplicateSameParameterAttributeUsages - => DuplicateSameAttributeUsagesTheoryData.Select(tdr => ((tdr[0] as string)!, (int)tdr[1], (tdr[2] as int[])!)); + => DuplicateSameAttributeUsagesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2, tdr.Data.Item3)); public static TheoryData DuplicateParameterAttributeUsageCounts => DuplicateAttributeUsageCountsTheoryData; @@ -814,7 +810,7 @@ public class BenchmarkClass } public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static TheoryData UniqueParameterAttributes => UniqueParameterAttributesTheoryData; @@ -952,7 +948,7 @@ public class BenchmarkClass } public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static TheoryData UniqueParameterAttributes => UniqueParameterAttributesTheoryData; @@ -1114,7 +1110,7 @@ public class BenchmarkClass } public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static TheoryData UniqueParameterAttributes => UniqueParameterAttributesTheoryData; @@ -1279,20 +1275,20 @@ public static IEnumerable DuplicateAttributeUsageCountsAndNonPublicPro => CombinationsGenerator.CombineArguments(DuplicateParameterAttributeUsageCounts, NonPublicPropertySetters()); public static TheoryData UniqueParameterAttributeUsages - => [.. UniqueParameterAttributesTheoryData.Select(tdr => (tdr[1] as string)!)]; + => [.. UniqueParameterAttributesTheoryData.Select(tdr => tdr.Data.Item2)]; public static IEnumerable<(string AttributeName, string AttributeUsage)> UniqueParameterAttributes - => UniqueParameterAttributesTheoryData.Select(tdr => ((tdr[0] as string)!, (tdr[1] as string)!)); + => UniqueParameterAttributesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2)); public static IEnumerable<(string CurrentUniqueAttributeUsage, int CurrentUniqueAttributeUsagePosition, int[] Counts)> DuplicateSameParameterAttributeUsages - => DuplicateSameAttributeUsagesTheoryData.Select(tdr => ((tdr[0] as string)!, (int)tdr[1], (tdr[2] as int[])!)); + => DuplicateSameAttributeUsagesTheoryData.Select(tdr => (tdr.Data.Item1, tdr.Data.Item2, tdr.Data.Item3)); public static TheoryData DuplicateParameterAttributeUsageCounts => DuplicateAttributeUsageCountsTheoryData; public static IEnumerable NonPublicPropertySetters() => new NonPublicPropertySetterAccessModifiersTheoryData() - .Select(m => $"{{ get; {m} set; }}") + .Select(m => $"{{ get; {m.Data} set; }}") .Concat(["{ get; }", "=> 0;"]); public static TheoryData NonPublicPropertySettersTheoryData() @@ -1487,7 +1483,7 @@ private static IEnumerable GenerateDuplicateAttributeUsageCombinations(Th private static ReadOnlyCollection<(string CurrentUniqueAttributeUsage, int CurrentUniqueAttributeUsagePosition, int[] Counts)> GenerateDuplicateSameAttributeUsageCombinations(TheoryData uniqueAttributeUsages) { var uniqueAttributeUsagesList = uniqueAttributeUsages - .Select(tdr => (tdr[1] as string)!) + .Select(tdr => tdr.Data.Item2) .ToList() .AsReadOnly(); diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAllValuesAttributeAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAllValuesAttributeAnalyzerTests.cs index ce92329620..68fcfcefa4 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAllValuesAttributeAnalyzerTests.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAllValuesAttributeAnalyzerTests.cs @@ -32,9 +32,7 @@ public class BenchmarkClass } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable InvalidTypes => [ @@ -149,9 +147,7 @@ public class BenchmarkClass } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable NonEnumStructs => [ @@ -249,9 +245,7 @@ public class BenchmarkClass } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable NonEnumOrBoolStructs => [ diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAttributeAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAttributeAnalyzerTests.cs index 5b2bb6cc86..043972a922 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAttributeAnalyzerTests.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/Attributes/ParamsAttributeAnalyzerTests.cs @@ -32,9 +32,7 @@ public string {{fieldOrPropertyDeclaration}} } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); } public class MustHaveValues : AnalyzerTestFixture @@ -113,12 +111,10 @@ public string {{fieldOrPropertyDeclaration}} } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable DummyAttributeUsage - => DummyAttributeUsageTheoryData; + => DummyAttributeUsageTheoryData.Select(x => x.Data); public static IEnumerable ScalarValuesListLength => Enumerable.Range(1, ScalarValues.Count); @@ -130,7 +126,7 @@ private static ReadOnlyCollection ScalarValues .AsReadOnly(); public static IEnumerable ScalarValuesContainerAttributeArgument - => ScalarValuesContainerAttributeArgumentTheoryData(); + => ScalarValuesContainerAttributeArgumentTheoryData().Select(x => x.Data); public static IEnumerable EmptyParamsAttributeUsagesWithLocationMarker() { @@ -252,7 +248,7 @@ public async Task Providing_expected_value_type_should_not_trigger_diagnostic( { var testCode = /* lang=c#-test */ $$""" using DifferentNamespace; - + using BenchmarkDotNet.Attributes; public class BenchmarkClass @@ -333,7 +329,7 @@ public async Task Providing_expected_enum_value_type_array_using_not_fully_quali { var testCode = /* lang=c#-test */ $$""" using DifferentNamespace; - + using BenchmarkDotNet.Attributes; public class BenchmarkClass @@ -391,7 +387,7 @@ public async Task Providing_expected_type_using_not_fully_qualified_name_located using BenchmarkDotNet.Attributes; namespace DifferentNamespace; - + public class BenchmarkClass { [{{dummyAttributeUsage}}Params({{string.Format(scalarValuesContainerAttributeArgument, valueAndType.Value1)}})] @@ -415,7 +411,7 @@ public async Task Providing_expected_type_using_not_fully_qualified_name_located { var testCode = /* lang=c#-test */ $$""" using DifferentNamespace; - + using BenchmarkDotNet.Attributes; public class BenchmarkClass @@ -769,7 +765,7 @@ public async Task Providing_an_unexpected_array_value_type_to_params_attribute_s var testCode = /* lang=c#-test */ $$""" using DifferentNamespace; - + using BenchmarkDotNet.Attributes; public class BenchmarkClass @@ -838,12 +834,10 @@ public object[] {{fieldOrPropertyDeclaration}} } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable DummyAttributeUsage - => DummyAttributeUsageTheoryData; + => DummyAttributeUsageTheoryData.Select(x => x.Data); public static IEnumerable> IntegerValuesAndTypesWithinTargetTypeRange => [ @@ -967,7 +961,7 @@ public static IEnumerable EmptyValuesAttributeArgument() } public static IEnumerable ScalarValuesContainerAttributeArgumentEnumerable - => ScalarValuesContainerAttributeArgumentTheoryData(); + => ScalarValuesContainerAttributeArgumentTheoryData().Select(x => x.Data); public static IEnumerable ArrayValuesContainerAttributeArgumentEnumerableLocal() { @@ -1208,12 +1202,10 @@ public string {{fieldOrPropertyDeclaration}} } public static IEnumerable FieldOrPropertyDeclarations -#pragma warning disable IDE0028 // Simplify collection initialization - => new FieldOrPropertyDeclarationsTheoryData(); -#pragma warning restore IDE0028 // Simplify collection initialization + => new FieldOrPropertyDeclarationsTheoryData().Select(x => x.Data); public static IEnumerable DummyAttributeUsage - => DummyAttributeUsageTheoryData; + => DummyAttributeUsageTheoryData.Select(x => x.Data); public static IEnumerable ScalarValuesListLength => Enumerable.Range(2, ScalarValues.Count); @@ -1224,7 +1216,7 @@ private static ReadOnlyCollection ScalarValues .ToList() .AsReadOnly(); public static IEnumerable ScalarValuesContainerAttributeArgument - => ScalarValuesContainerAttributeArgumentTheoryData(); + => ScalarValuesContainerAttributeArgumentTheoryData().Select(x => x.Data); public static IEnumerable ScalarValuesContainerAttributeArgumentWithLocationMarker() { diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/BenchmarkRunner/RunAnalyzerTests.cs b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/BenchmarkRunner/RunAnalyzerTests.cs index 458e8bd326..f50cbeaf8b 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/BenchmarkRunner/RunAnalyzerTests.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/AnalyzerTests/BenchmarkRunner/RunAnalyzerTests.cs @@ -61,7 +61,7 @@ public async Task Invoking_with_type_argument_class_having_at_least_one_public_m var testCode = /* lang=c#-test */ $$""" using BenchmarkDotNet.Running; - + public class Program { public static void Main(string[] args) { @@ -548,7 +548,7 @@ public void BenchmarkMethod() } public static IEnumerable NonPublicClassAccessModifiersExceptFile - => new NonPublicClassAccessModifiersTheoryData().Where(m => m != "file "); + => new NonPublicClassAccessModifiersTheoryData().Where(m => m.Data != "file ").Select(x => x.Data); } public class TypeArgumentClassMustBeUnsealed : AnalyzerTestFixture diff --git a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Extensions/TheoryDataExtensions.cs b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Extensions/TheoryDataExtensions.cs index bc5fcc258c..1970ab058d 100644 --- a/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Extensions/TheoryDataExtensions.cs +++ b/tests/BenchmarkDotNet.Analyzers.Tests/Fixtures/Extensions/TheoryDataExtensions.cs @@ -6,5 +6,5 @@ namespace BenchmarkDotNet.Analyzers.Tests.Fixtures; public static class TheoryDataExtensions { public static ReadOnlyCollection AsReadOnly(this TheoryData theoryData) - => (theoryData as IEnumerable).ToList().AsReadOnly(); + => theoryData.Select(x => x.Data).ToList().AsReadOnly(); } \ No newline at end of file diff --git a/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs b/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs index 53230ade6c..56d428fa6d 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/AsyncBenchmarksTests.cs @@ -1,4 +1,8 @@ using BenchmarkDotNet.Attributes; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Toolchains; +using BenchmarkDotNet.Toolchains.InProcess.Emit; +using BenchmarkDotNet.Toolchains.InProcess.NoEmit; using System.Threading.Tasks.Sources; namespace BenchmarkDotNet.IntegrationTests @@ -57,14 +61,14 @@ public void TaskReturningMethodsAreAwaited() [Fact] public void TaskReturningMethodsAreAwaited_AlreadyComplete() => CanExecute(); - public static TheoryData GetToolchains() => + public static TheoryData GetToolchains() => new( [ new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = false }), new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = true }), new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = false }), new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = true }), Job.Default.GetToolchain() - ]; + ]); [Theory] [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)] diff --git a/tests/BenchmarkDotNet.IntegrationTests/CallerThreadTests.cs b/tests/BenchmarkDotNet.IntegrationTests/CallerThreadTests.cs index fe0b3940cd..9073af2e4e 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/CallerThreadTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/CallerThreadTests.cs @@ -19,12 +19,12 @@ namespace BenchmarkDotNet.IntegrationTests; public class CallerThreadTests(ITestOutputHelper output) : BenchmarkTestExecutor(output) { - public static TheoryData GetToolchains() => + public static TheoryData GetToolchains() => new( [ new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = false }), new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = false }), Job.Default.GetToolchain() - ]; + ]); [Theory] [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)] diff --git a/tests/BenchmarkDotNet.IntegrationTests/EngineTests.cs b/tests/BenchmarkDotNet.IntegrationTests/EngineTests.cs index f37716cb04..84b5199206 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/EngineTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/EngineTests.cs @@ -72,12 +72,12 @@ public class FooBench public void Foo() => Thread.Sleep(10); } - public static TheoryData GetToolchains() => + public static TheoryData GetToolchains() => new( [ InProcessEmitToolchain.Default, InProcessNoEmitToolchain.Default, Job.Default.GetToolchain() - ]; + ]); // #1120 [Theory] diff --git a/tests/BenchmarkDotNet.IntegrationTests/RunAsyncTests.cs b/tests/BenchmarkDotNet.IntegrationTests/RunAsyncTests.cs index 5a1405bb78..62a21b6707 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/RunAsyncTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/RunAsyncTests.cs @@ -9,14 +9,14 @@ namespace BenchmarkDotNet.IntegrationTests; public class RunAsyncTests(ITestOutputHelper output) : BenchmarkTestExecutor(output) { - public static TheoryData GetToolchains() => + public static TheoryData GetToolchains() => new( [ new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = false }), new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = true }), new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = false }), new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = true }), Job.Default.GetToolchain() - ]; + ]); [Theory] [MemberData(nameof(GetToolchains), DisableDiscoveryEnumeration = true)] From a434cd21457ee43cd6c7d19fe32ace76661508f7 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 29 Mar 2026 03:52:23 +0900 Subject: [PATCH 06/25] chore: add global.json to use Microsoft.Testing.Platform by dotnet test --- global.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 global.json diff --git a/global.json b/global.json new file mode 100644 index 0000000000..3140116df3 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} From 564f7582126325db4b56d79847403b50cc56b040 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 29 Mar 2026 11:39:03 +0900 Subject: [PATCH 07/25] chore: add tests/.editorconfig --- BenchmarkDotNet.slnx | 1 + tests/.editorconfig | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 tests/.editorconfig diff --git a/BenchmarkDotNet.slnx b/BenchmarkDotNet.slnx index 7fa4bade23..45a12f59c0 100644 --- a/BenchmarkDotNet.slnx +++ b/BenchmarkDotNet.slnx @@ -28,6 +28,7 @@ + diff --git a/tests/.editorconfig b/tests/.editorconfig new file mode 100644 index 0000000000..64a64c01c8 --- /dev/null +++ b/tests/.editorconfig @@ -0,0 +1,7 @@ +root = false + +# C# files +[*.cs] +# xUnit1051: Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive. +dotnet_diagnostic.xUnit1051.severity = suggestion + From 74c510a8c67d61c8ce5b8dc18540e8adfb6d5f40 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 29 Mar 2026 19:51:06 +0900 Subject: [PATCH 08/25] chore: fix custom inlinedata attribute --- .../Shared/XUnit/InlineDataEnvSpecific.cs | 40 ++++++++++++++++--- .../XUnit/InlineDataEnvSpecificDiscoverer.cs | 33 --------------- 2 files changed, 34 insertions(+), 39 deletions(-) delete mode 100644 tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs index 79a720b6b1..8f9419f5c0 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecific.cs @@ -1,25 +1,53 @@ using System.Reflection; +using Xunit; using Xunit.Sdk; using Xunit.v3; namespace BenchmarkDotNet.Tests.XUnit; -[DataDiscoverer("BenchmarkDotNet.Tests.XUnit.InlineDataEnvSpecificDiscoverer", "BenchmarkDotNet.IntegrationTests")] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] public class InlineDataEnvSpecific : DataAttribute { - readonly object[] data; + /// + /// Gets the data to be passed to the test. + /// + // If the user passes null to the constructor, we assume what they meant was a + // single null value to be passed to the test. + public object?[] Data { get; } - public InlineDataEnvSpecific(object data, string reason, params EnvRequirement[] requirements) + public InlineDataEnvSpecific(object? data, string reason, params EnvRequirement[] requirements) : this([data], reason, requirements) { } - public InlineDataEnvSpecific(object[] data, string reason, params EnvRequirement[] requirements) + public InlineDataEnvSpecific(object?[] data, string reason, params EnvRequirement[] requirements) { - this.data = data; + // If the user passes null to the constructor, we assume what they meant was a + // single null value to be passed to the test. + Data = data ?? [null]; string? skip = EnvRequirementChecker.GetSkip(requirements); if (skip != null) Skip = $"{skip} ({reason})"; } - public override IEnumerable GetData(MethodInfo testMethod) => [data]; + public override ValueTask> GetData( + MethodInfo testMethod, + DisposalTracker disposalTracker) + { + var traits = new Dictionary>(StringComparer.OrdinalIgnoreCase); + TestIntrospectionHelper.MergeTraitsInto(traits, Traits); + + return new([ + new TheoryDataRow(Data) + { + Explicit = ExplicitAsNullable, + Label = Label, + Skip = Skip, + TestDisplayName = TestDisplayName, + Timeout = TimeoutAsNullable, + Traits = traits, + } + ]); + } + + public override bool SupportsDiscoveryEnumeration() + => true; } diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs b/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs deleted file mode 100644 index a9a73f20a3..0000000000 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/InlineDataEnvSpecificDiscoverer.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Xunit; -using Xunit.Sdk; - -namespace BenchmarkDotNet.Tests.XUnit; - -public class InlineDataEnvSpecificDiscoverer : IDataDiscoverer -{ - public IEnumerable GetData(IAttributeInfo dataAttribute, IMethodInfo testMethod) - { - // InlineDataEnvSpecific has two constructors: - // 1. InlineDataEnvSpecific(object data, string reason, params EnvRequirement[] requirements) - // 2. InlineDataEnvSpecific(object[] data, string reason, params EnvRequirement[] requirements) - // GetConstructorArguments returns arguments from the constructor that was actually called - - var args = dataAttribute.GetConstructorArguments().ToArray(); - if (args.Length == 0) - yield break; - - // First argument is either a single object or object[] - wrap accordingly - if (args[0] is object[] dataArray) - { - // Array constructor was used - yield return dataArray; - } - else - { - // Single object constructor was used - wrap in array - yield return new[] { args[0] }; - } - } - - public bool SupportsDiscoveryEnumeration(IAttributeInfo dataAttribute, IMethodInfo testMethod) => true; -} From 9e102ffbd34eb26b3269695bc327456cedebd396 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 05:40:06 +0900 Subject: [PATCH 09/25] chore: fix wasm related tests --- BenchmarkDotNet.slnx | 1 + tests/Directory.Build.targets | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 tests/Directory.Build.targets diff --git a/BenchmarkDotNet.slnx b/BenchmarkDotNet.slnx index 45a12f59c0..56aaa43b06 100644 --- a/BenchmarkDotNet.slnx +++ b/BenchmarkDotNet.slnx @@ -30,6 +30,7 @@ + diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets new file mode 100644 index 0000000000..90b61d0ba4 --- /dev/null +++ b/tests/Directory.Build.targets @@ -0,0 +1,9 @@ + + + + + + + From 167d6af4b51b4c105fdba6b02176cc2ff57f3065 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 14:04:09 +0900 Subject: [PATCH 10/25] chore: suppress MSB3277 warnings --- .../BenchmarkDotNet.IntegrationTests.ManualRunning.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj index e1b8af85f7..2d97462b82 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj @@ -3,6 +3,8 @@ BenchmarkDotNet.IntegrationTests.ManualRunning net472;net8.0 + + $(MSBuildWarningsAsMessages);MSB3277 Exe true BenchmarkDotNet.IntegrationTests.ManualRunning From 8fb8ae9f3b94e9b18bb4131587c6b8d38387694e Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 13:35:29 +0900 Subject: [PATCH 11/25] chore: migrate multipleframeworks tests to tunit --- ...ts.ManualRunning.MultipleFrameworks.csproj | 18 ++-- .../MultipleFrameworksTest.cs | 15 ++- .../Properties/AssemblyInfo.cs | 5 + .../ModuleInitializerAttribute.cs | 11 +++ .../Shared/TUnit/BenchmarkTestExecutor.cs | 93 +++++++++++++++++++ .../Shared/TUnit/OutputLogger.cs | 39 ++++++++ ...tNet.IntegrationTests.ManualRunning.csproj | 8 +- .../AllSetupAndCleanupTest.cs | 2 +- .../BenchmarkDotNet.IntegrationTests.csproj | 16 ++-- .../Shared/BenchmarkTestExecutor.cs | 1 - .../Shared/Extensions.cs | 2 +- .../MisconfiguredEnvironmentException.cs | 2 +- .../Shared/{XUnit => }/SmartAssert.cs | 2 +- 13 files changed, 176 insertions(+), 38 deletions(-) create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/AssemblyInfo.cs create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/System.Runtime.CompilerServices/ModuleInitializerAttribute.cs create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/BenchmarkTestExecutor.cs create mode 100644 tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/OutputLogger.cs rename tests/BenchmarkDotNet.Tests/Shared/{XUnit => }/SmartAssert.cs (96%) diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj index e7c0a02a75..80a9ac2738 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks.csproj @@ -16,12 +16,10 @@ true - - - - - - + + + + @@ -36,12 +34,8 @@ - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs index 9cc9ffeae0..d94a580e6c 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/MultipleFrameworksTest.cs @@ -2,6 +2,7 @@ using BenchmarkDotNet.Configs; using BenchmarkDotNet.Extensions; using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.Tests; namespace BenchmarkDotNet.IntegrationTests.ManualRunning { @@ -9,15 +10,11 @@ public class MultipleFrameworksTest : BenchmarkTestExecutor { private const string TfmEnvVarName = "TfmEnvVarName"; - public MultipleFrameworksTest(ITestOutputHelper output) : base(output) - { - } - - [Theory] - [InlineData(RuntimeMoniker.Net461)] - [InlineData(RuntimeMoniker.Net48)] - [InlineData(RuntimeMoniker.NetCoreApp20)] - [InlineData(RuntimeMoniker.Net80)] + [Test] + [TUnit.Core.Arguments(RuntimeMoniker.Net462)] + [TUnit.Core.Arguments(RuntimeMoniker.Net48)] + [TUnit.Core.Arguments(RuntimeMoniker.Net80)] + [TUnit.Core.Arguments(RuntimeMoniker.Net10_0)] public void EachFrameworkIsRebuilt(RuntimeMoniker runtime) { var config = ManualConfig.CreateEmpty().AddJob(Job.Dry.WithRuntime(runtime.GetRuntime()).WithEnvironmentVariable(TfmEnvVarName, runtime.ToString())); diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/AssemblyInfo.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..84dd4b071d --- /dev/null +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Properties/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using System.Runtime.InteropServices; + +[assembly: Guid("f8203913-4b95-4fd9-b640-08d58dd563e2")] + +[assembly: NotInParallel] diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/System.Runtime.CompilerServices/ModuleInitializerAttribute.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/System.Runtime.CompilerServices/ModuleInitializerAttribute.cs new file mode 100644 index 0000000000..874ad6d08a --- /dev/null +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/System.Runtime.CompilerServices/ModuleInitializerAttribute.cs @@ -0,0 +1,11 @@ +#if NETFRAMEWORK +namespace System.Runtime.CompilerServices; + +[AttributeUsage(AttributeTargets.Method, Inherited = false)] +public sealed class ModuleInitializerAttribute : Attribute +{ + public ModuleInitializerAttribute() + { + } +} +#endif diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/BenchmarkTestExecutor.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/BenchmarkTestExecutor.cs new file mode 100644 index 0000000000..a4a367b256 --- /dev/null +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/BenchmarkTestExecutor.cs @@ -0,0 +1,93 @@ +using AwesomeAssertions; +using BenchmarkDotNet.Columns; +using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Jobs; +using BenchmarkDotNet.IntegrationTests; +using BenchmarkDotNet.Loggers; +using BenchmarkDotNet.Reports; +using BenchmarkDotNet.Running; +using TUnit.Core.Interfaces; + +namespace BenchmarkDotNet.Tests; + +public class BenchmarkTestExecutor +{ + protected ITestOutput Output => TestContext.Current!.Output!; + + /// + /// Runs Benchmarks with the most simple config (SingleRunFastConfig) + /// combined with any benchmark config applied to TBenchmark (via an attribute) + /// By default will verify if every benchmark was successfully executed + /// + /// type that defines Benchmarks + /// Optional custom config to be used instead of the default + /// Optional: disable validation (default = true/enabled) + /// The summary from the benchmark run + public Reports.Summary CanExecute(IConfig? config = null, bool fullValidation = true) + { + return CanExecute(typeof(TBenchmark), config, fullValidation); + } + + /// + /// Runs Benchmarks with the most simple config (SingleRunFastConfig) + /// combined with any benchmark config applied to Type (via an attribute) + /// By default will verify if every benchmark was successfully executed + /// + /// type that defines Benchmarks + /// Optional custom config to be used instead of the default + /// Optional: disable validation (default = true/enabled) + /// The summary from the benchmark run + public Reports.Summary CanExecute(Type type, IConfig? config = null, bool fullValidation = true) + { + // Add logging, so the Benchmark execution is in the TestRunner output (makes Debugging easier) + if (config == null) + config = CreateSimpleConfig(); + + if (!config.GetLoggers().OfType().Any()) + config = config.AddLogger(Output != null ? new OutputLogger(Output) : ConsoleLogger.Default); + if (!config.GetLoggers().OfType().Any()) + config = config.AddLogger(ConsoleLogger.Default); + + if (!config.GetColumnProviders().Any()) + config = config.AddColumnProvider(DefaultColumnProviders.Instance); + + // Make sure we ALWAYS combine the Config (default or passed in) with any Config applied to the Type/Class + var summary = BenchmarkRunner.Run(type, config); + + if (fullValidation) + { + summary.HasCriticalValidationErrors.Should().BeFalse("The \"Summary\" should have NOT \"HasCriticalValidationErrors\""); + summary.Reports.Any().Should().BeTrue("The \"Summary\" should contain at least one \"BenchmarkReport\" in the \"Reports\" collection"); + + summary.CheckPlatformLinkerIssues(); + + summary.Reports.Should().OnlyContain(r => r.BuildResult.IsBuildSuccess, + "The following benchmarks have failed to build: " + + string.Join(", ", summary.Reports.Where(r => !r.BuildResult.IsBuildSuccess).Select(r => r.BenchmarkCase.DisplayInfo))); + + summary.Reports.Should().OnlyContain(r => r.ExecuteResults != null, + "The following benchmarks have failed to execute: " + + string.Join(", ", summary.Reports.Where(r => r.ExecuteResults == null || r.ExecuteResults.Any(er => !er.IsSuccess)).Select(r => r.BenchmarkCase.DisplayInfo))); ; + + summary.Reports.SelectMany(x => x.ExecuteResults).Should().OnlyContain(r => r.IsSuccess, + "All reports should have succeeded to execute"); + } + + return summary; + } + + protected IConfig CreateSimpleConfig(OutputLogger? logger = null, Job? job = null) + { + var baseConfig = job == null ? (IConfig)new SingleRunFastConfig() : new SingleJobConfig(job); + return baseConfig + .AddLogger(logger ?? (Output != null ? new OutputLogger(Output) : ConsoleLogger.Default)) + .AddColumnProvider(DefaultColumnProviders.Instance) + .AddAnalyser(DefaultConfig.Instance.GetAnalysers().ToArray()); + } + + protected static IReadOnlyList GetSingleStandardOutput(Summary summary) + => summary.Reports.Single().ExecuteResults.Single().StandardOutput; + + protected static IReadOnlyList GetCombinedStandardOutput(Summary summary) + => summary.Reports.SelectMany(r => r.ExecuteResults).SelectMany(e => e.StandardOutput).ToArray(); +} \ No newline at end of file diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/OutputLogger.cs b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/OutputLogger.cs new file mode 100644 index 0000000000..5350d2d9f9 --- /dev/null +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning.MultipleFrameworks/Shared/TUnit/OutputLogger.cs @@ -0,0 +1,39 @@ +using BenchmarkDotNet.Loggers; +using System.Runtime.CompilerServices; +using TUnit.Core.Interfaces; + +namespace BenchmarkDotNet.Tests; + +public class OutputLogger : AccumulationLogger +{ + private readonly ITestOutput Output; + private string currentLine = ""; + + public OutputLogger(ITestOutput output) + { + Output = output ?? throw new ArgumentNullException(nameof(Output)); + } + + [MethodImpl(MethodImplOptions.Synchronized)] + public override void Write(LogKind logKind, string text) + { + currentLine += text; + base.Write(logKind, text); + } + + [MethodImpl(MethodImplOptions.Synchronized)] + public override void WriteLine() + { + Output.WriteLine(currentLine); + currentLine = ""; + base.WriteLine(); + } + + [MethodImpl(MethodImplOptions.Synchronized)] + public override void WriteLine(LogKind logKind, string text) + { + Output.WriteLine(currentLine + text); + currentLine = ""; + base.WriteLine(logKind, text); + } +} \ No newline at end of file diff --git a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj index 2d97462b82..4cc3afcdd5 100644 --- a/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests.ManualRunning/BenchmarkDotNet.IntegrationTests.ManualRunning.csproj @@ -28,9 +28,11 @@ - - - + + + + + diff --git a/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs b/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs index 54934cd6a2..94965c50f6 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/AllSetupAndCleanupTest.cs @@ -2,7 +2,7 @@ using BenchmarkDotNet.Engines; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Reports; -using BenchmarkDotNet.Tests.XUnit; +using BenchmarkDotNet.Tests; namespace BenchmarkDotNet.IntegrationTests { diff --git a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj index 52b42e81a2..cb53e6dc27 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj +++ b/tests/BenchmarkDotNet.IntegrationTests/BenchmarkDotNet.IntegrationTests.csproj @@ -38,15 +38,13 @@ - - - - - - - + + + + + + + diff --git a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs index 795127c130..b608fdc1ec 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/BenchmarkTestExecutor.cs @@ -1,6 +1,5 @@ using BenchmarkDotNet.Columns; using BenchmarkDotNet.Configs; -using BenchmarkDotNet.IntegrationTests.Xunit; using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Loggers; using BenchmarkDotNet.Reports; diff --git a/tests/BenchmarkDotNet.IntegrationTests/Shared/Extensions.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/Extensions.cs index e6f27f54eb..bbee466722 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/Shared/Extensions.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/Extensions.cs @@ -1,6 +1,6 @@ using BenchmarkDotNet.Reports; -namespace BenchmarkDotNet.IntegrationTests.Xunit +namespace BenchmarkDotNet.IntegrationTests { public static class Extensions { diff --git a/tests/BenchmarkDotNet.IntegrationTests/Shared/MisconfiguredEnvironmentException.cs b/tests/BenchmarkDotNet.IntegrationTests/Shared/MisconfiguredEnvironmentException.cs index 8f5d236d9f..c397c9e339 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/Shared/MisconfiguredEnvironmentException.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/Shared/MisconfiguredEnvironmentException.cs @@ -1,4 +1,4 @@ -namespace BenchmarkDotNet.IntegrationTests.Xunit +namespace BenchmarkDotNet.IntegrationTests { public class MisconfiguredEnvironmentException : Exception { diff --git a/tests/BenchmarkDotNet.Tests/Shared/XUnit/SmartAssert.cs b/tests/BenchmarkDotNet.Tests/Shared/SmartAssert.cs similarity index 96% rename from tests/BenchmarkDotNet.Tests/Shared/XUnit/SmartAssert.cs rename to tests/BenchmarkDotNet.Tests/Shared/SmartAssert.cs index 3cbe6b3f82..c1cad4e86a 100644 --- a/tests/BenchmarkDotNet.Tests/Shared/XUnit/SmartAssert.cs +++ b/tests/BenchmarkDotNet.Tests/Shared/SmartAssert.cs @@ -1,6 +1,6 @@ using System.Text; -namespace BenchmarkDotNet.Tests.XUnit +namespace BenchmarkDotNet.Tests { public static class SmartAssert { From 16815c66b0e8ccfba4f0800526b65a28cac6af92 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 14:27:35 +0900 Subject: [PATCH 12/25] chore: update build project to support mtp --- .../BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj | 2 +- build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs | 10 ++++++++-- tests/Directory.Build.props | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj b/build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj index 1992bbf28e..44c9df5cfc 100644 --- a/build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj +++ b/build/BenchmarkDotNet.Build/BenchmarkDotNet.Build.csproj @@ -7,7 +7,7 @@ $(NoWarn);CA2007 - + diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index e6d5637040..db7f5bc676 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -3,7 +3,9 @@ using Cake.Common.Diagnostics; using Cake.Common.Tools.DotNet; using Cake.Common.Tools.DotNet.Test; +using Cake.Core; using Cake.Core.IO; +using System.Linq; using System.Runtime.InteropServices; namespace BenchmarkDotNet.Build.Runners; @@ -41,11 +43,15 @@ private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tf Framework = tfm, NoBuild = true, NoRestore = true, - Loggers = new[] { "trx", $"trx;LogFileName={logFile.FullPath}", "console;verbosity=detailed" }, EnvironmentVariables = { ["Platform"] = "" // force the tool to not look for the .dll in platform-specific directory - } + }, + PathType = DotNetTestPathType.Auto, + ArgumentCustomization = args + => args.Append("--report-trx") + .AppendSwitchQuoted("--report-trx-filename", System.IO.Path.GetFileName(logFile.FullPath)) + .Append("--no-progress"), }; return settings; } diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 95b878006d..7192d1f6ff 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -10,6 +10,10 @@ $([System.IO.Path]::GetDirectoryName($(MSBuildThisFileDirectory))) + + + + From f708cc63a092260417057dfc484f1be8967e4b6d Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 30 Mar 2026 19:54:40 +0900 Subject: [PATCH 13/25] chore: suppress auto-entrypoint generation of benchmark project templates --- src/BenchmarkDotNet/Templates/CsProj.txt | 1 + src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt | 3 ++- src/BenchmarkDotNet/Templates/R2RCsProj.txt | 1 + src/BenchmarkDotNet/Templates/WasmCsProj.txt | 3 ++- src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/BenchmarkDotNet/Templates/CsProj.txt b/src/BenchmarkDotNet/Templates/CsProj.txt index d7ae3cae05..f247140b21 100644 --- a/src/BenchmarkDotNet/Templates/CsProj.txt +++ b/src/BenchmarkDotNet/Templates/CsProj.txt @@ -27,6 +27,7 @@ true BenchmarkDotNet.Autogenerated.UniqueProgramName + false diff --git a/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt b/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt index e87eee2527..418b2c537b 100644 --- a/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt +++ b/src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt @@ -1,4 +1,4 @@ - + $CSPROJPATH$ $([System.IO.Path]::ChangeExtension('$(OriginalCSProjPath)', '.Mono.props')) @@ -21,6 +21,7 @@ true true + false diff --git a/src/BenchmarkDotNet/Templates/R2RCsProj.txt b/src/BenchmarkDotNet/Templates/R2RCsProj.txt index 0a9702ac1c..54f2c2aaa9 100644 --- a/src/BenchmarkDotNet/Templates/R2RCsProj.txt +++ b/src/BenchmarkDotNet/Templates/R2RCsProj.txt @@ -30,6 +30,7 @@ BenchmarkDotNet.Autogenerated.UniqueProgramName false + false diff --git a/src/BenchmarkDotNet/Templates/WasmCsProj.txt b/src/BenchmarkDotNet/Templates/WasmCsProj.txt index 5ab10b2a57..38068cef34 100644 --- a/src/BenchmarkDotNet/Templates/WasmCsProj.txt +++ b/src/BenchmarkDotNet/Templates/WasmCsProj.txt @@ -1,4 +1,4 @@ - + $CSPROJPATH$ $([System.IO.Path]::ChangeExtension('$(OriginalCSProjPath)', '.Wasm.props')) @@ -26,6 +26,7 @@ $CORECLR_OVERRIDES$ true BenchmarkDotNet.Autogenerated.UniqueProgramName + false diff --git a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs index 2cfdce0259..1f8f2c51eb 100644 --- a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs +++ b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs @@ -153,6 +153,7 @@ private string GenerateProjectForNuGetBuild(string projectFilePath, BuildPartiti false true false + false true {ilcOptimizationPreference} {ilcOptimizationPreference} From 2847bd4233b107ec27a61a48c8b3d103640e6d89 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Wed, 1 Apr 2026 22:32:56 +0900 Subject: [PATCH 14/25] chore: add setting to suppress entrypoint generation for NativeAot --- src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs index 1f8f2c51eb..fa21dc2d36 100644 --- a/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs +++ b/src/BenchmarkDotNet/Toolchains/NativeAot/Generator.cs @@ -153,7 +153,6 @@ private string GenerateProjectForNuGetBuild(string projectFilePath, BuildPartiti false true false - false true {ilcOptimizationPreference} {ilcOptimizationPreference} @@ -166,6 +165,10 @@ private string GenerateProjectForNuGetBuild(string projectFilePath, BuildPartiti true {GetInstructionSetSettings(buildPartition)} + + false + false + {GetRuntimeSettings(buildPartition.RepresentativeBenchmarkCase.Job.Environment.Gc, buildPartition.Resolver)} From c6b706ef57c59773c185cc006bca6c57d2cc4b36 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:03:05 +0900 Subject: [PATCH 15/25] chore: fix run-tests-selected workflow --- .github/workflows/run-tests-selected.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests-selected.yaml b/.github/workflows/run-tests-selected.yaml index 28711fda21..b62b122217 100644 --- a/.github/workflows/run-tests-selected.yaml +++ b/.github/workflows/run-tests-selected.yaml @@ -34,7 +34,7 @@ on: - net472 filter: type: string - description: Test filter text (It's used for `dotnet test --filter`) Use default value when running all tests + description: Test filter text (It's used for `dotnet test --filter-method`) Use default value when running all tests required: true default: "BenchmarkDotNet" iteration_count: @@ -83,12 +83,13 @@ jobs: run: | $PSNativeCommandUseErrorActionPreference = $true $iterationCount = ${{ inputs.iteration_count }} + + Write-Host ("OSArchitecture" + [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) foreach($i in 1..$iterationCount) { Write-Output ('##[group]Executing Iteration: {0}/${{ inputs.iteration_count }}' -f $i) - dotnet test -c Release --framework ${{ inputs.framework }} --filter ${{ inputs.filter }} -tl:off --no-build --logger "console;verbosity=normal" - + dotnet test -c Release --framework ${{ inputs.framework }} --no-build --filter-method "${{ inputs.filter }}" --no-ansi Write-Output '##[endgroup]' } From 9678bf5f7d9634332717c5869ee395ca325f966f Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Fri, 3 Apr 2026 15:02:10 +0900 Subject: [PATCH 16/25] chore: add setting for ci on windows-11-arm --- tests/Directory.Build.props | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 7192d1f6ff..e2bd2c4101 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -10,6 +10,11 @@ $([System.IO.Path]::GetDirectoryName($(MSBuildThisFileDirectory))) + + + true + + From a390f616c6847649f83b4639eec12283645f9895 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sat, 4 Apr 2026 05:15:34 +0900 Subject: [PATCH 17/25] chore: move PreferNativeArm64 setting to Directory.Build.targets --- tests/Directory.Build.props | 5 ----- tests/Directory.Build.targets | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index e2bd2c4101..7192d1f6ff 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -10,11 +10,6 @@ $([System.IO.Path]::GetDirectoryName($(MSBuildThisFileDirectory))) - - - true - - diff --git a/tests/Directory.Build.targets b/tests/Directory.Build.targets index 90b61d0ba4..be5cd7eabe 100644 --- a/tests/Directory.Build.targets +++ b/tests/Directory.Build.targets @@ -1,4 +1,9 @@ + + + true + + Date: Mon, 6 Apr 2026 09:58:19 +0900 Subject: [PATCH 18/25] chore: cleanup compile item references and file name --- ...ionParsingTestscs.cs => TargetFrameworkVersionParsingTests.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/BenchmarkDotNet.Tests/{TargetFrameworkVersionParsingTestscs.cs => TargetFrameworkVersionParsingTests.cs} (100%) diff --git a/tests/BenchmarkDotNet.Tests/TargetFrameworkVersionParsingTestscs.cs b/tests/BenchmarkDotNet.Tests/TargetFrameworkVersionParsingTests.cs similarity index 100% rename from tests/BenchmarkDotNet.Tests/TargetFrameworkVersionParsingTestscs.cs rename to tests/BenchmarkDotNet.Tests/TargetFrameworkVersionParsingTests.cs From 9e92029f7530f34bde1f89ecf4af5a0180c4334c Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 6 Apr 2026 10:37:56 +0900 Subject: [PATCH 19/25] chore: temporary skip disassemble tests for macos --- .../DisassemblyDiagnoserTests.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs index 5e804a3cde..b4b740edc5 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs @@ -1,6 +1,7 @@ using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Columns; using BenchmarkDotNet.Configs; +using BenchmarkDotNet.Detectors; using BenchmarkDotNet.Diagnosers; using BenchmarkDotNet.Disassemblers; using BenchmarkDotNet.Engines; @@ -85,6 +86,9 @@ public void Recursive() [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, IToolchain toolchain) { + if (OsDetector.IsMacOS()) + Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076"); + var disassemblyDiagnoser = new DisassemblyDiagnoser( new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3)); @@ -105,6 +109,9 @@ public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, IToolchain [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] public void CanDisassembleAllMethodCallsUsingFilters(Jit jit, Platform platform, IToolchain toolchain) { + if (OsDetector.IsMacOS()) + Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076"); + var disassemblyDiagnoser = new DisassemblyDiagnoser( new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 1, filters: ["*WithCalls*"])); @@ -131,6 +138,9 @@ public void CanDisassembleAllMethodCallsUsingFilters(Jit jit, Platform platform, [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] public void CanDisassembleGenericTypes(Jit jit, Platform platform, IToolchain toolchain) { + if (OsDetector.IsMacOS()) + Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076"); + var disassemblyDiagnoser = new DisassemblyDiagnoser( new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3)); @@ -152,6 +162,9 @@ [Benchmark] public void JustReturn() { } [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] public void CanDisassembleInlinableBenchmarks(Jit jit, Platform platform, IToolchain toolchain) { + if (OsDetector.IsMacOS()) + Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076"); + var disassemblyDiagnoser = new DisassemblyDiagnoser( new DisassemblyDiagnoserConfig(printSource: true, maxDepth: 3)); From 7ccc9b08c05024da81be638a271b42a1b998da85 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:14:17 +0900 Subject: [PATCH 20/25] chore: add diagnostic logs and collect as artifacts --- .github/workflows/run-tests.yaml | 16 ++++++++++++---- .../Runners/UnitTestRunner.cs | 5 ++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 7b8d6e578e..bd21f48d3e 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -52,7 +52,9 @@ jobs: if: always() with: name: test-windows-core-trx-${{ github.run_id }}-${{ matrix.os }} - path: "**/*.trx" + path: | + **/*.trx + **/log_*.diag test-windows-full: strategy: @@ -94,7 +96,9 @@ jobs: if: always() with: name: test-windows-full-trx-${{ github.run_id }}-${{ matrix.os }} - path: "**/*.trx" + path: | + **/*.trx + **/log_*.diag test-linux: strategy: @@ -129,7 +133,9 @@ jobs: if: always() with: name: test-linux-trx-${{ github.run_id }}-${{ matrix.os }} - path: "**/*.trx" + path: | + **/*.trx + **/log_*.diag test-macos: name: test-macos (${{ matrix.os.arch }}) @@ -169,7 +175,9 @@ jobs: if: always() with: name: test-macos(${{ matrix.os.arch }})-trx-${{ github.run_id }} - path: "**/*.trx" + path: | + **/*.trx + **/log_*.diag test-pack: runs-on: ubuntu-latest diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index db7f5bc676..836f4b12a5 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -51,7 +51,10 @@ private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tf ArgumentCustomization = args => args.Append("--report-trx") .AppendSwitchQuoted("--report-trx-filename", System.IO.Path.GetFileName(logFile.FullPath)) - .Append("--no-progress"), + .Append("--no-ansi") + .AppendSwitch("--output", "Detailed") + .Append("--diagnostic") + .AppendSwitch("--diagnostic-verbosity", "Trace") }; return settings; } From 830e8a53f3b34cb5a8c4a42ba86900ecb4822799 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Mon, 6 Apr 2026 15:41:00 +0900 Subject: [PATCH 21/25] chore: update generate-coverage-report.yaml --- .github/workflows/generate-coverage-report.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/generate-coverage-report.yaml b/.github/workflows/generate-coverage-report.yaml index f6684bcbf8..2eb1fa0897 100644 --- a/.github/workflows/generate-coverage-report.yaml +++ b/.github/workflows/generate-coverage-report.yaml @@ -44,13 +44,13 @@ jobs: - name: Collect Code Coverage run: | - dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Tests -c Release --no-build --framework net8.0" - dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net8.0" + dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Tests -c Release --no-build --framework net8.0" + dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net8.0" - name: Collect Code Coverage for BenchmarkDotNet.IntegrationTests if: ${{ github.event.inputs.skip_integration_tests == 'false'}} run: | - dotnet coverage connect bdn_coverage 'dotnet test tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net8.0 --filter "(FullyQualifiedName!~DotMemoryTests) & (FullyQualifiedName!~DotTraceTests) & (FullyQualifiedName!~WasmIsSupported) & (FullyQualifiedName!~WasmSupportsInProcessDiagnosers)"' + dotnet coverage connect bdn_coverage 'dotnet test --project tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net8.0 --filter-query "/*/*/(!*DotMemoryTests)&(!*DotTraceTests)/(!*WasmIsSupported)&(!*WasmSupportsInProcessDiagnosers)"' - name: Shutdown dotnet-coverage server. run: dotnet coverage shutdown bdn_coverage --timeout 60000 @@ -80,13 +80,13 @@ jobs: - name: Collect Code Coverage run: | - dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Tests -c Release --no-build --framework net472" - dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net472" + dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Tests -c Release --no-build --framework net472" + dotnet coverage connect bdn_coverage "dotnet test --project tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net472" - name: Collect Code Coverage for BenchmarkDotNet.IntegrationTests if: ${{ github.event.inputs.skip_integration_tests == 'false'}} run: | - dotnet coverage connect bdn_coverage 'dotnet test tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net472 --filter "(FullyQualifiedName!~DotMemoryTests) & (FullyQualifiedName!~DotTraceTests) & (FullyQualifiedName!~WasmIsSupported) & (FullyQualifiedName!~WasmSupportsInProcessDiagnosers)"' + dotnet coverage connect bdn_coverage 'dotnet test --project tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net472 --filter-query "/*/*/(!*DotMemoryTests)&(!*DotTraceTests)/(!*WasmIsSupported)&(!*WasmSupportsInProcessDiagnosers)"' - name: Shutdown dotnet-coverage server. run: dotnet coverage shutdown bdn_coverage --timeout 60000 From 6fb8bfdd104723c36c1e505990a34f88a762c046 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 9 Apr 2026 09:49:54 +0900 Subject: [PATCH 22/25] chore: add isinprocess condition to skip tests --- .../DisassemblyDiagnoserTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs index b4b740edc5..6aef8a3e51 100644 --- a/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs +++ b/tests/BenchmarkDotNet.IntegrationTests/DisassemblyDiagnoserTests.cs @@ -86,7 +86,7 @@ public void Recursive() [Trait(Constants.Category, Constants.BackwardCompatibilityCategory)] public void CanDisassembleAllMethodCalls(Jit jit, Platform platform, IToolchain toolchain) { - if (OsDetector.IsMacOS()) + if (OsDetector.IsMacOS() && toolchain.IsInProcess) Assert.Skip("https://github.com/dotnet/BenchmarkDotNet/issues/3076"); var disassemblyDiagnoser = new DisassemblyDiagnoser( From 9855dc5ee6fddbbe0d4199af97bc593fde17bdf6 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Thu, 9 Apr 2026 17:04:18 +0900 Subject: [PATCH 23/25] chore: modify test filter to exclude all wasm tests --- .github/workflows/generate-coverage-report.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate-coverage-report.yaml b/.github/workflows/generate-coverage-report.yaml index 2eb1fa0897..86c1850cfb 100644 --- a/.github/workflows/generate-coverage-report.yaml +++ b/.github/workflows/generate-coverage-report.yaml @@ -50,7 +50,7 @@ jobs: - name: Collect Code Coverage for BenchmarkDotNet.IntegrationTests if: ${{ github.event.inputs.skip_integration_tests == 'false'}} run: | - dotnet coverage connect bdn_coverage 'dotnet test --project tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net8.0 --filter-query "/*/*/(!*DotMemoryTests)&(!*DotTraceTests)/(!*WasmIsSupported)&(!*WasmSupportsInProcessDiagnosers)"' + dotnet coverage connect bdn_coverage 'dotnet test --project tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net8.0 --filter-query "/*/*/(!*DotMemoryTests)&(!*DotTraceTests)&(!*WasmTests)"' --no-ansi --output Detailed - name: Shutdown dotnet-coverage server. run: dotnet coverage shutdown bdn_coverage --timeout 60000 @@ -86,7 +86,7 @@ jobs: - name: Collect Code Coverage for BenchmarkDotNet.IntegrationTests if: ${{ github.event.inputs.skip_integration_tests == 'false'}} run: | - dotnet coverage connect bdn_coverage 'dotnet test --project tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net472 --filter-query "/*/*/(!*DotMemoryTests)&(!*DotTraceTests)/(!*WasmIsSupported)&(!*WasmSupportsInProcessDiagnosers)"' + dotnet coverage connect bdn_coverage 'dotnet test --project tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net472 --filter-query "/*/*/(!*DotMemoryTests)&(!*DotTraceTests)&(!*WasmTests)"' --no-ansi --output Detailed - name: Shutdown dotnet-coverage server. run: dotnet coverage shutdown bdn_coverage --timeout 60000 From bdc65955811cb64dab30fe9d24e4021f2208b675 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Sun, 12 Apr 2026 20:22:56 +0900 Subject: [PATCH 24/25] chore: add setting to use native mtp entrypoint --- tests/Directory.Build.props | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 7192d1f6ff..48435cf1a2 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -10,6 +10,10 @@ $([System.IO.Path]::GetDirectoryName($(MSBuildThisFileDirectory))) + + true + + From f5fda24a82d0ab7932d11ba8906743a4dee30fb1 Mon Sep 17 00:00:00 2001 From: filzrev <103790468+filzrev@users.noreply.github.com> Date: Wed, 15 Apr 2026 14:54:48 +0900 Subject: [PATCH 25/25] chore: remove mtp trx report package and use xunit's trx reporter instead --- build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs | 4 ++-- tests/Directory.Build.props | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs index 836f4b12a5..f592ea65e7 100644 --- a/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs +++ b/build/BenchmarkDotNet.Build/Runners/UnitTestRunner.cs @@ -49,8 +49,8 @@ private DotNetTestSettings GetTestSettingsParameters(FilePath logFile, string tf }, PathType = DotNetTestPathType.Auto, ArgumentCustomization = args - => args.Append("--report-trx") - .AppendSwitchQuoted("--report-trx-filename", System.IO.Path.GetFileName(logFile.FullPath)) + => args.Append("--report-xunit-trx") + .AppendSwitchQuoted("--report-xunit-trx-filename", System.IO.Path.GetFileName(logFile.FullPath)) .Append("--no-ansi") .AppendSwitch("--output", "Detailed") .Append("--diagnostic") diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index 48435cf1a2..68d9e50706 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -14,10 +14,6 @@ true - - - -