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.89k stars 356 forks source link

Automatically run cleanup on file save not working on VS 2022 #868

Closed fernandoweiler closed 2 years ago

fernandoweiler commented 2 years ago

Environment

Description

'Automatically run cleanup on file save' not working on VS 2022.

Steps to recreate

  1. Open a .CS file.
  2. Make a change (or leave it as it is).
  3. Save the file with Ctrl + S or clicking on the save button.

Current behavior

No cleanup is made, although the Cleaning > General > Automatically run cleanup on file save is active.

Expected behavior

Cleanup should be dispatched.

image

codecadwallader commented 2 years ago

Thanks for reporting the issue. I have been unable to reproduce it. A couple things to try:

  1. Can you manually clean up that file? If it is not supported or a part of the exclusion list this may be on purpose.
  2. Using statements are not cleaned by default during automatic cleanup. This is due to some race condition scenarios that can happen with other extensions. This can be changed at CodeMaid->Options->Cleaning->Visual Studio->Run remove and sort using statements->Skip during automatic cleanup on save.
  3. If you enable diagnostics (CodeMaid->Options->General->Diagnostics mode) and look at the Output window with the CodeMaid pane you may get some helpful information such as:

    [CodeMaid Diagnostic 08:33:54 AM] CodeCleanupAvailabilityLogic.CanCleanupDocument returned false for 'C:\src\codemaid\CodeMaidShared\Logic\Cleaning\CodeCleanupAvailabilityLogic.cs' due to an auto-generated header.

fernandoweiler commented 2 years ago

Hi, thanks for the answer. Manually it works fine, only on save it is not working. I will take a look on steps 2 and 3 and give you a feedback. Edit: so, it seems the 'Skip during automatic cleanup on save' was enabled, so it wasn't a bug at all.

cuteUnicornCode commented 2 years ago

That resolved my issue as well, thanks!