Skip to content

Commit 153e400

Browse files
authored
Fix #2793: Use proper FQN in VS Test Explorer to avoid hierarchy split (#2978)
When job display name contains '.' (e.g., '.NET 8.0.6'), VS Test Explorer interprets it as a namespace separator, causing incorrect hierarchy grouping. Detect Visual Studio environment via VSAPPIDNAME env variable and use the benchmark method FQN instead of displayName for the test case. Co-authored-by: Shrinidhi203 <[email protected]>
1 parent 9612c51 commit 153e400

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/BenchmarkDotNet.TestAdapter/BenchmarkCaseExtensions.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ internal static TestCase ToVsTestCase(this BenchmarkCase benchmarkCase, string a
3535
// See: https://github.com/dotnet/BenchmarkDotNet/issues/2494
3636
var fullyQualifiedName = displayName;
3737

38+
// Use benchmark method FQN on Visual Studio environment to avoid TestExplorer hierarchy split
39+
// when job display name contains '.' which is interpreted as a namespace separator by VS.
40+
// See: https://github.com/dotnet/BenchmarkDotNet/issues/2793
41+
if (Environment.GetEnvironmentVariable("VSAPPIDNAME") != null)
42+
{
43+
var benchmarkMethodName = benchmarkMethod.Name;
44+
fullyQualifiedName = $"{fullClassName}.{benchmarkMethodName}";
45+
}
46+
3847
var vsTestCase = new TestCase(fullyQualifiedName, VsTestAdapter.ExecutorUri, assemblyPath)
3948
{
4049
DisplayName = displayName,

0 commit comments

Comments
 (0)