From 18023726134a4d7325eb4028e399ff8ddc2754a3 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Tue, 10 Dec 2024 18:27:25 +0100 Subject: [PATCH 1/7] check if it is filepath --- src/Utilities/TaskItem.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Utilities/TaskItem.cs b/src/Utilities/TaskItem.cs index e5e53b3ff01..27740083b67 100644 --- a/src/Utilities/TaskItem.cs +++ b/src/Utilities/TaskItem.cs @@ -64,7 +64,7 @@ public sealed class TaskItem : /// Default constructor -- do not use. /// /// - /// This constructor exists only so that the type is COM-creatable. Prefer . + /// This constructor exists only so that the type is COM-creatable. Prefer . /// [EditorBrowsable(EditorBrowsableState.Never)] public TaskItem() @@ -75,14 +75,23 @@ public TaskItem() /// /// This constructor creates a new task item, given the item spec. /// - /// Assumes the itemspec passed in is escaped. + /// + /// Assumes the itemspec passed in is escaped. + /// If tratAsFilePath is set to true, it will try to fix itemSpac backslashes into slashes. + /// /// The item-spec string. + /// If item-spec string is a path or not. public TaskItem( - string itemSpec) + string itemSpec, + bool treatAsFilePath = true) { ErrorUtilities.VerifyThrowArgumentNull(itemSpec); - _itemSpec = FileUtilities.FixFilePath(itemSpec); + if (treatAsFilePath) + { + + _itemSpec = FileUtilities.FixFilePath(itemSpec); + } } /// From 6d2c46a634a601a1f7d2ceb2be9bf74ffd5abf94 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Wed, 11 Dec 2024 11:21:04 +0100 Subject: [PATCH 2/7] Note to self: avoid coding when very tired --- src/Utilities/TaskItem.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Utilities/TaskItem.cs b/src/Utilities/TaskItem.cs index 27740083b67..a3f20860833 100644 --- a/src/Utilities/TaskItem.cs +++ b/src/Utilities/TaskItem.cs @@ -77,21 +77,21 @@ public TaskItem() /// /// /// Assumes the itemspec passed in is escaped. - /// If tratAsFilePath is set to true, it will try to fix itemSpac backslashes into slashes. + /// If is set to , the value in + /// will be fixed up as path by having backslashes replaced with slashes. /// /// The item-spec string. - /// If item-spec string is a path or not. + /// + /// Specifies whether or not to treat the value in + /// as a file path and attempt to normalize it. Defaults to . + /// public TaskItem( string itemSpec, bool treatAsFilePath = true) { ErrorUtilities.VerifyThrowArgumentNull(itemSpec); - if (treatAsFilePath) - { - - _itemSpec = FileUtilities.FixFilePath(itemSpec); - } + _itemSpec = treatAsFilePath ? FileUtilities.FixFilePath(itemSpec) : itemSpec; } /// From 84606017152f3c382a7ea6de601f97fbae6aa964 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Wed, 11 Dec 2024 15:48:16 +0100 Subject: [PATCH 3/7] Keep old constructor --- src/Utilities/TaskItem.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Utilities/TaskItem.cs b/src/Utilities/TaskItem.cs index a3f20860833..919b460d538 100644 --- a/src/Utilities/TaskItem.cs +++ b/src/Utilities/TaskItem.cs @@ -72,6 +72,13 @@ public TaskItem() _itemSpec = string.Empty; } + /// + /// This constructor creates a new task item, given the item spec. + /// + /// Assumes the itemspec passed in is escaped. + /// The item-spec string. + public TaskItem(string itemSpec) => new TaskItem(itemSpec, treatAsFilePath: true); + /// /// This constructor creates a new task item, given the item spec. /// From 2ef5117e0d29ebaf740384eb1a52f3debb49e136 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Fri, 13 Dec 2024 13:19:39 +0100 Subject: [PATCH 4/7] Removed default value --- src/Utilities/TaskItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utilities/TaskItem.cs b/src/Utilities/TaskItem.cs index 919b460d538..df52ab93423 100644 --- a/src/Utilities/TaskItem.cs +++ b/src/Utilities/TaskItem.cs @@ -94,7 +94,7 @@ public TaskItem() /// public TaskItem( string itemSpec, - bool treatAsFilePath = true) + bool treatAsFilePath) { ErrorUtilities.VerifyThrowArgumentNull(itemSpec); From 23a7761116bc843ee5a812248785b9555bd23722 Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Fri, 13 Dec 2024 14:24:02 +0100 Subject: [PATCH 5/7] Fix build error --- src/Utilities/TaskItem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Utilities/TaskItem.cs b/src/Utilities/TaskItem.cs index df52ab93423..082878d172c 100644 --- a/src/Utilities/TaskItem.cs +++ b/src/Utilities/TaskItem.cs @@ -77,7 +77,8 @@ public TaskItem() /// /// Assumes the itemspec passed in is escaped. /// The item-spec string. - public TaskItem(string itemSpec) => new TaskItem(itemSpec, treatAsFilePath: true); + public TaskItem(string itemSpec) + : this(itemSpec, treatAsFilePath: true) { } /// /// This constructor creates a new task item, given the item spec. From 862c796f1c58510a0695f3e17848c9145c22888f Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Fri, 13 Dec 2024 16:51:02 +0100 Subject: [PATCH 6/7] Updated comments from PR suggestions --- src/Utilities/TaskItem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utilities/TaskItem.cs b/src/Utilities/TaskItem.cs index 082878d172c..6391d45e19a 100644 --- a/src/Utilities/TaskItem.cs +++ b/src/Utilities/TaskItem.cs @@ -86,12 +86,12 @@ public TaskItem(string itemSpec) /// /// Assumes the itemspec passed in is escaped. /// If is set to , the value in - /// will be fixed up as path by having backslashes replaced with slashes. + /// will be fixed up as a path by having any backslashes replaced with slashes. /// /// The item-spec string. /// /// Specifies whether or not to treat the value in - /// as a file path and attempt to normalize it. Defaults to . + /// as a file path and attempt to normalize it. /// public TaskItem( string itemSpec, From e4474a63108c8d004342614e969b41db2d95892f Mon Sep 17 00:00:00 2001 From: Mariana Dematte Date: Fri, 13 Dec 2024 16:53:52 +0100 Subject: [PATCH 7/7] File was not saved with all the changes -_- --- src/Utilities/TaskItem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Utilities/TaskItem.cs b/src/Utilities/TaskItem.cs index 6391d45e19a..d43175b77aa 100644 --- a/src/Utilities/TaskItem.cs +++ b/src/Utilities/TaskItem.cs @@ -75,7 +75,7 @@ public TaskItem() /// /// This constructor creates a new task item, given the item spec. /// - /// Assumes the itemspec passed in is escaped. + /// Assumes the itemspec passed in is escaped and represents a file path. /// The item-spec string. public TaskItem(string itemSpec) : this(itemSpec, treatAsFilePath: true) { }