fixed width of trace recording to be constant (#349)
authorMarisa You <marisayou2017@u.northwestern.edu>
Wed, 19 Jun 2019 23:48:38 +0000 (16:48 -0700)
committerJosé Rivero <jorive@microsoft.com>
Wed, 19 Jun 2019 23:48:38 +0000 (16:48 -0700)
Fixes #316

The trace recording is displayed in the UI as:
Recording trace 1.733 (MB)
This fix aligns the unit of the trace recording size (MB) so that it does not move left and right when the number of digits changes.

src/Tools/dotnet-trace/CommandLine/Commands/CollectCommand.cs

index c1ad9c132b5487708c9661b680facf4645e08b6c..fadfa256f2aefb09331c749646dca8cd959a8f66 100644 (file)
@@ -217,13 +217,13 @@ namespace Microsoft.Diagnostics.Tools.Trace
         private static string GetSize(long length)
         {
             if (length > 1e9)
-                return $"{length / 1e9:0.00##} (GB)";
+                return String.Format("{0,-8} (GB)", $"{length / 1e9:0.00##}");
             else if (length > 1e6)
-                return $"{length / 1e6:0.00##} (MB)";
+                return String.Format("{0,-8} (MB)", $"{length / 1e6:0.00##}");
             else if (length > 1e3)
-                return $"{length / 1e3:0.00##} (KB)";
+                return String.Format("{0,-8} (KB)", $"{length / 1e3:0.00##}");
             else
-                return $"{length / 1.0:0.00##} (byte)";
+                return String.Format("{0,-8} (byte)", $"{length / 1.0:0.00##}");
         }
 
         public static Command CollectCommand() =>