--check along with --dry-run not working as expected
See original GitHub issueHi,
My intention was to get a set of files and the errors associated with them with the --check command. But seems like --check returns just a non-zero response if there are any files that do not conform to the rules.
I tried the same, but the command ‘dotnet format --check’ doesn’t seem to be different from running dotnet format without any options. They both format the file and save changes to disk.
Now, I tried to run the option --dry-run --check (as mentioned in another issue), so that it shows just the files that have error and returns a non-zero exit code. But, the command executed successfully.
Please find below the code against which the command was run:
class Program
{
static void Main(string[] args)
{
test();
Console.WriteLine("Inside Main");
}
public static void test()
{
var i = 0;
if (i == 0){
Console.WriteLine("i is 0");
}
else
{
Console.WriteLine("i is not 0");
}
Console.WriteLine("Inside Test method");
}
}
Rule: csharp_new_line_before_else = true csharp_new_line_before_open_brace = all
When I ran > dotnet format --check The braces were formatted in the file Program.cs and the changes were saved.
Now, I tried running > dotnet format --dry-run --check With the hope that it will exit with non-zero exit code. But it showed the below message:
Formatting code files in workspace ‘C:\Project\MyHobbyProjects\EditoConfigCLISample\ConsoleApp1\ConsoleApp1.sln’. Loading workspace. Workspace loaded in 1785ms. Formatting code files in project ‘ConsoleApp1’. Formatting code file ‘Program.cs’. Formatted code file ‘Program.cs’. Formatted 1 of 3 files in 1275ms. Format complete.
Is it possible to display the files that doesn’t abide by EditorConfig and the rules that it does not conform to?
Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top GitHub Comments
Closing issue due to inactivity.
@arnavb With https://github.com/dotnet/format/pull/249, we now log individual messages for each formatting issue. These are printed during
--dry-run
s and when you also include the--check
flag it will log as an Error instead of a Warning.You can try this change by installing from myget