Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/Framework/IItemData.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;

namespace Microsoft.Build.Framework;
Expand Down Expand Up @@ -41,11 +40,8 @@ string EvaluatedInclude
/// </remarks>
public readonly struct ItemData
{
private readonly Func<IEnumerable<KeyValuePair<string, string>>> _enumerateMetadata;

public ItemData(string type, object value)
{

Type = type;
Value = value;

Expand All @@ -56,17 +52,14 @@ public ItemData(string type, object value)
if (value is IItemData dt)
{
EvaluatedInclude = dt.EvaluatedInclude;
_enumerateMetadata = dt.EnumerateMetadata;
}
else if (value is ITaskItem ti)
{
EvaluatedInclude = ti.ItemSpec;
_enumerateMetadata = ti.EnumerateMetadata;
}
else
{
EvaluatedInclude = value.ToString() ?? string.Empty;
_enumerateMetadata = () => [];
}
}

Expand All @@ -91,5 +84,16 @@ public ItemData(string type, object value)
/// The item metadata
/// </summary>
public IEnumerable<KeyValuePair<string, string>> EnumerateMetadata()
=> _enumerateMetadata();
{
if (Value is IItemData dt)
{
return dt.EnumerateMetadata();
}
else if (Value is ITaskItem ti)
{
return ti.EnumerateMetadata();
}

return [];
}
}