[Bug]: ExpressionShredder.GetReferencedItemNamesAndMetadata expression parser does not handle nested quotes #9940
Labels
Area: Language
Issues impacting the MSBuild programming language.
backlog
bug
Priority:3
Work that is nice to have
triaged
Issue Description
Task batching on item metadata does not handle complicated expressions like
@(a->'$(...)')
properly, leading to misdetection of metadata to batch on and/or build errors. The following minimal reproducible example illustrates the problem. I put additional explanations and analysis in MRE comments.Steps to Reproduce
Uncomment the fragment creating
d
items to see the error.Expected Behavior
ExpressionShredder.GetReferencedItemNamesAndMetadata
correctly skips the whole quoted expression and does not pick upm
as a metadata to batch on.Actual Behavior
ExpressionShredder.GetReferencedItemNamesAndMetadata
mangles the expression and picks upm
as a metadata to batch on. In the above MRE this produces a build error becausea
items do not have them
metadata.Analysis
The reason for this is that
ExpressionShredder.GetReferencedItemNamesAndMetadata
stops parsing a quoted expression at the first closing quote, which happens to be in the middle of an expression. It does not find the closing brace there, restarts skipping the leading@
, and keeps skipping leading characters of the expression until it finds and parses the%(m)
in the middle of the expression.Versions & Configurations
Verified with
msbuild
17.8.5 and withmsbuild
built from HEAD (2e6f2ff).The text was updated successfully, but these errors were encountered: