diff --git a/documentation/wiki/ChangeWaves.md b/documentation/wiki/ChangeWaves.md index 7744d96a090..c30d03cea0f 100644 --- a/documentation/wiki/ChangeWaves.md +++ b/documentation/wiki/ChangeWaves.md @@ -27,6 +27,7 @@ A wave of features is set to "rotate out" (i.e. become standard functionality) t - [Log TaskParameterEvent for scalar parameters](https://github.com/dotnet/msbuild/pull/9908) - [Convert.ToString during a property evaluation uses the InvariantCulture for all types](https://github.com/dotnet/msbuild/pull/9874) - [Fix oversharing of build results in ResultsCache](https://github.com/dotnet/msbuild/pull/9987) +- [Add ParameterName and PropertyName to TaskParameterEventArgs](https://github.com/dotnet/msbuild/pull/10130) ### 17.10 - [AppDomain configuration is serialized without using BinFmt](https://github.com/dotnet/msbuild/pull/9320) - feature can be opted out only if [BinaryFormatter](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.formatters.binary.binaryformatter) is allowed at runtime by editing `MSBuild.runtimeconfig.json` diff --git a/src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs b/src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs index cb60a9f2d42..bd03a54d29a 100644 --- a/src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs +++ b/src/Build.UnitTests/BuildEventArgsSerialization_Tests.cs @@ -650,12 +650,14 @@ public void RoundtripTaskParameterEventArgs() new TaskItemData("ItemSpec1", null), 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); + var args = new TaskParameterEventArgs(TaskParameterMessageKind.TaskOutput, "ParameterName1", "PropertyName1", "ItemName1", items, true, DateTime.MinValue); args.LineNumber = 265; args.ColumnNumber = 6; Roundtrip(args, e => e.Kind.ToString(), + e => e.ParameterName, + e => e.PropertyName, e => e.ItemType, e => e.LogItemMetadata.ToString(), e => e.LineNumber.ToString(), diff --git a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs index 08cc3e9f5e0..5335ec2f45c 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs @@ -225,6 +225,8 @@ private void ExecuteAdd(ProjectItemGroupTaskItemInstance child, ItemBucket bucke ItemGroupLoggingHelper.LogTaskParameter( LoggingContext, TaskParameterMessageKind.AddItem, + parameterName: null, + propertyName: null, child.ItemType, itemsToAdd, logItemMetadata: true, @@ -269,6 +271,8 @@ private void ExecuteRemove(ProjectItemGroupTaskItemInstance child, ItemBucket bu ItemGroupLoggingHelper.LogTaskParameter( LoggingContext, TaskParameterMessageKind.RemoveItem, + parameterName: null, + propertyName: null, child.ItemType, itemsToRemove, logItemMetadata: true, diff --git a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs index df32111f095..deae62102f0 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupLoggingHelper.cs @@ -10,6 +10,7 @@ #endif using Microsoft.Build.BackEnd.Logging; using Microsoft.Build.Collections; +using Microsoft.Build.Execution; using Microsoft.Build.Framework; using Microsoft.Build.Shared; @@ -35,6 +36,7 @@ internal static class ItemGroupLoggingHelper internal static string ItemGroupIncludeLogMessagePrefix = ResourceUtilities.GetResourceString("ItemGroupIncludeLogMessagePrefix"); internal static string ItemGroupRemoveLogMessage = ResourceUtilities.GetResourceString("ItemGroupRemoveLogMessage"); internal static string OutputItemParameterMessagePrefix = ResourceUtilities.GetResourceString("OutputItemParameterMessagePrefix"); + internal static string OutputPropertyLogMessagePrefix = ResourceUtilities.GetResourceString("OutputPropertyLogMessagePrefix"); internal static string TaskParameterPrefix = ResourceUtilities.GetResourceString("TaskParameterPrefix"); internal static string SkipTargetUpToDateInputs = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("SkipTargetUpToDateInputs", string.Empty); internal static string SkipTargetUpToDateOutputs = ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("SkipTargetUpToDateOutputs", string.Empty); @@ -255,6 +257,8 @@ private static void AppendStringFromParameterValue(ReuseableStringBuilder sb, ob internal static void LogTaskParameter( LoggingContext loggingContext, TaskParameterMessageKind messageKind, + string parameterName, + string propertyName, string itemType, IList items, bool logItemMetadata, @@ -263,6 +267,8 @@ internal static void LogTaskParameter( var args = CreateTaskParameterEventArgs( loggingContext.BuildEventContext, messageKind, + parameterName, + propertyName, itemType, items, logItemMetadata, @@ -276,6 +282,8 @@ internal static void LogTaskParameter( internal static TaskParameterEventArgs CreateTaskParameterEventArgs( BuildEventContext buildEventContext, TaskParameterMessageKind messageKind, + string parameterName, + string propertyName, string itemType, IList items, bool logItemMetadata, @@ -290,6 +298,8 @@ internal static TaskParameterEventArgs CreateTaskParameterEventArgs( var args = new TaskParameterEventArgs( messageKind, + parameterName, + propertyName, itemType, items, logItemMetadata, @@ -355,26 +365,23 @@ private static void CreateItemsSnapshot(ref IList items) #endif internal static string GetTaskParameterText(TaskParameterEventArgs args) - => GetTaskParameterText(args.Kind, args.ItemType, args.Items, args.LogItemMetadata); - - internal static string GetTaskParameterText(TaskParameterMessageKind messageKind, string itemType, IList items, bool logItemMetadata) { - var resourceText = messageKind switch + var resourceText = args.Kind switch { TaskParameterMessageKind.AddItem => ItemGroupIncludeLogMessagePrefix, TaskParameterMessageKind.RemoveItem => ItemGroupRemoveLogMessage, TaskParameterMessageKind.TaskInput => TaskParameterPrefix, - TaskParameterMessageKind.TaskOutput => OutputItemParameterMessagePrefix, + TaskParameterMessageKind.TaskOutput => args.PropertyName is null ? OutputItemParameterMessagePrefix : OutputPropertyLogMessagePrefix, TaskParameterMessageKind.SkippedTargetInputs => SkipTargetUpToDateInputs, TaskParameterMessageKind.SkippedTargetOutputs => SkipTargetUpToDateOutputs, - _ => throw new NotImplementedException($"Unsupported {nameof(TaskParameterMessageKind)} value: {messageKind}") + _ => throw new NotImplementedException($"Unsupported {nameof(TaskParameterMessageKind)} value: {args.Kind}") }; var itemGroupText = GetParameterText( resourceText, - itemType, - items, - logItemMetadata); + args.PropertyName ?? args.ItemType, + args.Items, + args.LogItemMetadata); return itemGroupText; } } diff --git a/src/Build/BackEnd/Components/RequestBuilder/TargetUpToDateChecker.cs b/src/Build/BackEnd/Components/RequestBuilder/TargetUpToDateChecker.cs index 4b40715d67b..9940131c9e9 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/TargetUpToDateChecker.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/TargetUpToDateChecker.cs @@ -368,6 +368,8 @@ private void LogUniqueInputsAndOutputs() var args = ItemGroupLoggingHelper.CreateTaskParameterEventArgs( _buildEventContext, TaskParameterMessageKind.SkippedTargetInputs, + parameterName: null, + propertyName: null, itemType: null, _uniqueTargetInputs.Keys.ToArray(), logItemMetadata: false, @@ -377,6 +379,8 @@ private void LogUniqueInputsAndOutputs() args = ItemGroupLoggingHelper.CreateTaskParameterEventArgs( _buildEventContext, TaskParameterMessageKind.SkippedTargetOutputs, + parameterName: null, + propertyName: null, itemType: null, _uniqueTargetOutputs.Keys.ToArray(), logItemMetadata: false, diff --git a/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs b/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs index fdff89eb618..c1b49647f8e 100644 --- a/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs +++ b/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs @@ -1317,10 +1317,14 @@ private bool InternalSetTaskParameter( // Structured logging for all parameters that have logging enabled and are not empty lists. if (parameterValueAsList?.Count > 0 || (parameterValueAsList == null && !legacyBehavior)) { + // Note: We're setting TaskParameterEventArgs.ItemType to parameter name for backward compatibility with + // older loggers and binlog viewers. ItemGroupLoggingHelper.LogTaskParameter( _taskLoggingContext, TaskParameterMessageKind.TaskInput, - parameter.Name, + parameterName: parameter.Name, + propertyName: null, + itemType: parameter.Name, parameterValueAsList ?? new object[] { parameterValue }, parameter.LogItemMetadata); } @@ -1429,7 +1433,9 @@ static IEnumerable> EnumerateMetadata(IDictionary c ItemGroupLoggingHelper.LogTaskParameter( _taskLoggingContext, TaskParameterMessageKind.TaskOutput, - outputTargetName, + parameterName: parameter.Name, + propertyName: null, + itemType: outputTargetName, outputs, parameter.LogItemMetadata); } @@ -1470,7 +1476,23 @@ static IEnumerable> EnumerateMetadata(IDictionary c var outputString = joinedOutputs.ToString(); if (LogTaskInputs && !_taskLoggingContext.LoggingService.OnlyLogCriticalEvents) { - _taskLoggingContext.LogComment(MessageImportance.Low, "OutputPropertyLogMessage", outputTargetName, outputString); + if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_12)) + { + // Note: We're setting TaskParameterEventArgs.ItemType to property name for backward compatibility with + // older loggers and binlog viewers. + ItemGroupLoggingHelper.LogTaskParameter( + _taskLoggingContext, + TaskParameterMessageKind.TaskOutput, + parameterName: parameter.Name, + propertyName: outputTargetName, + itemType: outputTargetName, + new object[] { outputString }, + parameter.LogItemMetadata); + } + else + { + _taskLoggingContext.LogComment(MessageImportance.Low, "OutputPropertyLogMessage", outputTargetName, outputString); + } } _batchBucket.Lookup.SetProperty(ProjectPropertyInstance.Create(outputTargetName, outputString, parameterLocation, _projectInstance.IsImmutable)); @@ -1505,7 +1527,9 @@ private void GatherArrayStringAndValueOutputs(bool outputTargetIsItem, string ou ItemGroupLoggingHelper.LogTaskParameter( _taskLoggingContext, TaskParameterMessageKind.TaskOutput, - outputTargetName, + parameterName: parameter.Name, + propertyName: null, + itemType: outputTargetName, outputs, parameter.LogItemMetadata); } @@ -1539,7 +1563,23 @@ private void GatherArrayStringAndValueOutputs(bool outputTargetIsItem, string ou var outputString = joinedOutputs.ToString(); if (LogTaskInputs && !_taskLoggingContext.LoggingService.OnlyLogCriticalEvents) { - _taskLoggingContext.LogComment(MessageImportance.Low, "OutputPropertyLogMessage", outputTargetName, outputString); + if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_12)) + { + // Note: We're setting TaskParameterEventArgs.ItemType to property name for backward compatibility with + // older loggers and binlog viewers. + ItemGroupLoggingHelper.LogTaskParameter( + _taskLoggingContext, + TaskParameterMessageKind.TaskOutput, + parameterName: parameter.Name, + propertyName: outputTargetName, + itemType: outputTargetName, + new object[] { outputString }, + parameter.LogItemMetadata); + } + else + { + _taskLoggingContext.LogComment(MessageImportance.Low, "OutputPropertyLogMessage", outputTargetName, outputString); + } } _batchBucket.Lookup.SetProperty(ProjectPropertyInstance.Create(outputTargetName, outputString, parameterLocation, _projectInstance.IsImmutable)); diff --git a/src/Build/BuildCheck/Infrastructure/BuildEventsProcessor.cs b/src/Build/BuildCheck/Infrastructure/BuildEventsProcessor.cs index cf2bae57bad..aa804067b60 100644 --- a/src/Build/BuildCheck/Infrastructure/BuildEventsProcessor.cs +++ b/src/Build/BuildCheck/Infrastructure/BuildEventsProcessor.cs @@ -151,7 +151,7 @@ internal void ProcessTaskParameterEventArgs( { // Add the parameter name and value to the matching entry in _tasksBeingExecuted. Parameters come typed as IList // but it's more natural to pass them as scalar values so we unwrap one-element lists. - string parameterName = taskParameterEventArgs.ItemType; + string parameterName = taskParameterEventArgs.ParameterName; object? parameterValue = taskParameterEventArgs.Items?.Count switch { 1 => taskParameterEventArgs.Items[0], diff --git a/src/Build/Logging/BinaryLogger/BinaryLogger.cs b/src/Build/Logging/BinaryLogger/BinaryLogger.cs index a7b005a1925..d4c37461938 100644 --- a/src/Build/Logging/BinaryLogger/BinaryLogger.cs +++ b/src/Build/Logging/BinaryLogger/BinaryLogger.cs @@ -71,6 +71,8 @@ public sealed class BinaryLogger : ILogger // - GeneratedFileUsedEventArgs exposed for brief period of time (so let's continue with 20) // version 20: // - TaskStartedEventArgs: Added TaskAssemblyLocation property + // version 21: + // - TaskParameterEventArgs: Added ParameterName and PropertyName properties // This should be never changed. // The minimum version of the binary log reader that can read log of above version. @@ -78,7 +80,7 @@ public sealed class BinaryLogger : ILogger // The current version of the binary log representation. // Changes with each update of the binary log format. - internal const int FileFormatVersion = 20; + internal const int FileFormatVersion = 21; // The minimum version of the binary log reader that can read log of above version. // This should be changed only when the binary log format is changed in a way that would prevent it from being diff --git a/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs b/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs index 03ce7bed76c..358c410265f 100644 --- a/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs +++ b/src/Build/Logging/BinaryLogger/BuildEventArgsReader.cs @@ -1022,10 +1022,15 @@ private BuildEventArgs ReadTaskParameterEventArgs() var kind = (TaskParameterMessageKind)ReadInt32(); var itemType = ReadDeduplicatedString(); var items = ReadTaskItemList() as IList; + var (parameterName, propertyName) = _fileFormatVersion >= 21 + ? (ReadDeduplicatedString(), ReadDeduplicatedString()) + : (null, null); var e = ItemGroupLoggingHelper.CreateTaskParameterEventArgs( fields.BuildEventContext, kind, + parameterName, + propertyName, itemType, items, logItemMetadata: true, diff --git a/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs b/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs index 0c5c82846b3..a9a734b1638 100644 --- a/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs +++ b/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs @@ -571,6 +571,8 @@ private BinaryLogRecordKind Write(TaskParameterEventArgs e) Write((int)e.Kind); WriteDeduplicatedString(e.ItemType); WriteTaskItemList(e.Items, e.LogItemMetadata); + WriteDeduplicatedString(e.ParameterName); + WriteDeduplicatedString(e.PropertyName); if (e.Kind == TaskParameterMessageKind.AddItem || e.Kind == TaskParameterMessageKind.TaskOutput) { diff --git a/src/Build/Resources/Strings.resx b/src/Build/Resources/Strings.resx index 62bcd2464c3..32d308cacbc 100644 --- a/src/Build/Resources/Strings.resx +++ b/src/Build/Resources/Strings.resx @@ -1102,6 +1102,9 @@ Output Item(s): + + Output Property: + Output Property: {0}={1} diff --git a/src/Build/Resources/xlf/Strings.cs.xlf b/src/Build/Resources/xlf/Strings.cs.xlf index cce18578077..01111d770e3 100644 --- a/src/Build/Resources/xlf/Strings.cs.xlf +++ b/src/Build/Resources/xlf/Strings.cs.xlf @@ -393,6 +393,11 @@ Metoda {0} se nedá zavolat s kolekcí, která obsahuje prázdné cílové názvy nebo názvy null. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} Vytvořilo se přepsání pomocí úlohy: {0} v {1} diff --git a/src/Build/Resources/xlf/Strings.de.xlf b/src/Build/Resources/xlf/Strings.de.xlf index d1aa6cbc8ec..d1b394878f2 100644 --- a/src/Build/Resources/xlf/Strings.de.xlf +++ b/src/Build/Resources/xlf/Strings.de.xlf @@ -393,6 +393,11 @@ Die Methode "{0}" kann nicht mit einer Sammlung aufgerufen werden, die NULL oder leere Zielnamen enthält. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} Außerkraftsetzung mit Task erstellt: {0} bei {1} diff --git a/src/Build/Resources/xlf/Strings.es.xlf b/src/Build/Resources/xlf/Strings.es.xlf index 90914c626ff..1fca3294b7c 100644 --- a/src/Build/Resources/xlf/Strings.es.xlf +++ b/src/Build/Resources/xlf/Strings.es.xlf @@ -393,6 +393,11 @@ No se puede llamar al método {0} con una colección que contiene nombres de destino nulos o vacíos. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} Se creó una invalidación mediante la tarea: {0} en {1} diff --git a/src/Build/Resources/xlf/Strings.fr.xlf b/src/Build/Resources/xlf/Strings.fr.xlf index 09bad2f7e80..f5808cbd2be 100644 --- a/src/Build/Resources/xlf/Strings.fr.xlf +++ b/src/Build/Resources/xlf/Strings.fr.xlf @@ -393,6 +393,11 @@ Impossible d'appeler la méthode {0} avec une collection contenant des noms de cibles qui ont une valeur null ou qui sont vides. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} Remplacement créé à l’aide de la tâche : {0} au {1} diff --git a/src/Build/Resources/xlf/Strings.it.xlf b/src/Build/Resources/xlf/Strings.it.xlf index 8bf8eec2d8d..67f13f70d43 100644 --- a/src/Build/Resources/xlf/Strings.it.xlf +++ b/src/Build/Resources/xlf/Strings.it.xlf @@ -393,6 +393,11 @@ Non è possibile chiamare il metodo {0} con una raccolta contenente nomi di destinazione Null o vuoti. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} È stata creata una sostituzione con l'attività: {0} in {1} diff --git a/src/Build/Resources/xlf/Strings.ja.xlf b/src/Build/Resources/xlf/Strings.ja.xlf index fbdc02d0590..c6fe789da0d 100644 --- a/src/Build/Resources/xlf/Strings.ja.xlf +++ b/src/Build/Resources/xlf/Strings.ja.xlf @@ -393,6 +393,11 @@ Null または空のターゲット名を含むコレクションを指定してメソッド {0} を呼び出すことはできません。 + + Output Property: + Output Property: + + Created an override using task: {0} at {1} タスクを使用してオーバーライドを作成しました: {1} の {0} diff --git a/src/Build/Resources/xlf/Strings.ko.xlf b/src/Build/Resources/xlf/Strings.ko.xlf index dc7c94b9d2f..cdac9492ab1 100644 --- a/src/Build/Resources/xlf/Strings.ko.xlf +++ b/src/Build/Resources/xlf/Strings.ko.xlf @@ -393,6 +393,11 @@ null 또는 빈 대상 이름을 포함하는 컬렉션을 사용하여 {0} 메서드를 호출할 수 없습니다. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} 다음 작업을 사용하여 재정의를 만들었습니다. {1}의 {0} diff --git a/src/Build/Resources/xlf/Strings.pl.xlf b/src/Build/Resources/xlf/Strings.pl.xlf index d8d09cb9c63..27befb97cf5 100644 --- a/src/Build/Resources/xlf/Strings.pl.xlf +++ b/src/Build/Resources/xlf/Strings.pl.xlf @@ -393,6 +393,11 @@ Metody {0} nie można wywołać przy użyciu kolekcji zawierającej nazwy docelowe o wartości null lub puste. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} Utworzono zastąpienie przy użyciu zadania: {0} o {1} diff --git a/src/Build/Resources/xlf/Strings.pt-BR.xlf b/src/Build/Resources/xlf/Strings.pt-BR.xlf index 389700299cc..cb83c722ef8 100644 --- a/src/Build/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Build/Resources/xlf/Strings.pt-BR.xlf @@ -393,6 +393,11 @@ O método {0} não pode ser chamado com uma coleção que contém nomes de destino nulos ou vazios. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} Criou uma substituição usando a tarefa: {0} em {1} diff --git a/src/Build/Resources/xlf/Strings.ru.xlf b/src/Build/Resources/xlf/Strings.ru.xlf index 5c04d7194eb..b9d85985c8b 100644 --- a/src/Build/Resources/xlf/Strings.ru.xlf +++ b/src/Build/Resources/xlf/Strings.ru.xlf @@ -393,6 +393,11 @@ Метод {0} не может быть вызван с коллекцией, содержащей целевые имена, которые пусты или равны NULL. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} Создано переопределение с помощью задачи {0} в {1} diff --git a/src/Build/Resources/xlf/Strings.tr.xlf b/src/Build/Resources/xlf/Strings.tr.xlf index a9dc8a0e065..2fe1897b791 100644 --- a/src/Build/Resources/xlf/Strings.tr.xlf +++ b/src/Build/Resources/xlf/Strings.tr.xlf @@ -393,6 +393,11 @@ {0} metosu null veya boş hedef adları içeren bir koleksiyonla çağrılamaz. + + Output Property: + Output Property: + + Created an override using task: {0} at {1} {0} görevi kullanılarak geçersiz kılma işlemi oluşturuldu, saat: {1} diff --git a/src/Build/Resources/xlf/Strings.zh-Hans.xlf b/src/Build/Resources/xlf/Strings.zh-Hans.xlf index 868e495f52b..d4834faab5a 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hans.xlf @@ -393,6 +393,11 @@ 无法使用包含 null 或空目标名称的集合调用方法 {0}。 + + Output Property: + Output Property: + + Created an override using task: {0} at {1} 已使用任务创建替代: {0} 位于 {1} diff --git a/src/Build/Resources/xlf/Strings.zh-Hant.xlf b/src/Build/Resources/xlf/Strings.zh-Hant.xlf index b31a9ad4517..3735847ae07 100644 --- a/src/Build/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Build/Resources/xlf/Strings.zh-Hant.xlf @@ -393,6 +393,11 @@ 無法使用內含 null 或空白目標名稱的集合呼叫方法 {0}。 + + Output Property: + Output Property: + + Created an override using task: {0} at {1} 已使用下列工作建立覆寫: 於 {1} 的 {0} diff --git a/src/BuildCheck.UnitTests/TaskInvocationAnalysisDataTests.cs b/src/BuildCheck.UnitTests/TaskInvocationAnalysisDataTests.cs index bd93ddcf927..67d7cf784ef 100644 --- a/src/BuildCheck.UnitTests/TaskInvocationAnalysisDataTests.cs +++ b/src/BuildCheck.UnitTests/TaskInvocationAnalysisDataTests.cs @@ -114,15 +114,17 @@ public void ReportsSimpleTaskParameters() data.Parameters["Text"].Value.ShouldBe("Hello"); } - [Fact] - public void ReportsComplexTaskParameters() + [Theory] + [InlineData("")] + [InlineData("")] + public void ReportsComplexTaskParameters(string outputElement) { - BuildProject(""" + BuildProject($""" - + {outputElement} """); @@ -139,9 +141,8 @@ public void ReportsComplexTaskParameters() listValue[1]!.ShouldBeAssignableTo(typeof(ITaskItem)); ((ITaskItem)listValue[0]!).ItemSpec.ShouldBe("item1"); ((ITaskItem)listValue[1]!).ItemSpec.ShouldBe("item2"); - - // The name of the parameter would ideally be "CombinedPaths" but we don't seem to be currently logging it. - data.Parameters["OutputDirectories"].IsOutput.ShouldBe(true); + data.Parameters["CombinedPaths"].IsOutput.ShouldBe(true); + data.Parameters["CombinedPaths"].Value.ShouldNotBeNull(); } } } diff --git a/src/Framework/TaskParameterEventArgs.cs b/src/Framework/TaskParameterEventArgs.cs index 7aa294f828c..8dcf97730c7 100644 --- a/src/Framework/TaskParameterEventArgs.cs +++ b/src/Framework/TaskParameterEventArgs.cs @@ -34,6 +34,8 @@ public class TaskParameterEventArgs : BuildMessageEventArgs /// public TaskParameterEventArgs( TaskParameterMessageKind kind, + string parameterName, + string propertyName, string itemType, IList items, bool logItemMetadata, @@ -41,14 +43,57 @@ public TaskParameterEventArgs( : base(null, null, null, MessageImportance.Low, eventTimestamp) { Kind = kind; + ParameterName = parameterName; + PropertyName = propertyName; ItemType = itemType; Items = items; LogItemMetadata = logItemMetadata; } + /// + /// Creates an instance of this class for the given task parameter. + /// + public TaskParameterEventArgs( + TaskParameterMessageKind kind, + string itemType, + IList items, + bool logItemMetadata, + DateTime eventTimestamp) + : this(kind, parameterName: null, propertyName: null, itemType, items, logItemMetadata, eventTimestamp) + { } + + /// + /// The kind of event represented by this instance. + /// public TaskParameterMessageKind Kind { get; private set; } + + /// + /// The name of the parameter if is or , + /// null otherwise. + /// + public string ParameterName { get; private set; } + + /// + /// The name of the property if is and the task output + /// is assigned to a property, null otherwise. + /// + public string PropertyName { get; private set; } + + /// + /// The name of the item being manipulated, e.g. "Compile" if this is an item operation. If this object represents a task input, this property should be set + /// to the same value as for backward compatibility. Similarly, if this object represents a task output assigned to a property, + /// this should be set to the same value as for backward compatibility. + /// public string ItemType { get; private set; } + + /// + /// The values being manipulated (added, removed, passed to/from task). + /// public IList Items { get; private set; } + + /// + /// True if the string should include metadata. + /// public bool LogItemMetadata { get; private set; } /// @@ -85,6 +130,8 @@ internal override void CreateFromStream(BinaryReader reader, int version) RawTimestamp = reader.ReadTimestamp(); BuildEventContext = reader.ReadOptionalBuildEventContext(); Kind = (TaskParameterMessageKind)reader.Read7BitEncodedInt(); + ParameterName = reader.ReadOptionalString(); + PropertyName = reader.ReadOptionalString(); ItemType = reader.ReadOptionalString(); LineNumber = reader.Read7BitEncodedInt(); ColumnNumber = reader.Read7BitEncodedInt(); @@ -134,6 +181,8 @@ internal override void WriteToStream(BinaryWriter writer) writer.WriteTimestamp(RawTimestamp); writer.WriteOptionalBuildEventContext(BuildEventContext); writer.Write7BitEncodedInt((int)Kind); + writer.WriteOptionalString(ParameterName); + writer.WriteOptionalString(PropertyName); writer.WriteOptionalString(ItemType); writer.Write7BitEncodedInt(LineNumber); writer.Write7BitEncodedInt(ColumnNumber);