Skip to content

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


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 force-pushed the console-logger-source-name branch from 057e974 to e5e076d Compare August 22, 2022 14:45
@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