Partager via


ProjectItem.Rename(String) Method

Definition

Renames the item. Equivalent to setting the UnevaluatedInclude value. Generally, no expansion occurs. This is because it would potentially result in several items, which is not meaningful semantics when renaming a single item. However if the item does not need to be split (which would invalidate its ProjectItemElement), and the new value expands to exactly one item, then its evaluated include is updated with the expanded value, rather than the unexpanded value.

public:
 void Rename(System::String ^ name);
public void Rename (string name);
member this.Rename : string -> unit
Public Sub Rename (name As String)

Parameters

name
String

The new name of the item.

Remarks

Even if the new value expands to zero items, we do not expand it. The common case we are interested in for expansion here is setting something like "$(sourcesroot)\foo.cs" and expanding that to a single item. If say "@(foo)" is set as the new name, and it expands to blank, that might be surprising to the host and maybe even unhandled, if on full reevaluation it wouldn’t expand to blank. That’s why we're being cautious and supporting the most common scenario only. Many hosts will do a ReevaluateIfNecessary before reading anyway.

Applies to