Skip to content

Option to avoid "fixing" \ in new TaskItem() #11120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 13, 2024
Merged
Changes from 5 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
23 changes: 20 additions & 3 deletions src/Utilities/TaskItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public sealed class TaskItem :
/// Default constructor -- do not use.
/// </summary>
/// <remarks>
/// This constructor exists only so that the type is COM-creatable. Prefer <see cref="TaskItem(string)"/>.
/// This constructor exists only so that the type is COM-creatable. Prefer <see cref="TaskItem(string, bool)"/>.
/// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
public TaskItem()
Expand All @@ -77,12 +77,29 @@ public TaskItem()
/// </summary>
/// <comments>Assumes the itemspec passed in is escaped.</comments>
/// <param name="itemSpec">The item-spec string.</param>
public TaskItem(string itemSpec)
: this(itemSpec, treatAsFilePath: true) { }

/// <summary>
/// This constructor creates a new task item, given the item spec.
/// </summary>
/// <comments>
/// Assumes the itemspec passed in is escaped.
/// If <see name="treatAsFilePath" /> is set to <see langword="true" />, the value in <see name="itemSpec" />
/// will be fixed up as path by having backslashes replaced with slashes.
/// </comments>
/// <param name="itemSpec">The item-spec string.</param>
/// <param name="treatAsFilePath">
/// Specifies whether or not to treat the value in <see name="itemSpec" />
/// as a file path and attempt to normalize it. Defaults to <see langword="true" />.
/// </param>
public TaskItem(
string itemSpec)
string itemSpec,
bool treatAsFilePath)
{
ErrorUtilities.VerifyThrowArgumentNull(itemSpec);

_itemSpec = FileUtilities.FixFilePath(itemSpec);
_itemSpec = treatAsFilePath ? FileUtilities.FixFilePath(itemSpec) : itemSpec;
}

/// <summary>
Expand Down