Skip to content

Force output paths to use u8string with filesystem::path#694

Merged
JohnMcPMS merged 4 commits into
microsoft:masterfrom
JohnMcPMS:fixpathlog
Jan 12, 2021
Merged

Force output paths to use u8string with filesystem::path#694
JohnMcPMS merged 4 commits into
microsoft:masterfrom
JohnMcPMS:fixpathlog

Conversation

@JohnMcPMS

@JohnMcPMS JohnMcPMS commented Jan 9, 2021

Copy link
Copy Markdown
Member

Issue

When paths with non-ASCII characters are used, logging them is resulting in an exception due to not being able to convert them to ASCII (the default behavior when forced to convert to a narrow char).

Change

To better handle all situations of output of a path, both the logging and reporting infrastructure have been enlightened to force the use of u8String() when they see one.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS JohnMcPMS requested a review from a team as a code owner January 9, 2021 01:10
@JohnMcPMS JohnMcPMS requested a review from msftrubengu January 9, 2021 01:11
{
// Force use of the UTF-8 string from a file path.
// This should not be necessary when we move to C++20 and convert to using u8string.
friend AppInstaller::Logging::LoggingStream& operator<<(AppInstaller::Logging::LoggingStream& out, std::filesystem::path& path)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::filesystem::path& path [](start = 107, length = 27)

Is this override with non const variant used?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; when doing overload resolution, only the exact match will be considered a better candidate than the template. So a non-const local will not match the const& function. Unfortunately I'm not aware of a better way to force the compiler to "do everything as you would have except in this one case". I suppose it might be possible to add some dummy parameters to the template to make it a worse candidate function.

@yao-msft yao-msft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@JohnMcPMS JohnMcPMS merged commit 69290f9 into microsoft:master Jan 12, 2021
@JohnMcPMS JohnMcPMS deleted the fixpathlog branch January 12, 2021 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants