Git Product home page Git Product logo

Comments (35)

codecadwallader avatar codecadwallader commented on July 30, 2024

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:

  1. If you manually invoke remove unused using statements, does it also throw an error?
  2. What changes to the file are happening during the R# cleaning of the file? Can you provide examples?

from codemaid.

dudekkrzysztof avatar dudekkrzysztof commented on July 30, 2024

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, Action1 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, Action1 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.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

philbarresi avatar philbarresi commented on July 30, 2024

Just checked, it does work.

from codemaid.

dudekkrzysztof avatar dudekkrzysztof commented on July 30, 2024

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.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

dudekkrzysztof avatar dudekkrzysztof commented on July 30, 2024

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, Action1 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.

codecadwallader avatar codecadwallader commented on July 30, 2024

Can you export your CodeMaid and ReSharper settings and make them available?

from codemaid.

dudekkrzysztof avatar dudekkrzysztof commented on July 30, 2024

I can, I export it but I don' know how to make them available for you. Maybe you provide e-mail address?

from codemaid.

codecadwallader avatar codecadwallader commented on July 30, 2024

Codemaid on gmail

from codemaid.

dudekkrzysztof avatar dudekkrzysztof commented on July 30, 2024

Did you get email?

from codemaid.

codecadwallader avatar codecadwallader commented on July 30, 2024

No I have not

from codemaid.

dudekkrzysztof avatar dudekkrzysztof commented on July 30, 2024

I resend it from different address. Did you get it?

from codemaid.

codecadwallader avatar codecadwallader commented on July 30, 2024

Yes I have now, thanks. I will take a look and see if I can reproduce.

from codemaid.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

philbarresi avatar philbarresi commented on July 30, 2024

I can reproduce but am unsure what sort of details to provide.

from codemaid.

codecadwallader avatar codecadwallader commented on July 30, 2024

@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.

philbarresi avatar philbarresi commented on July 30, 2024

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.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

codecadwallader avatar codecadwallader commented on July 30, 2024

Reproduced with VS2015 Preview and ReSharper 9.

from codemaid.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

codecadwallader avatar codecadwallader commented on July 30, 2024

Ticket opened with ReSharper: https://youtrack.jetbrains.com/issue/RSRP-428826

from codemaid.

 avatar commented on July 30, 2024

Same problem. Codemaid completely broken, VS2013 pro + Resharper 9

from codemaid.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

 avatar commented on July 30, 2024

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.

mzolnowski avatar mzolnowski commented on July 30, 2024

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.

 avatar commented on July 30, 2024

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.

w5l avatar w5l commented on July 30, 2024

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.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

codecadwallader avatar codecadwallader commented on July 30, 2024

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.

sriv avatar sriv commented on July 30, 2024

I see this issue on VS2012 with R# 9. Will wait for the update and see if it helps.

from codemaid.

MikeLooper avatar MikeLooper commented on July 30, 2024

Just installed the R# update 1 - it looks like the code that was breaking CodeMaid is fixed.
Happy days again.

from codemaid.

codecadwallader avatar codecadwallader commented on July 30, 2024

Confirmed as well. :)

from codemaid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.