Last active
December 28, 2015 15:39
-
-
Save JayBazuzi/7523672 to your computer and use it in GitHub Desktop.
test for logging MSBuild items items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void LogProperty(PropertyInfo propertyInfo) | |
{ | |
string name = propertyInfo.Name; | |
var value = propertyInfo.GetValue(this); | |
if (value is ITaskItem[]) | |
{ | |
LogTaskItems(value as ITaskItem[], name); | |
} | |
else | |
{ | |
Log.LogMessage(MessageImportance.High, " {0} = {1}", name, value); | |
} | |
} | |
private void LogTaskItems(ITaskItem[] taskItems, string itemGroup) | |
{ | |
Log.LogMessage(MessageImportance.High, " {0} =", itemGroup); | |
foreach (var item in taskItems) | |
{ | |
LogTaskItem(item); | |
} | |
} | |
private void LogTaskItem(ITaskItem item) | |
{ | |
Log.LogMessage(MessageImportance.High, " {0}", item.ItemSpec); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void TaskItemsGetLogged() | |
{ | |
var buildTarget = CreateBuildTarget(); | |
var itemGroup = buildTarget.AddItemGroup(); | |
itemGroup.AddItem("Foo", "a"); | |
itemGroup.AddItem("Foo", "b"); | |
buildTarget.AddTask<TaskWithItems>().SetParameter("Foo", "@(Foo)"); | |
const string expected = @"Inputs: | |
Foo = | |
a | |
b | |
"; | |
AssertTargetOutput(expected, buildTarget); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment