From e1b3bf962726df18b13e8b771717452946c23980 Mon Sep 17 00:00:00 2001 From: Eduardo Villalpando Mello Date: Tue, 7 Feb 2023 01:31:38 -0600 Subject: [PATCH] [LiveLogger] Add code to high priority messages (#8397) Fixes #8393 Context Currently the live logger does not log the message id's. Including the message ID is useful when searching for messages from customer reports. Changes Made When receiving BuildMessageEventArgs, the Code is now also passed to MessageNode and printed on the display. --- src/MSBuild/LiveLogger/MessageNode.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/MSBuild/LiveLogger/MessageNode.cs b/src/MSBuild/LiveLogger/MessageNode.cs index 87cac606660..7d6029e041d 100644 --- a/src/MSBuild/LiveLogger/MessageNode.cs +++ b/src/MSBuild/LiveLogger/MessageNode.cs @@ -37,18 +37,19 @@ public MessageNode(LazyFormattedBuildEventArgs args) // Get type switch (args) { - case BuildMessageEventArgs: + case BuildMessageEventArgs message: // Detect output messages var finalOutputMarker = " -> "; - int i = args.Message!.IndexOf(finalOutputMarker, StringComparison.Ordinal); + int i = message.Message!.IndexOf(finalOutputMarker, StringComparison.Ordinal); if (i > 0) { Type = MessageType.ProjectOutputMessage; - ProjectOutputExecutablePath = args.Message!.Substring(i + finalOutputMarker.Length); + ProjectOutputExecutablePath = message.Message!.Substring(i + finalOutputMarker.Length); } else { Type = MessageType.HighPriorityMessage; + Code = message.Subcategory; } break; case BuildWarningEventArgs warning: @@ -84,7 +85,7 @@ public string ToANSIString() return $"⚙️ {ANSIBuilder.Formatting.Hyperlink(ProjectOutputExecutablePath!, Path.GetDirectoryName(ProjectOutputExecutablePath)!)}"; case MessageType.HighPriorityMessage: default: - return $"ℹ️ {ANSIBuilder.Formatting.Italic(Message)}"; + return $"ℹ️ {Code}{(Code is not null ? ": " : string.Empty)} {ANSIBuilder.Formatting.Italic(Message)}"; } }