Calling item functions on the result of a transform #6687
Replies: 1 comment 1 reply
-
It doesn't look like a coincidence to me, but not really documented either, so I'm not sure it will work in future versions. ExpressionShredder.GetReferencedItemExpressions parses the chaining syntax msbuild/src/Build/Evaluation/ExpressionShredder.cs Lines 172 to 173 in 9802d43 msbuild/src/Build/Evaluation/ExpressionShredder.cs Lines 260 to 263 in 9802d43 msbuild/src/Build/Evaluation/Expander.cs Lines 1877 to 1880 in 9802d43 Expander<P, I>.ItemExpander.IntrinsicItemFunctions<S>.GetItemTransformFunction searches for the function in IntrinsicItemFunctions<S>, or if not found, uses ExecuteStringFunction, which then searches for the function in System.String. msbuild/src/Build/Evaluation/Expander.cs Lines 2076 to 2087 in 9802d43 GetItemTransformFunction also recognizes the msbuild/src/Build/Evaluation/Expander.cs Lines 2069 to 2073 in 9802d43 |
Beta Was this translation helpful? Give feedback.
-
Apparently, the following works:
I can call an item function (
ClearMetadata()
) on the result of a transform expression which looks like a string, and it works:But string functions also work:
I'd like to know if calling an item function like this is really supported, or if it just works by coincidence? The syntax looks unintuitive.
The transforms documentation doesn't mention the type of the transform result, and a quick glance on the .NET SDK revealed only one place where an item function is used that way. I didn't expect this to work, since the transform looks like it produces a string, not an item.
Also, I didn't really expect item metadata to be preserved after a transform (since I thought the transform produces a string in the first place), so I suppose that clarifying this in the docs would be nice.
Beta Was this translation helpful? Give feedback.
All reactions