Skip to content
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

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

Closed
rainersigwald opened this issue Dec 4, 2024 · 1 comment · Fixed by #11120
Closed

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

rainersigwald opened this issue Dec 4, 2024 · 1 comment · Fixed by #11120
Assignees
Labels

Comments

@rainersigwald
Copy link
Member

Summary

This code unconditionally calls FixFilePath:

public TaskItem(
string itemSpec)
{
ErrorUtilities.VerifyThrowArgumentNull(itemSpec);
_itemSpec = FileUtilities.FixFilePath(itemSpec);
}

But while TaskItems usually represent files on disk, they don't necessarily do so, and if they don't and also contain backslashes this will corrupt them. It should be configurable.

Background and Motivation

See analysis by @JoeRobich in dotnet/roslyn#72014 (comment).

Proposed Feature

        public TaskItem(
            string itemSpec
+           bool convertBackslashesToSlashes = true)
        {
            ErrorUtilities.VerifyThrowArgumentNull(itemSpec);

+           if (convertBackslashesToSlashes)
+           {
                _itemSpec = FileUtilities.FixFilePath(itemSpec);
+           }
        }

Alternative Designs

No response

@jeffkl
Copy link
Contributor

jeffkl commented Dec 4, 2024

I suggest the name of the input parameter to be bool treatAsFilePath = true and document as such that MSBuild will by default treat it as a file path and potentially "fix" it up and/or create a full path from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants