More detailed report messages
See original GitHub issueGiven the following code:
namespace ConsoleApp1
{
class Program {
static void Main(string[] args)
{
Console.WriteLine ("Hello World!");
}
}
}
Running dotnet-format --dry-run
gives the following output:
Formatting code files in workspace 'C:\dev\xt0rted\actions-playground\Application.sln'.
src\ConsoleApp1\Program.cs(5,18): Fix whitespace formatting.
src\ConsoleApp1\Program.cs(8,30): Fix whitespace formatting.
Formatted code file 'Program.cs'.
Format complete in 4450ms.
The two violations have the same message of Fix whitespace formatting
but there’s no indication as to what the formatting issues are. The first error is csharp_new_line_before_open_brace
and the second is csharp_space_between_method_declaration_parameter_list_parentheses
.
At the very least the rule names should be included in the output, but more descriptive messages would be best. Knowing that the first issue is because there needs to be a new line before the brace, and the second issue is because there shouldn’t be a space after the method declaration, is a lot more helpful then being told there’s a generic whitespace issue.
Other linters such as ESLint and StyleLint produce a report in the stylish format which has the rule name a violation message. The compact format is most similar to what’s being used now though.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
That part’s relatively easy. You can either run the formatter manually to get the information, or you can indirectly invoke the code fix and then provide some sort of UI to present the changes.
CodeFixTest<TVerifier>
is a good example of executing code fixes (likely more complicated than you need but shows pretty much everything).+1 This would be a great DX improvement