BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

Wrong benchmark hierarchy shown on VS TestExplorer when job display name contains `.`

Open filzrev opened this issue 6 months ago • 0 comments

Currently following hierarchy are shown for BenchmarkDotNet.Samples when group by Project, Class.

Image

It show unintended 0 and 6 grouping.

It's caused by following workaround code for Rider/R#. (#2494) https://github.com/dotnet/BenchmarkDotNet/blob/799ecfc514f310efcd93d274199795f2ae4e276e/src/BenchmarkDotNet.TestAdapter/BenchmarkCaseExtensions.cs#L34-L36

It seems when FullyQualfiedName's dot(.) char. It's used for hierarchy separator. So when job display name contains . char. It cause wrong grouping.


I've confirmed, It can be fixed by overwriting FQN value for VS. But this workaround can't distinguish VS TestExplorer / Resharper's TestExplorer.

// Use benchmark method FQN on Visual Studio environment.
if (Environment.GetEnvironmentVariable("VSAPPIDNAME") != null)
{
   var benchmarkMethodName = benchmarkCase.Descriptor.WorkloadMethod.Name;
   var benchmarkFullMethodName = $"{fullClassName}.{benchmarkMethodName}";
   fullyQualifiedName = benchmarkFullMethodName;
}

filzrev avatar Jun 23 '25 12:06 filzrev