-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Remove item operation to match on specified metadata instead of just item identity #4997
Conversation
This allows users to import and map metadata between two or more item types.
This would be readily useful in #4931 |
Another interesting scenario would be when the two items have differing metadata names that need to match. Say, Remove all items from |
Oops, took the PR out of draft mode by mistake (thinking it was another PR). Sadly I can't find the option to make it a draft again. Ah well. |
… adding match on metadata tests
@cdmihai a few notes about my changes:
|
For perf testing of evaluation, here's what I do nowadays:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a partial review.
src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs
Outdated
Show resolved
Hide resolved
src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs
Outdated
Show resolved
Hide resolved
src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs
Outdated
Show resolved
Hide resolved
Thanks to @Forgind for doing some end to end testing of this along with #4931! @rainersigwald @cdmihai that PR has been rebased on top of this one so this is good to go for a final round of review. |
LGTM, pending comments (apparently I can't approve the PR since it was opened by me 😃) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking nice! Many nits but overall 👍
I can't remember--is this the one we evaluated doc impact on/drafted doc changes? Or was that another PR?
src/Build/BackEnd/Components/RequestBuilder/IntrinsicTasks/ItemGroupIntrinsicTask.cs
Outdated
Show resolved
Hide resolved
@rainersigwald I think I'm caught up with all the feedback other than this comment, let me know if I missed anything. I'm not aware of any pending docs changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only comment I had that I still feel pretty strongly about is unifying the ItemSpec methods. 90% of the logic is the same, so I really don't see why we should have duplicate code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
🥳 |
… just item identity (dotnet#4997) If you have two items `I2` and `I1`, and you want to remove all the items from `I2` that match on some metadata with items from `I1`, today you have to go through some msbuild gymnastics. It would be nice to be able to express this with just one operation: `<I2 Remove="@(I1)" MatchOnMetadata="M"/>`. Benefits: - makes MSBuild easier to understand, which may reduce bugs. - better perf, because it replaces a bunch of operations with a single one. This may not seem like much, but if this is in some sdk file that runs for every project out there, it can start getting noticeable. Specs: - simplification: if `MatchOnMetadata` is present, then the Remove attribute must only contain one item reference `@()` - simplification: `MatchOnMetadata` may specify a single metadata: `<I2 Remove="@(I1)" MatchOnMetadata="M1"/>` - if a metadata name doesn't exist in both items, then it's considered a match. Special case: if none of the metadata exist in both items, then it should not match. Co-authored-by: sfoslund <sfoslund@microsoft.com>
…5888) First commit: update a test such that it passes only if matching is case insensitive. Second commit: modify FileUtilities.ComparePathsNoThrow such that it can be made to be always case sensitive or case insensitive. Note that this was changed about seven months ago in #4997 where it had previously been a todo to make case sensitivity depend on OS but that implemented it. Third commit: fix a test that theoretically ensured case insensitivity but in practice did not, changed to care about case in the same PR. The second commit fixes #5749.
PR based on #4975. Merge that one in first. The changes for this PR are in 7aa753e
If you have two items
I2
andI1
, and you want to remove all the items fromI2
that match on some metadata with items fromI1
, today you have to go through some msbuild gymnastics. It would be nice to be able to express this with just one operation:<I2 Remove="@(I1)" MatchOnMetadata="M"/>
.Benefits:
Example which shows the gymnastics users have to go through today (second itemgroup), and what the gymnastics would be replaced with via this PR (third itemgroup)
Output using this PR:
Specs:
MatchOnMetadata
is present, then the Remove attribute must only contain one item reference@()
MatchOnMetadata
may specify a single metadata:<I2 Remove="@(I1)" MatchOnMetadata="M1"/>
Todos:
MatchOnMetadata
can have multiple semicolon delimited metadata namesMatchOnMetadata
can contain metadata which does not exist on the items. Nothing should match.MatchOnMetadata
is present, a Remove with anything other than one item reference fails the build.%()
) inMatchOnMetadata
MatchOnMetadata
is now a reserved msbuild keyword, project parsing should error if you do<I Include="foo" MatchOnMetadata="bar"/>