codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

Exception on prompting for cleaning external files

Open dannypike opened this issue 4 years ago • 1 comments

Environment

  • Visual Studio version: [example 2015 Community]
  • CodeMaid version: 11.1.209
  • Code language: C++

Description

Thanks for a really great addin!

I think I've come across a bug - on trying to clean the whole solution from within Visual Studio, I got an exception:

[CodeMaid Handled Exception 05:54:07 AM] Unable to prompt user about cleaning external files: System.InvalidOperationException: The calling thread must be STA, because many UI components require this. at System.Windows.Input.InputManager..ctor() at System.Windows.Input.InputManager.GetCurrentInputManagerImpl() at System.Windows.Input.KeyboardNavigation..ctor() at System.Windows.FrameworkElement.FrameworkServices..ctor() at System.Windows.FrameworkElement.EnsureFrameworkServices() at System.Windows.FrameworkElement..ctor() at System.Windows.Controls.Control..ctor() at System.Windows.Window..ctor() at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupAvailabilityLogic.PromptUserAboutCleaningExternalFiles(Document document) in C:\projects\codemaid\CodeMaid\Logic\Cleaning\CodeCleanupAvailabilityLogic.cs:line 425 [CodeMaid Handled Exception 05:54:07 AM] Unable to prompt user about cleaning external files: System.InvalidOperationException: The calling thread must be STA, because many UI components require this. at System.Windows.Input.InputManager..ctor() at System.Windows.Input.InputManager.GetCurrentInputManagerImpl() at System.Windows.Input.KeyboardNavigation..ctor() at System.Windows.FrameworkElement.FrameworkServices..ctor() at System.Windows.FrameworkElement.EnsureFrameworkServices() at System.Windows.FrameworkElement..ctor() at System.Windows.Controls.Control..ctor() at System.Windows.Window..ctor() at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupAvailabilityLogic.PromptUserAboutCleaningExternalFiles(Document document) in C:\projects\codemaid\CodeMaid\Logic\Cleaning\CodeCleanupAvailabilityLogic.cs:line 425 [CodeMaid Warning 05:54:29 AM] Activation was not completed before cleaning began for 'Program.cs'

I didn't get any sort of prompt window being displayed, so this is presumably at the outermost layer of trying to ask me something. This is the full text from the Output Window, so there's no info to give us a clue about which worker thread was trying to show a prompt window, if it's not obvious from the design. None of the external files were changed.

I hope that's enough info. Please let me know if you need more.

dannypike avatar Jul 31 '20 05:07 dannypike

Thanks for reporting the issue, and I'm glad to hear you're otherwise liking CodeMaid. :)

The "external files" prompt happens when there are files that are not included in the solution. Since cleaning up all files already provides a progress dialog, I suspect the attempt to show a second dialog when one is already open fails.

I was able to reproduce the issue and for me it silently failed to clean up that file and continued on with the rest of the files cleanly. Is that what you are seeing as well?

One workaround would be to explicit make a selection with the setting at CodeMaid->Options->Cleaning->General->"Perform partial cleanup if file is not in the solution". It defaults to "Ask" but you can change it to "Yes" or "No" which would avoid the dialog altogether.

image

codecadwallader avatar Sep 22 '20 12:09 codecadwallader