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

VS2022 Freeze / Crash #992

Open NightPr0wl3r opened 1 year ago

NightPr0wl3r commented 1 year ago

Environment

Description

Hi there, I've read through some of of the open issues and found similar issues, so I flag myself here as duplicate. I just sort of want to pin point the issue I'm having, and it might assist in resolving the persistent issue (since it seems that I have the current version). Again apologies in advance for the duplicate.

Steps to recreate

  1. Have items registered for cleanup in VS options (Tools->Options->Text Editor->Code Cleanup)
  2. Configure CodeMaid (CodeMaid.config.txt attached)
  3. Go to code file
  4. Perform Refactor.Rename on any member within the file (even something as small as a method parameter name)
  5. Finalize operation -> renders entire application frozen for 3s ~ 10s, then crashes

Current behavior

Crashes entire environment

Expected behavior

Do not crash entire environment

What's causing this?

Deadlock in either a cleanup or save operation caused by Automatic Cleanup On Save. Disabling this setting fixes the issue, then I have to run Ctrl + M ~ Ctrl + Z and Ctrl + M ~ Ctrl + Space after the refactor to do any needed cleanup.

CodeMaid.config.txt

codecadwallader commented 1 year ago

Thanks for reporting the issue. It has come up before but no problem to ask the question if you haven't found the answer.

This is usually caused by a loop between multiple tools performing after save operations. So for example Visual Studio running a save, which triggers CodeMaid to run a save, then back around the circle again in an infinite loop.

In the attached CodMaid configuration (thank you for including it!), it looks like one of the "Skip during automatic cleanup on save" safety options that breaks these loops has been disabled. I suspect if you re-enable CodeMaid->Options->General->Skip undo transactions during automatic cleanup on save that it will help break the loop you are seeing. Can you give that a try please?

NightPr0wl3r commented 1 year ago

Hi there, apologies for the delayed response. I'll give it a whirl and have a response for you in the next 12~24 hours 👍