dotnet / dotnet/msbuild

HasMetadata item function cannot distinguish between "not present" and "set to empty"

Open
#1,030 4 comments 1 reaction 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

I had the need to filter components based on the presence of metadata, regardless of its value.

The HasMetadata item function, however, checks for the metadata _value_, rather than just the presence of the metadata name, so items with the metadata, but an empty value, are improperly filtered out.

The following snippet showcases the issue:

``` XML








Bar







```

This renders "Bar", but not "Foo", which does contain the metadata item.

I know this would be a breaking change, so maybe a new item function named `HasMetadataName` could be provided for this behavior?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.