Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colorize TF instead of enclosing it in brackets #8715

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/MSBuild/LiveLogger/AnsiCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,14 @@ internal static class AnsiCodes
/// Shows/restores the cursor.
/// </summary>
public const string ShowCursor = "\x1b[?25h";

public static string Colorize(string? s, TerminalColor color)
{
if (string.IsNullOrWhiteSpace(s))
{
return s ?? "";
}

return $"{CSI}{(int)color}{SetColor}{s}{SetDefaultColor}";
}
}
16 changes: 0 additions & 16 deletions src/MSBuild/LiveLogger/ITerminal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,3 @@ internal interface ITerminal : IDisposable
/// </summary>
string RenderColor(TerminalColor color, string text);
}

/// <summary>
/// Enumerates the text colors supported by <see cref="ITerminal"/>.
/// </summary>
internal enum TerminalColor
{
Black = 30,
Red = 31,
Green = 32,
Yellow = 33,
Blue = 34,
Magenta = 35,
Cyan = 36,
White = 37,
Default = 39
}
6 changes: 4 additions & 2 deletions src/MSBuild/LiveLogger/LiveLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override string ToString()
: ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ProjectBuilding_WithTF",
Indentation,
Project,
TargetFramework,
AnsiCodes.Colorize(TargetFramework, TargetFrameworkColor),
Target,
duration);
}
Expand All @@ -64,6 +64,8 @@ public override string ToString()
/// </summary>
private const string Indentation = " ";

private const TerminalColor TargetFrameworkColor = TerminalColor.Cyan;

/// <summary>
/// Protects access to state shared between the logger callbacks and the rendering thread.
/// </summary>
Expand Down Expand Up @@ -363,7 +365,7 @@ private void ProjectFinished(object sender, ProjectFinishedEventArgs e)
Terminal.Write(ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ProjectFinished_WithTF",
Indentation,
projectFile,
project.TargetFramework,
AnsiCodes.Colorize(project.TargetFramework, TargetFrameworkColor),
buildResult,
duration));
}
Expand Down
20 changes: 20 additions & 0 deletions src/MSBuild/LiveLogger/TerminalColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace Microsoft.Build.Logging.LiveLogger;

/// <summary>
/// Enumerates the text colors supported by <see cref="ITerminal"/>.
/// </summary>
internal enum TerminalColor
{
Black = 30,
Red = 31,
Green = 32,
Yellow = 33,
Blue = 34,
Magenta = 35,
Cyan = 36,
White = 37,
Default = 39
}
4 changes: 2 additions & 2 deletions src/MSBuild/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@
</comment>
</data>
<data name="ProjectFinished_WithTF" xml:space="preserve">
<value>{0}{1} [{2}] {3} ({4}s)</value>
<value>{0}{1} {2} {3} ({4}s)</value>
<comment>
Project finished summary including target framework information.
{0}: indentation - few spaces to visually indent row
Expand Down Expand Up @@ -1450,7 +1450,7 @@
</comment>
</data>
<data name="ProjectBuilding_WithTF" xml:space="preserve">
<value>{0}{1} [{2}] {3} ({4}s)</value>
<value>{0}{1} {2} {3} ({4}s)</value>
<comment>
Project building including target framework information.
{0}: indentation - few spaces to visually indent row
Expand Down
8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.