Skip to content

Emit relative path to output#8692

Merged
rainersigwald merged 5 commits intodotnet:mainfrom
rainersigwald:livelogger-relative-path
Apr 25, 2023
Merged

Emit relative path to output#8692
rainersigwald merged 5 commits intodotnet:mainfrom
rainersigwald:livelogger-relative-path

Conversation

@rainersigwald
Copy link
Copy Markdown
Member

A top comment from the folks who've seen this is that the absolute paths take up a bunch of space and making them relative would be a UX nicety. This is the simplest possible approach for that: string prefix truncation with no path comparison anything.

@baronfel
Copy link
Copy Markdown
Member

Here's a short recording of what it looks like:

fsac-build-shortoutput

It does help a lot over using absolute paths! This is a reasonable sized terminal window (~1100x600) and it was still legible for this small, 7ish project repo.

Comment thread src/MSBuild/LiveLogger/LiveLogger.cs Outdated
Comment thread src/MSBuild/LiveLogger/LiveLogger.cs Outdated
Comment thread src/MSBuild/LiveLogger/LiveLogger.cs Outdated

// If the output path is under the initial working directory, make the console output relative to that to save space.
if (outputPathSpan.StartsWith(_initialWorkingDirectory.AsSpan(), FileUtilities.PathComparison)
&& (outputPathSpan[_initialWorkingDirectory.Length] == Path.DirectorySeparatorChar
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's not possible for outputPathSpan to be the same as _initialWorkingDirectory to cause a crash here, is it?

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.

Hm. Not normally, but we can't control what projects might emit, so we should definitely guard against this.

@rainersigwald rainersigwald added the merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now. label Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-when-branch-open PRs that are approved, except that there is a problem that means we are not merging stuff right now.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants