format icon indicating copy to clipboard operation
format copied to clipboard

Is the --include option working at all?

Open lextatic opened this issue 3 years ago • 5 comments

If so, can someone tell me how to make it work?

On version 6.0.347701 I was able to lint just the files listed when passing the --include parameter, but after I updated the dotnet format to 6.4.352107 it stopped working.

It still analyze all files as it's supposed to, but i doesn't "format" the included files, and it just do that if you use the --include paremeter, without this it works fine.

To clarify this, I have a .csproj including all files I want to format, When I run:

dotnet format csharp_project.csproj -v -d

It shows at the end: Formatted 2 of 5 files.

But if I run dotnet format csharp_project.csproj -v -d --include csharp_bad_01.cs csharp_bad_02.cs

It shows: Formatted 0 of 5 files.

I have double checked all paths and I'm sure it's okay because as I said it works on version 6.0.347701.

Has anything changed? Am I supposed to use it differently now? It seems to be this way even on version 7.*.

lextatic avatar Dec 01 '22 11:12 lextatic

This is not working for me either.

williambohrmann3 avatar Apr 27 '23 21:04 williambohrmann3

Not able to run dotnet-format --include or dotnet-format --files with a list of files separated by spaces. Will not format listed files.

williambohrmann3 avatar Apr 28 '23 21:04 williambohrmann3

@lextatic Check if csharp_bad_01.cs and csharp_bad_02.cs are the correct relative paths of the files. I had the same issue cause I was using

git diff --name-only --staged '*.cs'

instead of

git diff --name-only --relative --staged '*.cs'

to pass the file names.

erick2red avatar Jun 22 '23 16:06 erick2red

I am using the dotnet format pre-commit script, which uses comma-separation. This does not work for me. However, changing sed -e 's/ /,/g' to sed -e 's/ / /g' so that dotnet format is run with space-separated files makes this work with multiple files for me. Otherwise, it only works with one file.

jakoblover avatar Jun 29 '23 12:06 jakoblover