diff --git a/src/BenchmarkDotNet/Running/Descriptor.cs b/src/BenchmarkDotNet/Running/Descriptor.cs index dce0200019..b66e63872b 100644 --- a/src/BenchmarkDotNet/Running/Descriptor.cs +++ b/src/BenchmarkDotNet/Running/Descriptor.cs @@ -51,7 +51,7 @@ public Descriptor( IterationCleanupMethod = iterationCleanupMethod; OperationsPerInvoke = operationsPerInvoke; AdditionalLogic = additionalLogic ?? string.Empty; - WorkloadMethodDisplayInfo = description ?? workloadMethod?.Name ?? "Untitled"; + WorkloadMethodDisplayInfo = FormatDescription(description) ?? workloadMethod?.Name ?? "Untitled"; Baseline = baseline; Categories = categories ?? Array.Empty(); MethodIndex = methodIndex; @@ -59,6 +59,14 @@ public Descriptor( public override string ToString() => DisplayInfo; + private static string FormatDescription([CanBeNull] string description) + { + var specialSymbols = new[] { ' ', '\'', '[', ']' }; + return description != null && specialSymbols.Any(description.Contains) + ? "'" + description + "'" + : description; + } + public bool HasCategory(string category) => Categories.Any(c => c.EqualsWithIgnoreCase(category)); public string GetFilterName() => $"{Type.GetCorrectCSharpTypeName(includeGenericArgumentsNamespace: false)}.{WorkloadMethod.Name}";