codecadwallader / codemaid

CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
http://www.codemaid.net
GNU Lesser General Public License v3.0
1.88k stars 353 forks source link

Automatic Cleanup On Save... doesn't #953

Closed jdx-john closed 1 year ago

jdx-john commented 1 year ago

Environment

Description

I have checked "Automatic Cleanup On Save" in Extensions->CodeMaid options image

When I edit a file and save it, I see no evidence of CM making any changes. If I explicitly run code cleanup on the same file, changes are made. image

Steps to recreate

Just one example with using but it seems to be a general problem.

  1. Enable "Automatic Cleanup On Save"
  2. Add a spurious using to a code file in your C# project (VS will show it as not needed)
  3. Save the file - the using remains
  4. Explicitly cleanup the file by right-clicking it in the solution explorer - the using is removed as expected
codecadwallader commented 1 year ago

Thanks for reporting the issue. Using statements are a special case that by default skip cleaning during automatic cleanup on save. This is due to some possible conflicts where updating using statements during a save event could trigger an infinite loop depending on configuration and other installed extensions.

If you want to change this behavior, there is an option at CodeMaid->Options->Cleaning->Visual Studio->Run remove and sort using statements->Skip during automatic cleanup on save that controls it.

Hope it helps!

jdx-john commented 1 year ago

I confirm this works as you describe - thanks. As far as I am concerned I will close it, unless the team deems it worth further attention.