From: Sung Yoon Whang Date: Thu, 11 Jul 2019 04:11:55 +0000 (-0700) Subject: Fix issue 387 (#391) X-Git-Tag: submit/tizen/20190813.035844~4^2^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=92f0b993f33dcb35eef7ebfb2693c694193da62d;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Fix issue 387 (#391) * Fix some issue in counters * fix accidental bug --- diff --git a/src/Tools/dotnet-counters/ConsoleWriter.cs b/src/Tools/dotnet-counters/ConsoleWriter.cs index e89d58a1b..0f2a5eaf4 100644 --- a/src/Tools/dotnet-counters/ConsoleWriter.cs +++ b/src/Tools/dotnet-counters/ConsoleWriter.cs @@ -38,12 +38,20 @@ namespace Microsoft.Diagnostics.Tools.Counters displayLength = new Dictionary(); knownProvidersRowNum = new Dictionary(); unknownProvidersRowNum = new Dictionary(); - leftAlign = 45; // Width of counter names column + int maxNameWidth = -1; foreach(CounterProvider provider in KnownData.GetAllProviders()) { + foreach(CounterProfile counterProfile in provider.GetAllCounters()) + { + if (counterProfile.DisplayName.Length > maxNameWidth) + { + maxNameWidth = counterProfile.DisplayName.Length; + } + } knownProvidersRowNum[provider.Name] = -1; } + leftAlign = maxNameWidth + 15; } public void InitializeDisplay() @@ -103,7 +111,10 @@ namespace Microsoft.Diagnostics.Tools.Counters if (displayPosition.ContainsKey(keyName)) { (int left, int row) = displayPosition[keyName]; - int clearLength = displayLength[keyName]; + string payloadVal = payload.GetValue(); + + int clearLength = Math.Max(displayLength[keyName], payloadVal.Length); // Compute how long we need to clear out. + displayLength[keyName] = clearLength; Console.SetCursorPosition(left, row); Console.Write(new String(' ', clearLength)); @@ -116,7 +127,7 @@ namespace Microsoft.Diagnostics.Tools.Counters { Console.SetCursorPosition(left, row); } - Console.Write(payload.GetValue()); + Console.Write(payloadVal); } // Got a payload from a new counter that hasn't been written to the console yet. else diff --git a/src/Tools/dotnet-counters/KnownData.cs b/src/Tools/dotnet-counters/KnownData.cs index d94f7e766..00869e785 100644 --- a/src/Tools/dotnet-counters/KnownData.cs +++ b/src/Tools/dotnet-counters/KnownData.cs @@ -15,7 +15,6 @@ namespace Microsoft.Diagnostics.Tools.Counters private static readonly IReadOnlyDictionary _knownProviders = CreateKnownProviders().ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase); - private static IEnumerable CreateKnownProviders() { yield return new CounterProvider(