How to speed up CleanupCode Command-Line Tool?
Answered
I am attempting to integrate CleanupCode Command-Line Tool with a git hook, but unfortunately running it through command line is way slower than running it through IDE. I believe this is may be related to some caching or MSBuild (build runs in 2s through Rider and takes quite a while through command-line tool), but I wasn't able to fix it. Does anyone know how to improve the speed of the command-line tool? I am running both using the same profile, btw.
TIA
Please sign in to leave a comment.
Hello Eu11111,
Thank you for contacting us! Do you use MSBuild to build the project?
Do you mean that building plus the inspection takes a long time comparing to Rider?
Andrey Simukov thanks for the response. I mean when I am in Rider and I right click folder/file -> Code Cleanup. It runs super fast! I may be wrong, but I feel it is because it doesn't rebuild the entire solution.
But, if I run through command line it waits for MSBuild to finish running and it takes quite a while, slowing everything down! I was trying to implement a pre-commit hook that runs code cleanup on my commited files.
Eu11111 I believe the reason of the difference is the solution model creation time. Rider load the solution model when the solution is opened, so the Cleanup is fast since it's ready. Command-Line's CleanupCode needs to built the solution model first, before launching the cleanup itself.
Hello Andrey Simukov, I'm encountering this issue as well, with the following steps to repro:
Initialization
Then, open the solution in Rider.
Execution
1. Modify Program.cs by adding a leading whitespace. Then, select "Code" -> "Reformat Code". Observe that the operation completes immediately.
2. Launch Terminal from Rider, and run:
Observe that the operation completes in about 10s.
Is there anything that I should be doing to improve the speed of cleanupcode's execution?
Hello Yongzhiyuan
Thank you for contacting us! Please refer to my previous reply:
>Rider load the solution model when the solution is opened, so the Cleanup is fast since it's ready. Command-Line's CleanupCode needs to built the solution model first, before launching the cleanup itself.
I'm afraid it can't be done faster with the Command-Line Tools. In case you run the cleanup while the solution is loaded into Rider, use the Code | Reformat and Cleanup instead.