Open pgrm opened 4 years ago
I do think that most people assume that dotnet-format is only going to change their whitespace. There are lots of additional situations where it will need semantic information.
CC: @JoeRobich could we first look at the editorconfig files and only attempt to load a workspace if we find an option-set+command-line-args that require a workspace?
If I'm reading between the lines correctly, in order to only look at the files specified with --files
and prevent looking for a workspace (MSBuild project file or solution file), the --folder
option is required because a workspace is searched for by default. Is this correct?
Also, the difference between --include
and --files
doesn't seem to be explained. Do they function the same way?
@qubitz you are correct.
By default running dotnet format
will look for a solution/project file and attempt to formal all the *.cs
files in that are included there. It can be thought of as the default is an implicit -w
(the workspace option).
--include
and --files
are synonyms for the same option as you can see here:
https://github.com/dotnet/format/blob/aed51cf8bba5dcddb5f1c9ee718ceca4e0603822/src/Program.cs#L37
@jmarolf to be clear, I didn't mean, the behaviour should change, rather the documentation should reflect what is going on under the hood, maybe even explain why it's not always possible to just format the files without loading the whole workspace. Otherwise the user is left wondering what they did wrong.
@pgrm Please let me know if this documentation is sufficient - https://github.com/dotnet/format/tree/master/docs#filter-files-to-format. If not, please recommend how it could be improved. Thanks!
When I run
dotnet format --files .\src\ProjectFolder\Program.cs -v detailed
I always seeI would have expected to see only one file formatted.
it works, when I run
dotnet format --folder . --files .\src\ProjectFolder\Program.cs -v detailed
(kudos to https://github.com/dotnet/format/issues/403)But in the README it's described as
dotnet format --include Programs.cs Utility\Logging.cs
without further explanation (https://github.com/dotnet/format#how-to-use) - maybe it could be improved?Background:
The reason I want to specify only specific files, is to run it as a pre-commit hook as quickly as possible.