Lenguaje

TaskItem<T> Struct

Definition

A strongly-typed wrapper around ITaskItem that parses the item's identity as a value of type T.

generic <typename T>
public value class TaskItem : IEquatable<Microsoft::Build::Framework::TaskItem<T>>, Microsoft::Build::Framework::ITaskItem<T>
public readonly struct TaskItem<T> : IEquatable<Microsoft.Build.Framework.TaskItem<T>>, Microsoft.Build.Framework.ITaskItem<T>
type TaskItem<'T> = struct
    interface ITaskItem<'T>
    interface ITaskItem2
    interface ITaskItem
Public Structure TaskItem(Of T)
Implements IEquatable(Of TaskItem(Of T)), ITaskItem(Of T)

Type Parameters

T

The type to parse the item identity as. Can be a value type, FileInfo, or DirectoryInfo.

Inheritance
TaskItem<T>
Implements

Remarks

This allows tasks to receive strongly-typed parameters while still working with MSBuild's item system. The identity (ItemSpec) is parsed using Microsoft.Build.Shared.ValueTypeParser which handles value types, AbsolutePath, FileInfo, and DirectoryInfo.

Constructors

Name Description
TaskItem<T>(ITaskItem)

Initializes a new instance of TaskItem<T> from an ITaskItem.

TaskItem<T>(T)

Initializes a new instance of TaskItem<T> from a strongly-typed value.

Properties

Name Description
EvaluatedIncludeEscaped

Gets or sets the item include value e.g. for disk-based items this would be the file path.

ItemSpec

Gets or sets the item "specification" e.g. for disk-based items this would be the file path.

MetadataCount

Gets the number of pieces of metadata on the item. Includes both custom and built-in metadata.

MetadataNames

Gets the names of all the metadata on the item. Includes the built-in metadata like "FullPath".

Value

Gets the strongly-typed value parsed from the item's identity.

Methods

Name Description
CloneCustomMetadata()

Get the collection of custom metadata. This does not include built-in metadata.

CloneCustomMetadataEscaped()

ITaskItem2 implementation which returns a clone of the metadata on this object. Values returned are in their original escaped form.

CopyMetadataTo(ITaskItem)

Allows custom metadata on the item to be copied to another item.

Equals(Object)

Indicates whether this instance and a specified object are equal.

Equals(TaskItem<T>)

Indicates whether the current object is equal to another object of the same type.

GetHashCode()

Returns the hash code for this instance.

GetMetadata(String)

Allows the values of metadata on the item to be queried.

GetMetadataValueEscaped(String)

Allows the values of metadata on the item to be queried.

RemoveMetadata(String)

Allows the removal of custom metadata set on the item.

SetMetadata(String, String)

Allows a piece of custom metadata to be set on the item.

SetMetadataValueLiteral(String, String)

Allows a piece of custom metadata to be set on the item. Assumes that the value passed in is unescaped, and escapes the value as necessary in order to maintain its value.

ToString()

Returns the fully qualified type name of this instance.

Operators

Name Description
Equality(TaskItem<T>, TaskItem<T>)

Determines whether two TaskItem<T> instances are equal.

Implicit(T to TaskItem<T>)
Implicit(TaskItem<T> to T)

Implicitly converts a TaskItem<T> to its strongly-typed value.

Inequality(TaskItem<T>, TaskItem<T>)

Determines whether two TaskItem<T> instances are not equal.

Applies to