Skip to content

Commit 8ffc3fe

Browse files
Avoid overly-specific cast in bulk metadata copy (#8646)
The return value of `ITaskItem.CloneCustomMetadata` is an `IDictionary`, which is generally (in modern MSBuild) backed by a `Dictionary<string, string>`, but can be (when given an item from a net35 taskhost) a `Hashtable`. In the latter situation, casting entries to `KeyValuePair<,>` fails, because they conform only to `DictionaryEntry`. Use that less-well-typed approach--the casts were present in the pre- bulk-edit version of the code. Fixes #8645.
1 parent 61dd656 commit 8ffc3fe

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
33
<Project>
44
<PropertyGroup>
5-
<VersionPrefix>17.6.0</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
5+
<VersionPrefix>17.6.1</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
66
<PackageValidationBaselineVersion>17.5.0</PackageValidationBaselineVersion>
77
<AssemblyVersion>15.1.0.0</AssemblyVersion>
88
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>

src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,8 +1391,8 @@ private void GatherTaskItemOutputs(bool outputTargetIsItem, string outputTargetN
13911391
newItem = new ProjectItemInstance(_projectInstance, outputTargetName, EscapingUtilities.Escape(output.ItemSpec), parameterLocationEscaped);
13921392

13931393
newItem.SetMetadataOnTaskOutput(output.CloneCustomMetadata()
1394-
.Cast<KeyValuePair<string, string>>()
1395-
.Select(x => new KeyValuePair<string, string>(x.Key, EscapingUtilities.Escape(x.Value))));
1394+
.Cast<DictionaryEntry>()
1395+
.Select(x => new KeyValuePair<string, string>((string)x.Key, EscapingUtilities.Escape((string)x.Value))));
13961396
}
13971397
}
13981398

0 commit comments

Comments
 (0)