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

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

Merged
merged 4 commits into from
Jan 12, 2021

Conversation

JohnMcPMS
Copy link
Member

@JohnMcPMS JohnMcPMS commented Jan 9, 2021

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
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
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.

Copy link
Contributor

@yao-msft yao-msft left a comment

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