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

Console logger splits path using directory and alt directory separators #3923

Merged
merged 5 commits into from
Aug 22, 2022

Conversation

Evangelink
Copy link
Member

Description

Console logger splits path using directory and alt directory separators. I decided to use both separators because I have no idea if we are ensured to receive backslashes for windows paths.

Related issue

Fixes #3376

test/Microsoft.TestPlatform.TestUtilities/TestUtils.cs Outdated Show resolved Hide resolved
@@ -765,7 +765,7 @@ private void TestRunCompleteHandler(object? sender, TestRunCompleteEventArgs e)
: $"({_targetFramework})";

var duration = GetFormattedDurationString(sourceSummary.Duration);
var sourceName = sd.Key.Split('\\').Last();
var sourceName = sd.Key.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar).Last();
Copy link
Member

Choose a reason for hiding this comment

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

Could Path.GetFileName be used here? It handles both normal and alt separator char. But does not handle UNC paths well. So maybe this is a lower risk option.

It still seems like a one-off solution of something that should be in a "library" and used everywhere. That is different discussion though.

Copy link
Member Author

Choose a reason for hiding this comment

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

But does not handle UNC paths well

Do you know specific cases that are not well handled? Because replacing the code with Path.GetFileName seems pretty sensible to me.

@Evangelink Evangelink enabled auto-merge (squash) August 22, 2022 16:46
@Evangelink Evangelink merged commit c0f8e0e into microsoft:main Aug 22, 2022
@Evangelink Evangelink deleted the console-logger-source-name branch August 23, 2022 13:43
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.

Console logger has a hardcoded path separator for the source
2 participants