[v6] dotnet format don't respect --include option
See original GitHub issueHi,
I’m the maintainer of Husky.Net tool, In big projects using dotnet-format is a real pain, it takes a lot of time to complete. This is one of the reasons that I created Husky.Net. usually, people only want to format changed files( or staged files). In the previous versions (e.g v5) we could’ve easily limited the dotnet-format working area to the specific files using --include
but in the last version looks like dotnet-format doing something else in the background and don’t respect that option.
dotnet format --include folder/targetFile.cs folder/targetFile2.cs
The expected behavior is ignoring everything else except the target files. or providing an option to change its behavior. This issue makes dotnet-format v6 almost unusable, how can I fix this problem or change its behavior? Thank you
Issue Analytics
- State:
- Created 2 years ago
- Reactions:16
- Comments:7 (3 by maintainers)
Top Results From Across the Web
dotnet format command - .NET CLI
dotnet format is a code formatter that applies style preferences to a project or solution. Preferences will be read from an .editorconfig ...
Read more >Configure unit tests by using a .runsettings file
NET version on which the tests are run, the directory for the test results ... Select Tools > Options > Test > Auto...
Read more >How to use dotnet format to format the whole project inside ...
I have a .Net 5 app and want to use dotnet format. First I added commitlint, husky and lint-staged to the repository.
Read more >Backpacker - Mar 2001 - Page 15 - Google Books Result
This may seem cavalier, but I don't want the trailside risk when there's so ... the risk of insulting a less knowledgeable person,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To handle the options not being parsed correctly, we plan to remove the parsing from the CLI side and simply pass through to the dotnet-format tool. I have opened https://github.com/dotnet/sdk/pull/25541 to get this addressed.
As for performance, we have discussed alternate ways to speed up populating our workspace. Ultimately MSBuild will be involved at some point because .NET builds are so highly customizable the only way not to be wrong is to have MSBuild do the work.
We are not committing to either approach today, but know that this a problem that we are thinking on.
@JoeRobich Hey Joe! Giving a quick reply here… I guess my example is bad, because when I use
--include
with actual supported files in my solution, it’s really slow.So… to improve my example:
still results in other non-relevant projects being built/analyzed…
One workaround is simply using
dotnet format whitespace
which is super quick, but kinda defeats the point of using editorconfig and specific dotnet rules…Also, what do you mean with the workaround? How is that different than what @alirezanet is posting? The only difference i see is that @alirezanet 's example contain 2 files, where yours only contains one.
I dont think it is a functional workaround to call
dotnet format --options here
for EACH changed file… this would kill performance even more!Curious to hear about your reply!