Skip to content
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

Any have metadata value when empty Fixes #5113 #8603

Merged
merged 3 commits into from
Mar 28, 2023

Conversation

Forgind
Copy link
Member

@Forgind Forgind commented Mar 27, 2023

Fixes #5113

Context

AnyHaveMetadataValue returns empty when the itemgroup is empty, which doesn't make sense and doesn't match our documentation. This changes it to return false in that case.

Changes Made

If we see the function we're evaluating is AnyHaveMetadataValue, don't skip out early.

Testing

Made a unit test

Notes

Previously, when we saw the Item was empty, we'd jump out early. Fortunately, we already special-cased Count, and it turns out we can do the same with AnyHaveMetadataValue.
@@ -1947,7 +1947,8 @@ private static class ItemExpander
if (itemsOfType.Count == 0)
{
// .. but only if there isn't a function "Count()", since that will want to return something (zero) for an empty list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand comment please

@rainersigwald rainersigwald added this to the VS 17.6 milestone Mar 28, 2023
@Forgind Forgind added the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label Mar 28, 2023
Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thought about this again. I can't see any reason that this would break someone but it's an observable change. I think it should be in the 17.6 changewave.

@Forgind Forgind force-pushed the AnyHaveMetadataValue-when-empty branch from 345016e to e6f221a Compare March 28, 2023 18:56
@Forgind Forgind removed the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label Mar 28, 2023
@Forgind
Copy link
Member Author

Forgind commented Mar 28, 2023

Put it in the change wave. Scenarios I can think of where someone would be broken are a bit ridiculous like trying to use it as IsEmpty:
@(PossiblyEmptyItem->AnyHaveMetadataValue('m', 'v')) == ''

I really hope no one does that.

I skipped adding ChangeWave-specific tests; hopefully you're ok with that 🙂

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a very long time to check this logic!

@Forgind Forgind added the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label Mar 28, 2023
@rainersigwald rainersigwald merged commit da690cf into dotnet:main Mar 28, 2023
8 checks passed
Forgind added a commit to Forgind/sdk that referenced this pull request Apr 5, 2023
AnyHaveMetadataValue returns an empty string if the item is empty. This is a bug fixed in dotnet/msbuild#8603, but this branch does not yet have that change. This workaround should be resilient whether or not the fix is in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AnyHaveMetadataValue returns non boolean value when item group is empty
2 participants