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

feat: enable jumping to "not formatted" files from VisualStudio error list #1517

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

moormaster
Copy link

@moormaster moormaster commented Feb 28, 2025

Enables to double click on "was not formatted" message in error list of Visual Studio to jump to the file affected.

… list

- adds --msbuild-format parameter to format error message according to standard error/warning format of MSBuild.
See https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-diagnostic-format-for-tasks?view=vs-2022
@moormaster moormaster marked this pull request as ready for review February 28, 2025 23:11
Copy link
Owner

@belav belav left a comment

Choose a reason for hiding this comment

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

I'm happy to see that this cleans up the msbuild target. The main change is making the option an enum so it'll be easier to add #1398 later.

Comment on lines 57 to 60
new Option(
["--msbuild-format"],
"Formats messages in standard error/warning format for MSBuild."
),
Copy link
Owner

Choose a reason for hiding this comment

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

There have been requests for other log formats. I'm thinking this should be --log-format and accept a string/enum. Just msbuild and default (or maybe call it console?) for now.

Copy link
Author

Choose a reason for hiding this comment

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

Renamed Startparameter and used enum as suggested.

{
public void WriteError(string value, Exception? exception = null)
{
logger.LogError(exception, $"{this.GetPath()} - {value}");
if (isMsBuildFormat)
logger.LogError("{Path}: error: {Message}", this.GetPath(), value);
Copy link
Owner

Choose a reason for hiding this comment

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

I think the WriteWarning message should also use msbuild format. Although I don't recall what is considered a warning by CSharpier, and we turn on warningsAsErrors at work. Maybe that would cause issues.

Copy link
Author

Choose a reason for hiding this comment

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

Also made WriteWarning() obey the --log-format parameter.
Also added a TODO comment for adding a test as soon as it is clear in which situations CSharpier will output warnings.

Comment on lines 14 to 15
private const bool IsMsBuildFormat = true;
private const bool IsNotMsBuildFormat = false;
Copy link
Owner

Choose a reason for hiding this comment

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

These don't appear to be used and should be removed.

Copy link
Author

Choose a reason for hiding this comment

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

Removed leftovers :)

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.

2 participants