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

Merged
merged 12 commits into from
Mar 21, 2025

Conversation

moormaster
Copy link
Contributor

@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
Contributor 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
Contributor 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
Contributor Author

Choose a reason for hiding this comment

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

Removed leftovers :)

belav
belav previously approved these changes Mar 16, 2025
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.

Looks good, I'm going to try to figure out what gets logged as warnings and how that shows up with csharpier.msbuild

@belav
Copy link
Owner

belav commented Mar 16, 2025

I couldn't get csharpier.msbuild to ever log a warning. I believe at one time it would log warnings for files that could not be compiled but the logic around how msbuild runs has changed over time and I couldn't get it to trigger. The other two code paths that would write a warning wouldn't ever occur with using msbuild.

Thanks for the contribution!

@belav belav added this to the 0.31.0 milestone Mar 16, 2025
belav
belav previously approved these changes Mar 16, 2025
@belav belav enabled auto-merge (squash) March 16, 2025 18:02
@belav belav merged commit 9ae7bf1 into belav:main Mar 21, 2025
4 checks passed
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