Fix output of console writer of dotnet-counters when displayname is not set. (#505)
authorPeter Bons <Expecho@users.noreply.github.com>
Thu, 26 Sep 2019 21:30:23 +0000 (23:30 +0200)
committerSung Yoon Whang <suwhang@microsoft.com>
Thu, 26 Sep 2019 21:30:23 +0000 (14:30 -0700)
src/Tools/dotnet-counters/ConsoleWriter.cs

index 0714529c398103d56bcf802f2578db571d58b14f..5778480b2d55ef2840ffefa9ecbdfbbce387542c 100644 (file)
@@ -104,7 +104,7 @@ namespace Microsoft.Diagnostics.Tools.Counters
 
             if (!provider.Counters.TryGetValue(name, out ObservedCounter counter))
             {
-                string displayName = provider.KnownProvider?.TryGetDisplayName(name) ?? payload.GetDisplay() ?? name;
+                string displayName = provider.KnownProvider?.TryGetDisplayName(name) ?? (string.IsNullOrWhiteSpace(payload.GetDisplay()) ? name : payload.GetDisplay());
                 provider.Counters[name] = counter = new ObservedCounter(displayName);
                 maxNameLength = Math.Max(maxNameLength, displayName.Length);
                 redraw = true;