Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on prompting for cleaning external files #748

Open
dannypike opened this issue Jul 31, 2020 · 1 comment · Fixed by #854
Open

Exception on prompting for cleaning external files #748

dannypike opened this issue Jul 31, 2020 · 1 comment · Fixed by #854

Comments

@dannypike
Copy link

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.

@codecadwallader
Copy link
Owner

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

heku pushed a commit to heku/codemaid that referenced this issue Nov 7, 2021
heku pushed a commit to heku/codemaid that referenced this issue Nov 8, 2021
heku pushed a commit to heku/codemaid that referenced this issue Nov 8, 2021
codecadwallader pushed a commit that referenced this issue Nov 10, 2021
* Translate a newly added line

* Remove unused package references

* Eliminate redundant output via package reference manner

* Add missing references to fix unit tests build issue

* Fix cleanup external files issue #748
@codecadwallader codecadwallader linked a pull request Nov 10, 2021 that will close this issue
@codecadwallader codecadwallader added this to the v12.1 milestone Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants