Skip to content

Commit 06fb242

Browse files
Use different FQNs for parameterized cases in TestAdapter, fix #2494
1 parent b67b6b1 commit 06fb242

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/BenchmarkDotNet.TestAdapter/BenchmarkCaseExtensions.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ internal static TestCase ToVsTestCase(this BenchmarkCase benchmarkCase, string a
2525
{
2626
var benchmarkMethod = benchmarkCase.Descriptor.WorkloadMethod;
2727
var fullClassName = benchmarkCase.Descriptor.Type.GetCorrectCSharpTypeName();
28-
var benchmarkMethodName = benchmarkCase.Descriptor.WorkloadMethod.Name;
29-
var benchmarkFullMethodName = $"{fullClassName}.{benchmarkMethodName}";
30-
31-
// Display name has arguments as well.
32-
var displayMethodName = FullNameProvider.GetMethodName(benchmarkCase);
33-
if (includeJobInName)
34-
displayMethodName += $" [{benchmarkCase.GetUnrandomizedJobDisplayInfo()}]";
28+
var parametrizedMethodName = FullNameProvider.GetMethodName(benchmarkCase);
3529

30+
var displayJobInfo = benchmarkCase.GetUnrandomizedJobDisplayInfo();
31+
var displayMethodName = parametrizedMethodName + (includeJobInName ? $" [{displayJobInfo}]" : "");
3632
var displayName = $"{fullClassName}.{displayMethodName}";
3733

38-
var vsTestCase = new TestCase(benchmarkFullMethodName, VsTestAdapter.ExecutorUri, assemblyPath)
34+
// We use displayName as FQN to workaround the Rider/R# problem with FQNs processing
35+
// See: https://github.com/dotnet/BenchmarkDotNet/issues/2494
36+
var fullyQualifiedName = displayName;
37+
38+
var vsTestCase = new TestCase(fullyQualifiedName, VsTestAdapter.ExecutorUri, assemblyPath)
3939
{
4040
DisplayName = displayName,
4141
Id = GetTestCaseId(benchmarkCase)
@@ -67,7 +67,8 @@ internal static TestCase ToVsTestCase(this BenchmarkCase benchmarkCase, string a
6767
internal static string GetUnrandomizedJobDisplayInfo(this BenchmarkCase benchmarkCase)
6868
{
6969
var jobDisplayInfo = benchmarkCase.Job.DisplayInfo;
70-
if (!benchmarkCase.Job.HasValue(CharacteristicObject.IdCharacteristic) && benchmarkCase.Job.ResolvedId.StartsWith("Job-", StringComparison.OrdinalIgnoreCase))
70+
if (!benchmarkCase.Job.HasValue(CharacteristicObject.IdCharacteristic) &&
71+
benchmarkCase.Job.ResolvedId.StartsWith("Job-", StringComparison.OrdinalIgnoreCase))
7172
{
7273
// Replace Job-ABCDEF with Job
7374
jobDisplayInfo = "Job" + jobDisplayInfo.Substring(benchmarkCase.Job.ResolvedId.Length);
@@ -91,4 +92,4 @@ internal static Guid GetTestCaseId(this BenchmarkCase benchmarkCase)
9192
return testIdProvider.GetId();
9293
}
9394
}
94-
}
95+
}

0 commit comments

Comments
 (0)