diff --git a/src/Build.UnitTests/BackEnd/NodePackets_Tests.cs b/src/Build.UnitTests/BackEnd/NodePackets_Tests.cs index a3137f5b399..d65dea4e3a2 100644 --- a/src/Build.UnitTests/BackEnd/NodePackets_Tests.cs +++ b/src/Build.UnitTests/BackEnd/NodePackets_Tests.cs @@ -158,6 +158,8 @@ private static TaskParameterEventArgs CreateTaskParameter() items, logItemMetadata: true, DateTime.MinValue); + result.LineNumber = 30000; + result.ColumnNumber = 50; // normalize line endings as we can't rely on the line endings of NodePackets_Tests.cs Assert.Equal(@"Task Parameter: @@ -433,6 +435,8 @@ private void CompareLogMessagePackets(LogMessagePacket left, LogMessagePacket ri Assert.Equal(leftTaskParameter.Message, rightTaskParameter.Message); Assert.Equal(leftTaskParameter.BuildEventContext, rightTaskParameter.BuildEventContext); Assert.Equal(leftTaskParameter.Timestamp, rightTaskParameter.Timestamp); + Assert.Equal(leftTaskParameter.LineNumber, rightTaskParameter.LineNumber); + Assert.Equal(leftTaskParameter.ColumnNumber, rightTaskParameter.ColumnNumber); break; case LoggingEventType.TaskFinishedEvent: diff --git a/src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs b/src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs index f1b59b48e1f..0f4e8056159 100644 --- a/src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs +++ b/src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs @@ -327,11 +327,15 @@ public void RoundtripTaskParameterEventArgs() new TaskItemData("ItemSpec2", Enumerable.Range(1,3).ToDictionary(i => i.ToString(), i => i.ToString() + "value")) }; var args = new TaskParameterEventArgs(TaskParameterMessageKind.TaskOutput, "ItemName", items, true, DateTime.MinValue); + args.LineNumber = 265; + args.ColumnNumber = 6; Roundtrip(args, e => e.Kind.ToString(), e => e.ItemType, e => e.LogItemMetadata.ToString(), + e => e.LineNumber.ToString(), + e => e.ColumnNumber.ToString(), e => TranslationHelpers.GetItemsString(e.Items)); } diff --git a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs index 66195775b22..109cb49b9bf 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs @@ -218,7 +218,8 @@ private void ExecuteAdd(ProjectItemGroupTaskItemInstance child, ItemBucket bucke TaskParameterMessageKind.AddItem, child.ItemType, itemsToAdd, - logItemMetadata: true); + logItemMetadata: true, + child.Location); } // Now add the items we created to the lookup. @@ -261,7 +262,8 @@ private void ExecuteRemove(ProjectItemGroupTaskItemInstance child, ItemBucket bu TaskParameterMessageKind.RemoveItem, child.ItemType, itemsToRemove, - logItemMetadata: true); + logItemMetadata: true, + child.Location); } bucket.Lookup.RemoveItems(itemsToRemove); diff --git a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs index 4f7440b61e3..b672732ee39 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs @@ -252,7 +252,8 @@ internal static void LogTaskParameter( TaskParameterMessageKind messageKind, string itemType, IList items, - bool logItemMetadata) + bool logItemMetadata, + IElementLocation location = null) { var args = CreateTaskParameterEventArgs( loggingContext.BuildEventContext, @@ -260,7 +261,10 @@ internal static void LogTaskParameter( itemType, items, logItemMetadata, - DateTime.UtcNow); + DateTime.UtcNow, + location?.Line ?? 0, + location?.Column ?? 0); + loggingContext.LogBuildEvent(args); } @@ -270,7 +274,9 @@ internal static TaskParameterEventArgs CreateTaskParameterEventArgs( string itemType, IList items, bool logItemMetadata, - DateTime timestamp) + DateTime timestamp, + int line = 0, + int column = 0) { // Only create a snapshot of items if we use AppDomains #if FEATURE_APPDOMAIN @@ -284,6 +290,8 @@ internal static TaskParameterEventArgs CreateTaskParameterEventArgs( logItemMetadata, timestamp); args.BuildEventContext = buildEventContext; + args.LineNumber = line; + args.ColumnNumber = column; return args; } diff --git a/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs b/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs index 47c1f6d8306..27d6706108c 100644 --- a/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs +++ b/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs @@ -658,7 +658,9 @@ private BuildEventArgs ReadTaskParameterEventArgs() itemType, items, logItemMetadata: true, - fields.Timestamp); + fields.Timestamp, + fields.LineNumber, + fields.ColumnNumber); e.ProjectFile = fields.ProjectFile; return e; } diff --git a/src/Framework/BuildMessageEventArgs.cs b/src/Framework/BuildMessageEventArgs.cs index 23282a1db87..79d8a5177a9 100644 --- a/src/Framework/BuildMessageEventArgs.cs +++ b/src/Framework/BuildMessageEventArgs.cs @@ -322,12 +322,20 @@ internal override void CreateFromStream(BinaryReader reader, int version) /// /// Line number of interest in associated file. /// - public int LineNumber => lineNumber; + public int LineNumber + { + get => lineNumber; + internal set => lineNumber = value; + } /// /// Column number of interest in associated file. /// - public int ColumnNumber => columnNumber; + public int ColumnNumber + { + get => columnNumber; + internal set => columnNumber = value; + } /// /// Ending line number of interest in associated file. diff --git a/src/Framework/TaskParameterEventArgs.cs b/src/Framework/TaskParameterEventArgs.cs index b4efc953e84..1ca1a55f7ad 100644 --- a/src/Framework/TaskParameterEventArgs.cs +++ b/src/Framework/TaskParameterEventArgs.cs @@ -87,6 +87,8 @@ internal override void CreateFromStream(BinaryReader reader, int version) BuildEventContext = reader.ReadOptionalBuildEventContext(); Kind = (TaskParameterMessageKind)reader.Read7BitEncodedInt(); ItemType = reader.ReadOptionalString(); + LineNumber = reader.Read7BitEncodedInt(); + ColumnNumber = reader.Read7BitEncodedInt(); Items = ReadItems(reader); } @@ -134,6 +136,8 @@ internal override void WriteToStream(BinaryWriter writer) writer.WriteOptionalBuildEventContext(BuildEventContext); writer.Write7BitEncodedInt((int)Kind); writer.WriteOptionalString(ItemType); + writer.Write7BitEncodedInt(LineNumber); + writer.Write7BitEncodedInt(ColumnNumber); WriteItems(writer, Items); }