Avoid overly-specific cast in bulk metadata copy #8646
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Projects that have tasks that run in the .NET Framework 3.5 environment that return metadata are unusable in MSBuild 17.6.0.
The return value of
ITaskItem.CloneCustomMetadatais anIDictionary, which is generally (in modern MSBuild) backed by aDictionary<string, string>, but can be (when given an item from a net35 taskhost) aHashtable. In the latter situation, casting entries toKeyValuePair<,>fails, because they conform only toDictionaryEntry.Use that less-well-typed approach--the casts were present in the pre-bulk-edit version of the code. Fixes #8645.
Work item (Internal use): AB#1790945
Customer Impact
Microsoft-internal customer reported breaks in projects that use WiX3.
Regression?
Yes, from #8240.
Testing
Manual validation of the sample project from customer.
Risk
Low (fixes cast to match guaranteed behavior and uses only preexisting casts). But we could also revert #8240 entirely.