Skip to content

Commit 0d310de

Browse files
Fix item update evaluation when path contains parenthesis and add test coverage (#11293)
1 parent d3297e6 commit 0d310de

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/Build.UnitTests/Evaluation/Evaluator_Tests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,41 @@ public void VerifyLoadingImportScenarios(string importParameter, bool shouldSucc
9696
}
9797
}
9898

99+
[Theory]
100+
[InlineData("(test")]
101+
[InlineData("@@@test")]
102+
[InlineData(@")(!!test")]
103+
public void VerifyItemsUpdateIsHandledForAnyProjectPath(string projectPathCandidate)
104+
{
105+
using (TestEnvironment env = TestEnvironment.Create())
106+
{
107+
TransientTestFolder projDirectory = env.CreateFolder(Path.Combine(env.CreateNewTempPath().TempPath, projectPathCandidate), createFolder: true);
108+
TransientTestFile projectFile = env.CreateFile(projDirectory, "project.proj", @"
109+
<Project>
110+
111+
<ItemGroup>
112+
<ItemCheck Include=""Test"" />
113+
</ItemGroup>
114+
115+
<ItemGroup>
116+
<ItemCheck Update=""Test""
117+
NewTestLabels=""Dummy"" />
118+
</ItemGroup>
119+
120+
<Target Name=""MyTarget"">
121+
<Message Text=""ItemCheck updated metadata value: @(ItemCheck->Metadata('NewTestLabels'))"" />
122+
</Target>
123+
</Project>
124+
");
125+
Project project = new(projectFile.Path);
126+
MockLogger logger = new();
127+
var result = project.Build(logger);
128+
129+
result.ShouldBeTrue();
130+
project.AllEvaluatedItems.Where(ei => ei.ItemType == "ItemCheck" && ei.Metadata.Any(m => m.EvaluatedValue == "Dummy")).ShouldNotBeEmpty();
131+
}
132+
}
133+
99134
// Some of these are also tested elsewhere, but this consolidates related tests in one spot.
100135
public static IEnumerable<object[]> ImportLoadingScenarioTestData
101136
{

src/Build/Evaluation/LazyItemEvaluator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ private static OrderedItemDataCollection.Builder ComputeItems(LazyItemList lazyI
384384
break;
385385
}
386386

387-
string fullPath = FileUtilities.GetFullPath(frag.TextFragment, frag.ProjectDirectory);
387+
string fullPath = FileUtilities.NormalizePathForComparisonNoThrow(frag.TextFragment, frag.ProjectDirectory);
388388
if (itemsWithNoWildcards.ContainsKey(fullPath))
389389
{
390390
// Another update will already happen on this path. Make that happen before evaluating this one.

0 commit comments

Comments
 (0)