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
Merged
Prev Previous commit
Next Next commit
refactor: simplified FileIssueLogger.WriteError()
moormaster committed Mar 3, 2025
commit 76a7c4b9138e545dd008468fc00f8728138b72de
17 changes: 1 addition & 16 deletions Src/CSharpier.Cli/FileIssueLogger.cs
Original file line number Diff line number Diff line change
@@ -4,27 +4,12 @@ namespace CSharpier.Cli;

internal class FileIssueLogger(string filePath, ILogger logger, bool isMsBuildFormat)
{
static string FormatMsBuildError(LogState logState, Exception? exception) =>
$"{logState.Path}: error: {logState.Message}";

record class LogState
{
public required string Path;
public required string Message;
}

public void WriteError(string value, Exception? exception = null)
{
if (isMsBuildFormat)
{
var logState = new LogState() { Path = this.GetPath(), Message = value };

logger.Log(LogLevel.Error, 0, logState, exception, FormatMsBuildError);
}
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.

else
{
logger.LogError(exception, $"{this.GetPath()} - {value}");
}
}

public void WriteWarning(string value)