Comments (35)
It looks like the remove unused using statements command that is invoked during the cleanup process is what is throwing an error. A couple things to check:
- If you manually invoke remove unused using statements, does it also throw an error?
- What changes to the file are happening during the R# cleaning of the file? Can you provide examples?
from codemaid.
Hi,
I make a test. I create new project with new solution Console Application template in VS 2013, .Net 4.5.1.
First thing I try to do was clean up file (Ctrl + M, Space) and I got:
[CodeMaid Diagnostic 10:05:05 ] CleanupActiveCodeCommand.OnExecute invoked
[CodeMaid Diagnostic 10:05:05 ] WindowEventListener.OnWindowChange raised for 'c:\users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 10:05:05 ] CodeCleanupManager.Cleanup started for 'c:\users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Handled Exception 10:05:05 ] Stopped cleaning 'Program.cs': System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at EnvDTE80.DTE2.ExecuteCommand(String CommandName, String CommandArgs)
at SteveCadwallader.CodeMaid.Logic.Cleaning.UsingStatementCleanupLogic.RemoveUnusedUsingStatements(TextDocument textDocument, Boolean isAutoSave)
at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupManager.RunCodeCleanupCSharp(Document document, Boolean isAutoSave)
at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupManager.<>c__DisplayClass3.b__1()
at SteveCadwallader.CodeMaid.Helpers.UndoTransactionHelper.Run(Func1 undoConditions, Action tryAction, Action
1 catchAction)
Then I manually remove using and I notice new log line:
[CodeMaid Diagnostic 10:05:30 ] WindowEventListener.OnWindowChange raised for 'c:\users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 10:05:33 ] TextEditorEventListener.OnLineChanged raised for 'c:\users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
Next I try Ctrl + M, Space, result below:
[CodeMaid Diagnostic 10:05:44 ] CleanupActiveCodeCommand.OnExecute invoked
[CodeMaid Diagnostic 10:05:44 ] CodeCleanupManager.Cleanup started for 'c:\users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Handled Exception 10:05:44 ] Stopped cleaning 'Program.cs': System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at EnvDTE80.DTE2.ExecuteCommand(String CommandName, String CommandArgs)
at SteveCadwallader.CodeMaid.Logic.Cleaning.UsingStatementCleanupLogic.RemoveUnusedUsingStatements(TextDocument textDocument, Boolean isAutoSave)
at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupManager.RunCodeCleanupCSharp(Document document, Boolean isAutoSave)
at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupManager.<>c__DisplayClass3.b__1()
at SteveCadwallader.CodeMaid.Helpers.UndoTransactionHelper.Run(Func1 undoConditions, Action tryAction, Action
1 catchAction)
Next I invoke R# clear using and then CodeMaid, result was the same: an error.
CodeMaid sort lines works.
The file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
}
}
}
I tried to clean up few file from my current project but I got error for every file I open.
List of extension which I have installed:
Application Insights Tools for Visual Studio
Behaviors SDK (XAML)
CodeMaid
JustTrace
Microsoft Advertising pubCenter Service for Visual Studio
Microsoft Advertising SDK for Windows 8.1
Microsoft Advertising SDK for Windows Phone 8.1
Microsoft ASP.Net and Web Tools
Microsoft Visual Studio ASP.Net MVC 5 Scaffolding
NuGet Package Manager
NUnit Test Adapter
Productivity Power Tools 2013
ReSharperPlatformVs12
Telerik ASP.Net AJAX VSExtension
Telerik.CommonPackage
Telerik.TestingFramework
Unit Test Generator
Visual F# 3.1.2
Visual FSharp Tools Templates For VSPro
Visual Studio Extensions For Windows Libraty for JavaScript
Windows Phone 8.1 SDK Integration
Workflow Manager Activities
How to manually invoke remove unused using from CodeMaid?
from codemaid.
Remove unused using statements is a native VS command that CodeMaid invokes. You can manually run it by right clicking on a C# file, selecting the "Organize Usings" menu and then "Remove unused usings".
If it doesn't work in that context either, then either the code is in a state where that won't work (but it looks perfectly valid to me) or there's something in the environment that is interfering with that command now that R# is installed (since it used to work). If however it does work, that would be interesting to note.
from codemaid.
Just checked, it does work.
from codemaid.
Hi, exactly I check Edit->IntelliSense->Organize Usings and it works perfectly. After that I undo changes Ctrl+Z and try with CodeMaid. One more time I got an error.
I also remove Resharper and then CodeMaid run correctly. Then install R# and CodeMaid don't works. Next I remove CodeMaid and install it one more time and I still got an error.
from codemaid.
Are you using the CodeMaid option where the ReSharper cleanup is invoked during CodeMaid cleanup? If you run with default settings does it work?
I use ReSharper all the time so CodeMaid should definitely be compatible with that tool.
from codemaid.
I not sure if I correctly understand you, but:
On CodeMaid Configuration under Compatibility I had unchecked "Run ReSharper silent cleanup when cleaning files".
I checked it, and got:
[CodeMaid Diagnostic 04:10:52 ] WindowEventListener.OnWindowChange raised for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 04:10:52 ] CleanupActiveCodeCommand.OnExecute invoked
[CodeMaid Diagnostic 04:10:52 ] CodeCleanupManager.Cleanup started for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 04:10:53 ] TextEditorEventListener.OnLineChanged raised for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 04:10:53 ] TextEditorEventListener.OnLineChanged raised for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 04:10:53 ] TextEditorEventListener.OnLineChanged raised for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 04:10:53 ] TextEditorEventListener.OnLineChanged raised for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Handled Exception 04:10:53 ] Stopped cleaning 'Program.cs': System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at EnvDTE80.DTE2.ExecuteCommand(String CommandName, String CommandArgs)
at SteveCadwallader.CodeMaid.Logic.Cleaning.UsingStatementCleanupLogic.RemoveUnusedUsingStatements(TextDocument textDocument, Boolean isAutoSave)
at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupManager.RunCodeCleanupCSharp(Document document, Boolean isAutoSave)
at SteveCadwallader.CodeMaid.Logic.Cleaning.CodeCleanupManager.<>c__DisplayClass3.b__1()
at SteveCadwallader.CodeMaid.Helpers.UndoTransactionHelper.Run(Func1 undoConditions, Action tryAction, Action
1 catchAction)
[CodeMaid Diagnostic 04:10:53 ] TextEditorEventListener.OnLineChanged raised for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 04:10:53 ] TextEditorEventListener.OnLineChanged raised for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 04:10:53 ] TextEditorEventListener.OnLineChanged raised for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
[CodeMaid Diagnostic 04:10:53 ] TextEditorEventListener.OnLineChanged raised for 'C:\Users__\documents\visual studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\Program.cs'
from codemaid.
Can you export your CodeMaid and ReSharper settings and make them available?
from codemaid.
I can, I export it but I don' know how to make them available for you. Maybe you provide e-mail address?
from codemaid.
Codemaid on gmail
from codemaid.
Did you get email?
from codemaid.
No I have not
from codemaid.
I resend it from different address. Did you get it?
from codemaid.
Yes I have now, thanks. I will take a look and see if I can reproduce.
from codemaid.
I installed your settings files, but I was still unable to reproduce the issue you have reported. When I ran ReSharper cleanup on the file, it did not remove unused using statements. When I ran CodeMaid cleanup on the file, it worked successfully.
Is there anybody else who is seeing this problem that can provide some more details?
from codemaid.
I can reproduce but am unsure what sort of details to provide.
from codemaid.
@xueye Thanks for offering to help. As many as possible of the following would be helpful:
Visual Studio version, ReSharper version, CodeMaid version. Did the issue manifest after changing any of those tools (e.g. worked fine in VS2012 but broke when upgrading to VS2013). Exports of settings from those three tools. A code sample that exhibits the issue. Any details about when the issue does occur, or doesn't occur if it's conditional.
Thanks again, I'd like to get to the bottom of it as ReSharper compatibility is important but so far I've been unable to reproduce the issue.
from codemaid.
Not a problem, I would love to get this working again and help anyway I can!
- I'm using VS 2013, Update 4.
- I've been using each ReSharper 9 EAP and the Beta, and it's failed on all of them; at the moment, I am running ReSharper 9 EAP 10
- I am using CodeMaid v 0.7.5
- The issue started after installing ReSharper, it worked fine with VS 2013 Update 4 (and 2, 3 I think I had it installed back then)
- The issue occurs anytime I trigger cleanup, through the menu option or the hot key.
- Edit: here's the settings for all three.
I hope that this is all helpful!
from codemaid.
Great, thanks for all those details. I haven't been using the ReSharper EAP, that could certainly be a distinction. I'll try mimicking that configuration this weekend.
from codemaid.
Reproduced with VS2015 Preview and ReSharper 9.
from codemaid.
I've confirmed that the Edit.RemoveUnusedUsings statement is getting into an unavailable state when ReSharper is active. I haven't deduced why yet though, but it is new behavior as of ReSharper 9 as this worked in previous editions.
from codemaid.
I confirmed this behavior also happens if you make a brand new extension. I've reported it to JetBrains and am hoping they can provide some more details.
from codemaid.
Ticket opened with ReSharper: https://youtrack.jetbrains.com/issue/RSRP-428826
from codemaid.
Same problem. Codemaid completely broken, VS2013 pro + Resharper 9
from codemaid.
Agreed, currently waiting to hear back from JetBrains (see ticket above).
The workaround in the meantime is to disable both removal of unused usings and sorting of usings during cleanup. Those can be configured under the Visual Studio panel within CodeMaid's configuration.
from codemaid.
Some very helpful conversation on that JetBrains ticket, recommend reading for those who are interested in more details.
Another workaround proposed by JetBrains:
As a consequence VS commands become unavailable while R# is running. You can turn this behavior off: ReSharper / Options / Keyboard & Menus / Hide overridden Visual Studio menu items.
from codemaid.
My workaround was to email jetbrains and tell them to refund me. I really don't get what all the hype about resharper is anyway. The parts of it that did work slowed down visual studio to give me an experience I havn't felt since the pentium 3 days. Seriously, I'm not sure what benefit the tool is at all. People hype about it everywhere, but not pointing to anything specific that is even useful (like, auto-generating to-string methods. oooo, definitely worth $100+).
from codemaid.
Thank you for the solution!
I still think the tool is definitely worth it, but you need some horsepower to run it.
Cheers!
from codemaid.
Nah it's beyond needing horsepower. I'm running a 4th gen i7 12 gb ram gtx 860. It's piss-poor programming is what it is. (ReSharper, not codemaid)
from codemaid.
I don't know what it will do to performance, but maybe we can toggle Resharper's "hide overridden VS commands" option at the start of Codemaid cleanup, and reset it afterwards? It's not nice and a define R# only hack, but it might just save the day.
from codemaid.
Thanks for the suggestion @willemduncan . It's hacky, but that could work. For now I'm holding out for a cleaner solution from JetBrains.
from codemaid.
Update: JetBrains has addressed this issue and it will be fixed in the upcoming ReSharper 9.0.1 release. See the ticket above for more details.
from codemaid.
I see this issue on VS2012 with R# 9. Will wait for the update and see if it helps.
from codemaid.
Just installed the R# update 1 - it looks like the code that was breaking CodeMaid is fixed.
Happy days again.
from codemaid.
Confirmed as well. :)
from codemaid.
Related Issues (20)
- Progress window text remains cut off
- codemaid.net redirects to the VS Marketplace and linked images are broken HOT 1
- XML Comment formatting eats spacing inside `<code>` block HOT 1
- [[unlikely]] or [[likely]] after if statements break the formatting
- Smart backspace feature
- Shortcut Ctrl+M, Z (Reorganize Active Document) not working on records
- Feature Request: Add option for conditional per-file Automatic Cleanup on Save based on comment at top of file
- Spade takes too long to render document outline. Re-pinning/Re-docking the window seems to solve it. HOT 7
- digging window of cmake project show nothing
- Wrong cleaning up in C# HOT 1
- CodeMaid Causes Visual Studio 22 17.9.3 To Hang and Crash
- Documentation link broken? HOT 2
- Option to Keeping aligned spaces?
- TryDefault regex parsing exception
- CodeMaid Reorganizing Issue VS 2022 / 12.0.344 HOT 1
- Additional "Insert" menu option for toggling
- "Find in solution explorer" not working since VS2022 17.10.0 HOT 2
- Images link broken
- Hope to add a feature to disable or enable automatic addition of access modifiers
- new region for reorganizing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codemaid.