CodeMaid is an open source Visual Studio extension to cleanup, dig through and simplify our C#, C++, F#, VB, XAML, XML, ASP, HTML, CSS and JavaScript coding.
Good extension, but I have some remarks: What for in VS2012 there "Find in solution" in context menu and "collapse all recursively" in solution explorer? VS2012 already has this functions. There would be great if I can configure what buttons to display in context menu and solution explorer. What do you think about updating icons to make them pixel-clear because thy are blurry?
CodeMaid has had and continues support for those commands since earlier editions of Visual Studio (ex: VS2010). You're right that Visual Studio has newly introduced them in VS2012.
I've added a backlog card for voting/comments on configuring toolbar and context menu visibility here: https://trello.com/c/O5ldkODW
I'd be very happy to update the icons, do you know any icon designers who might be interested?
As a C# developer, this tool is a pretty good collection of most wanted tools: easy to learn, easy to customize (e.g. the reorganizing tool). I like the code map displaying regions, embedded methods, interfaces etc., so I easily can navigate between them. Congratulations to the developer of CodeMaid!
I have checked CodeMaid against VS10x CodeMap and I have to say that for my daily work and regarding to what I really need: CodeMaid is on the same Level like VS10x CodeMap.
Can you please add an option to turn off Spade if file is larger than configurable threshold?
I have a file (auto-generated classes from XSD) that is 35,000 lines and Spade takes forever! If I could tell Spade to ignore files longer than say 1000 lines it would be helpful.
Spade should fully run asynchronously - so although it may take a long time for it to load I wouldn't expect a performance hit except on a single core machine. I've created a Trello card for further discussion here: https://trello.com/c/ha1vFRS7
This is a seriously useful extension! I specifically use it to help preserve my sanity against "random whitespace syndrome" suffered by some other devs ;)
I would like to suggest that when you add new Insert/Remove features not to enable them automatically. It can produce unexpected results in the cleanup.
I would prefer using a CheckedListBox for the Insert/Remove items than LinkLabels, but that's a minor nitpick.
Hehe, it is good to help any dev's sanity stay afloat. ;)
That's a good point for discussion about auto-disabling new features for consistency. The big downside is that users would have to manually search through the configuration on each update to find/enable new features. I think it is fairly common to enable new features, and give the user the option to go in and turn them off if they don't like them. Happy to discuss further, I've created a Trello card here: https://trello.com/c/eoLpxzGI for discussion.
That's good feedback. I was trying to be clever and conserve space because those lists get pretty massive - but I have heard a few times that it is not very intuitive. Created a Trello card for that as well: https://trello.com/c/q4QjOEBe for voting/comments.
Thanks for the feedback points, they're certainly appreciated - and enjoy. :)
Would it be possible to have CodeMaid settings be part of the standard Visual Studio settings. This would allow exporting along with all the standard settings.
They used to be built in to VS settings, but I took them out several versions ago. The built in settings does not support nested levels for extensions without registry hacks (which was a source of issues) and the size of the configuration window is a fixed small size. Now in v0.6.0 CodeMaid supports exporting settings as well, but it is an independent step.
Seems like a valuable extension to the Visual Studio IDE, but unfortunately it crashes Visual Studio 2013 for me whenever I open a project. It may be conflicting with another extension I have but I'm unware of it causing any issues.
There is a known issue with VS2012 C++ projects that Microsoft is looking into (https://connect.microsoft.com/VisualStudio/feedback/details/770205/accessing-envdte80-codeclass2-c-members-hangs-vs2012). The workaround for now is to close the Spade tool window which is the part of CodeMaid that is accessing an API which is no longer functioning in VS2012.
If your issue is not with C++ projects, please let me know some additional details and I'd be happy to look into it. BitBucket is where we track issues so that would be the best place to report it: https://bitbucket.org/s_cadwallader/codemaid/issues
I love it. Keeps the code clean. It would be cool if it wouldn't remove the "using" statements required by code that is commented. I sometimes comment out some lines while debugging and if I decide to use that code I have to add the "using" statement again.
Thanks, glad you love it. :) The using statement removal logic comes directly from Microsoft (i.e. CodeMaid just invokes it). You could ask them about it but I suspect they would say it is by design that they don't analyze commented out code.
Steve, you wrote a fantastic tool! We are using it to clean code before running StyleCop and love results. This is one of the best extensions to VS out there. Keep up with a good work!
Really nice extension. I thing though, the CodeMaid Spade fail to parse the `para` tag of the documentation comment, instead it read it as text. Sorry, I can't find a place to post this bug so I post it here.
Thanks for the nice thoughts and feedback. You're right that the para tag was not supported, but I have added support for it and it will be present the next release. Thanks for the suggestion. :)
Summary: Too difficult to pick up and use, requires some seriously dedicated time to learn what the features are, and how they work.
Installation and uninstallation was problematic and frustrating, requiring installing/uninstalling/restarting VS2012 several times.
With a poorly designed configuration window which uses non standard UI interfaces, it makes it difficult to know what auto formatting options are selected, leaving the developer in a position of not knowing what changes are going to happen to the code files they happen to open and close.
Some suggestions to author: 1) Incorporate your configuration window into the VS Options window. 2) Use the already estabilished layout of a list box with checkboxes to select the options the developer can enable/disable, followed by a preview box of how the code is affected by each option. 3) If there are any options that will do 'code cleanup' in the background then those options should be centralised with a clear indicator of when and how those background processes will function.
Initially installed this for the formatting options, but it became unusable for me after constantly hanging on "waiting for background operation to complete" when opening the Spade on certain files. Even after disabling _every_ option and creating a new C++ project.
It's a shame, because I really like the Spade layout (sort of like the Code Map extension before it sold out).
Sorry for the trouble you're having. Unfortunately that is a known issue with VS2012 that I have been working on with Microsoft. Please feel free to vote up the Microsoft Connect issue and keep an eye on it for when it is resolved: https://connect.microsoft.com/VisualStudio/feedback/details/770205/accessing-envdte80-codeclass2-c-members-hangs-vs2012
The issue shows the last update is on November 9th but I've been talking to them for several weeks past that and am still hoping for a resolution.
Steve you've got 5 stars from me! My favourite extension, no doubt. Since I'm mostly using Code digging tool (McCabe software quality metric) for QA purposes, I'd like to ask you for a feature of turning off or ignoring switch-case statement for McCabe results. I know that this statement is included when measurig Cyclomatic complexity, but since most of switch-cases are easily readable, OK for maintaining and sometimes there are no space for introducing new classes for eliminating them with the use of switch-case design pattern (polymorphism), it would be great if not including McCabe results for these type of statements would be configurable. One more very usable feature would be sorting methods in CodeMain window by McCabe results. Many thanks for your effort! Keep up the good work
That's great, I'm really glad to hear the complexity calculations are helping you out.
I have added two new cards to the backlog for your feature requests: * Customize complexity results: https://trello.com/c/bRagJvzB * Sort by complexity: https://trello.com/c/mWSOjEvS
Be sure to check those out, add more comments if I missed anything and vote them up.
If you didn't notice, in the latest release I added a tooltip at the class level that will show you the most complex item. I think you may find that handy, here's the card with screenshots: https://trello.com/c/mNhnA7HK
Thanks for the great review and suggestions. :) -Steve Cadwallader
Sorry to hear it. If there's anything you'd like for me to look into please open up an issue on BitBucket (https://bitbucket.org/s_cadwallader/codemaid/issues) and I'd be happy to take a look.
Hey Steve,
I seem to be getting a bug where once-in-a-while I'll hit undo a few times rapidly and VS2010 will completely freeze up. I can't say for certain that it's CodeMaid, but when it freezes, the status bar always says that CodeMaid is cleaning the file. Is this a known issue?
(Your add-on is a god-send, by the way)
Cheers
Hi fasdewx -
I haven't heard of that issue before. CodeMaid usually won't be running during an undo operation. The possible exception that comes to mind is if the undo causes a save, which with the automatic cleanup on save option enabled would cause a cleanup to run. Visual Studio will automatically save the code during refactoring operations (ex: rename) but from what I can see they don't put those actions into the undo stack.
A few things you could try to get more information:
1. Is the status bar still showing the cleaning message from a previous operation before you undo, or is it starting cleaning during the undo?
2. If you disable the option to run automatic cleanup on save and run for awhile, do you still see the issue?
3. Are files being opened and closed during the undo operation?
Very glad to hear you're enjoying CodeMaid. :) Please let me know if you get any more information about the possible issue.
Thanks,
-Steve Cadwallader
You may be onto something with the refactoring - it *just-now* froze when undoing a rename operation. I'm not sure on #1 (pretty tricky to look out for, given the rarity of crashes), and will try #2. As for #3, as far as I'm aware, no files are being opened or closed. I'll certainly keep an eye out and see if I can find something reproducible :)
Thanks for the update.
I've recently added a new configuration option which by default will disable removing unused using statements during the automatic cleanup. It will avoid a few other issues that can occur and may also help with the issue that you were seeing. The option will be available in the next release.
Hi
Have to say again (I wrote a while ago on Github) Well done and love it!
One thing that has me puzzled is what do the numbers mean at the end of a method on Snooper? I can't figure this out!
And as for suggestions, I would +1 on what someone else said below on sync region open/collapse... If I double click on something from a closed region, it will go to it - I would just like to see this added as it would "complete" it.
Less important would be to double click to select the entire method and possibly a few other tweaks such as drag to reorder... but, less bothered on that.
In addition, Maybe I need to choose a better font/colour scheme, but, after clicking, sometimes it still takes me a few seconds to focus/work out where I should be looking - it would be great if you could do something like highlight a colour then fade back to default.
Also, one little bug, but, it could be me and if it isn't it is so minor, I wouldn't worry! - I just upgraded to 0.3.7, setup told me to restart, but, I didn't! I went straight in the CodeMaid menu, it states 0.3.6, but the about page says 0.3.7 - perhaps a restart will fix this, if it doesn't, again, so minor, but, thought you may want to know!
Sorry, didn't know it would loose formatting :( Looks like an ugly wall of text :( ... All the suggestion... Don't mean to sound ungrateful and want to say again, thanks for such a great addon!
Hi William -
Thanks for the compliments, glad you're enjoying it. :) Yeah the newline stripping here in the forum is annoying - hopefully they fix that soon.
The numbers in the snooper are McCabe complexity scores. If you're not familiar with them you can read more here: http://en.wikipedia.org/wiki/Cyclomatic_complexity . It will be a little more obvious what those numbers mean in the next release with some better tooltips.
I've actually been working on a rewrite of the snooper for the next big release. It is now WPF based and will run asynchronously for supporting larger files. Drag to reorder is one of the features I'm planning to include but haven't implemented yet. The styling has been redone and there are some new configuration options including controlling where the element is shown (centered on name or centered on whole element) that you may find helpful. I'll bump the region syncing up the priority list - I'm not sure if it will make it into the first release.
You do need to restart Visual Studio for the menu items to get updated and show the correct version number - so that should take care of it.
Suggestions are always welcome so no offense taken. :) Thanks for the recommendations and keep me posted if you think of any others.
-Steve Cadwallader
Dear Steve, I hope I'm not going on your nerves. But after using the extension now for some time there's one thing I find annoying. IMHO, the primary purpose of the snooper is navigation. Now when I click on any item there, it takes me to the line that contains this item. But the editor does not have the focus, so I have to click once more in the editor. Actually the editor has some kind of half-focus; you can see this when highlighting the current line. I'm obviously able to move around with the arrow keys, but cannot write. My suggestion would be to place the cursor at the beginning of the item's name ready to write. And while you're at it, it would be even greater to center this line then instead of having it at the top (ReSharper style). Cheers, Tobias.
Hi Tobias -
No worries about the nerves, but maybe I should start a frequent flyer club? ;) Seriously though, I do appreciate the feedback.
I've seen the focus issue you are talking about and anticipate having it resolved in the next release. As for the editor window scroll position I chose to put the element at the top of the screen so the maximum amount of code would be visible for large elements (ex: a complex method). I will add it to the backlog to look into extending the calculation to center smaller elements.
Thanks for the input,
-Steve Cadwallader
That's good to hear; it'll make me much more productive. ;-)
You got a point there with the scroll window positioning, sure. But it's strange when use also use other plugins that behave differently. May it could become a configurable option?
Thanks, Tobias
Hi Tobias -
I was thinking of looking into making the whole element centered on the screen (vs. starting at the top) as a compromise between the two approaches. That way the largest amount of the element is visible, and it is in the center of the screen as well. It is a little different than others which just put the starting line in the center of the screen and half of the screen is wasted for large elements. What do you think? Otherwise I can certainly put in an option to have it simply be at the top or center of the screen.
Thanks,
-Steve Cadwallader
Yes, I think that'll be better than on top. Nevertheless I think, an option to have it exactly in the middle would be helpful to some. At least my spinal cord would then be instantly looking at the correct line. :-)
Anyway, correct focus has priority to me.
Hi Steve, I'm back with new suggestions. First, I'd like to see the folding of regions synchronized between the editor and Snooper (optionally) in both ways. Another thing falling in the region category would be the following. Close all manually created regions (i.e. all #region tags). To get an overview I like to close everything too see my “headings”. Unfortunately, VS does not provide this. Pressing Ctrl+M, Ctrl+O does too much. This also closes all summaries and bodies. Do you get what I mean? If I wrote “#region” four times in a file, then only four folds should be closed, the rest should remain unchanged. I'd even like to have a dedicated button in the Snooper for that.
Regards,
Tobias
Hi Tobias -
Thanks for the additional suggestions :). I've added the first (synchronize expand/collapse state between code and snooper) to the backlog. For the second I believe Visual Studio will do that by default when you open a document, but it isn't one of their Outlining options so you can't get back to it. The option I'm thinking of is under Tools->Options->Text Editor->C#->Advanced->Enter outlining mode when files open. Is that the feature you're thinking of, just accessible again after the file is open?
Thanks again,
-Steve Cadwallader
Hi Steve, I know the feature that you mentioned, but it only sometimes works for me. Maybe because of ReSharper remembering folds solution-wide or something similar. According to the MSDN, the “first time a file is opened, #regions blocks and inactive code blocks collapse.” This sounds like the feature I'm looking for. But as you say, it's not available on demand. But it'll probably be a function easily available to a plugin?
Hi Tobias -
I took a quick look through the VS API and did not see any access to that functionality. Invoking the existing commands (ex: collapse to definitions) is available but that can already be easily done. There is the API for manually collapsing a selected region of text but it will take a little more work and may have consequences to the current document state.
I'll add this feature to the backlog and dig deeper at that time to see what other options may be available.
Thanks for the suggestion,
-Steve Cadwallader
Hi, I like that tool very much. The Snooper has replaced the CodeMap plugin that I was using. But there is one thing that I miss since switching: CodeMap had a dedicated icon for constructors (green plus) so that you could spot them very quickly. I'd love to see that feature added.
And a second thought: As you're rewriting files anyway, how about changing order of elements? Like fields before properties before constructors before public methods etc. or private->protected->public? Similar functionality is offered by Regionerate.
Thanks for sharing!
Hi primfaktor -
I'm glad to hear you're enjoying CodeMaid. I'm currently using Visual Studio's conventional icons in the Snooper window, but I agree it would be nice for constructors to stand out. I think it would also be helpful to depict additional things, such as which methods are static. I've looked for alternate icon sets in the past but didn't really find anything in the public domain. If you happen to know of any please let me know.
I've got automatic reordering of code elements listed in my backlog. Nobody has requested it before so I haven't prioritized it, but I'll give it a bump if you think it would be handy.
If you have any other suggestions for the snooper please let me know. I'm actively working on a rewrite to make it load asynchronously and utilize WPF for a richer UI.
Thanks for the comments,
-Steve Cadwallader
Hi again. I would not change from the VS icon too much, because these are the ones we're used to and recognize instantly. Only some minor changes. I tried to do a little mock up; you can find it here:
http://imageshare.web.id/images/c3ewvcsdh9e0b61mii.png
I did not know the font settings used, so it looks a little weird. But you should get the idea. For the constructor icon I went an even easier way, I just recolored it.
One thing that just happened when writing the code for the mock up. I closed another file for the screenshot. It was the only other file opened and I did this by clicking its close icon without activating the tab first. Then the snooper window contents vanished. It then looked like this:
http://imageshare.web.id/images/ykolb3tckh49k1i4q9j.png
Hitting Ctrl+S on my test file did not bring back the content. I had to click the "{}" icon, then it came back. I think I observed this once before. When is the refreshing of the Snooper done, on saving?
Hi primfaktor -
Thanks for the mockups, I really appreciate you taking the time. :) I'll consider keeping the standard icons and making some variations for the additional states/information beyond what the built-in ones provide.
I have reproduced the bug you saw where the snooper window is not always populating when other documents are closed. It currently catches window activation changes and save events to populate/re-populate itself, but apparently there is a scenario where the event is not getting raised as expected. I should have that fixed in the next release. As a workaround you can click the snooper window, then click back to the document. That will raise the window activation events and the snooper should(tm) populate.
Thanks again for your input/mockups :)
-Steve Cadwallader
Hi, i just installed this tool and ran the Cleanup All Code command on one of my projects. It worked ok and I think this is a great tool.
Here are my suggestions:
1) Add a toggle for Inserting a blank line of padding before/after Auto-Implemented Properties in the Configuration.
2) Add the following file types to the default Excluded file types in the Configuration: .settings; AssemblyInfo.cs
Hi David -
Thanks, I'm glad you like it. In regards to your first suggestion I agree that would be helpful and I would probably extend it to any single-line property vs. only auto-implemented properties. I've added it to my backlog. In regards to the second I am on the fence. I tend to hand edit AssemblyInfo.cs files so I like to clean those up, but .settings files I don't generally utilize so I could see those. I'll probably leave it as is for now unless I hear some more requests but you can (as I'm sure you already found) simply change it in your own configuration.
Thanks again for the nice feedback and suggestions,
-Steve Cadwallader
Hi, very, very nice and useful tool. Trying to reformat a couple of thousand of XML-files of various kinds in a couple of hundred projects. However - it's inconsistent when working with XML. It tends not to run the 'Format Document' command - but if I open the document and then use code maid to clean it, it works. It appears to work perfectly with C#. It's probably some kind of issue with the interaction with VS 2010. I looked at the code, and can't see any significant difference between how XML and C# files are handled in this case.
Any ideas, have you heard of anything like this before?
Hi Svante -
Thanks for the nice comments. :)
I haven't tried running that many XML files through at once, but I have done thousands of C# without issue. I haven't heard anyone else mention the issue. The best workaround that comes to mind is to do a project at a time - although not as nice as walking away.
I think you're probably right that a race condition is occurring where the document is not fully loaded so the format document command doesnt work as expected.
Let me know if you have any other thoughts or details. Thanks,
-Steve Cadwallader
Hi Steve. Did a little deep-dive into the issue, downloaded the source and did some debugging and research. It turns out to be a problem. Consistently. It's in fact been reported in similar circumstances before, try google for "Edit.FormatDocument XML" (without the quotes). There are several links on the first page of hits that describe the problem. Essentially - if the extension opens the document window via code it fails. If it's open to start with it works. I'm actually a bit stumped, I've tried quite a few things in order to either understand the issue better and/or find a workaround. No go. It just won't play nice. Too bad, I'd have liked to contribute a fix, but I'll have to see myself beat at this time. I can't spend more time on the issue right now. Do you have any channels so this can be researched by the VS team in our lifetimes?
On another note, I have made a stand-alone utility that follows the reference dependency tree and builds solution files with all references included, and some similar operations. It has proven to be a great tool for refactoring large code bases, and in general to create clean and complete solution files for very large code bases. I've used in on a 200-project code base with great success. Seeing your nice VS add-in I see that it might be useful to integrate the two, to provide a 'Clean Solution' feature perhaps or something similar. Interested?
Hi Svante -
Do you think it could be an issue with the document not being fully loaded at the time that format document is called? Perhaps there's a document loading event that can be caught, or some latency involved. Which approaches did you try?
Can you tell me more about your add-in or point me towards it if it is publicly available?
Thanks,
-Steve Cadwallader
Hi! Yes, it's an issue with events occuring after the document being loaded. Strangely enough it seems to only affect XML documents. The issue is there as soon as automation + XML is involved, and I've not been able to figure out a way to wait for it to be ready. It appears to require some time idle in the user interface. I've tried delays both in the background thread and the UI thread, I've tried loading the document in either thread, I've tried various ways of simulating a 'get focus' in the document window in combination with delays, I've tried wating for 'input idle'. I've not even been able to get a keyboard macro to work. I am no automation expert, and I'm totally frustrated. The solution I have now for my immediate issue is to run a keyboard macro for each document, and then wait for the visual markers of collapse/expand to appear in the editor window - then Format.Document works, and only then. My solution builder is not an add-in at this time, and I've not yet published it but when I get the time I can put it up on CodePlex, or I can just send you a zip.
Hi Svante -
It sounds like you've covered all the bases that come to my mind as workarounds for the XML document loading issue you've seen. The best remaining recommendation I have is to post it to Microsoft Connect and see what they have to say. If you have a minimal reproducible solution that tends to get the best results.
Feel free to keep me keep me posted as you evolve your solution builder. You can reach me more directly via e-mail to codemaid at gmail.
Thanks and good luck,
-Steve Cadwallader
How about a small help file? or at least a quick start. I've been using this tool for a couple of weeks, it's pretty intuitive, but still there are some stuff I don't know.
E.g.: What does mean the number next to members in the "CodeMaid Snooper".
Great tool. Thanx!!
Hi Scaredfinger -
You're right, adding some documentation would be helpful. I've been meaning to do it but keep putting it off because I'd rather be coding. ;) I've bumped documentation back up the priority list and if you have any ideas for things you think should be mentioned in a quick start please feel free to let me know here or by e-mail to codemaid at gmail.
To answer your example - the numbers alongside methods and properties within CodeMaid's Snooper are McCabe cyclomatic complexity scores. It is a metric that calculates the different number of branches within a block of code where the higher the number the more complex the logic. For more details check out this wikipedia page: http://en.wikipedia.org/wiki/Cyclomatic_complexity
Very glad to hear you're enjoying the tool, thanks. :)
-Steve Cadwallader
Hello,
CodeMaid is a great product and thanks for the cool features!
I have a minor issue: Some VSTS solutions of ours need not CodeMaid run at all. Is there a way to disable the tool in a particular solution?
Thanks in advance and have a great one!
Hi codeguardian7 -
Thanks, I'm glad you like it. :)
There is not currently a way to set solution specific configurations for CodeMaid. I am working on integrating CodeMaid's configuration with the Visual Studio export/import settings process which would be a step in this direction - but would still require a manual action.
If you're primarily concerned about the automatic cleanup, you can easily enable/disable that behavior in CodeMaid's configuration (CodeMaid->Configuration->Cleanup->General->Automatically run file cleanup on file save). You can toggle this on/off as needed or leave it off and invoke code cleanup on demand as an alternative.
Hope it helps,
-Steve Cadwallader
Hi codeguardian7 -
Glad that it helps. I've added solution-specific configurations to the wish-list backlog of things I hope to get to someday. :)
-Steve Cadwallader
Hi Steve,
Ive been using your cool addin long time now, but recently I have encountered more of these dialog boxes when doing a rename refactoring in VS2010:
---------------------------
Microsoft Visual Studio
---------------------------
Binding failed because IntelliSense for source file 'G:\Dev\Main\Src\Borealis.Acos.Database.DataGenerators\EnumGenerator.cs' is out of date
---------------------------
OK
---------------------------
I'm not 100% sure this is caused by CodeMaid itself rather than some integration between VS2010 and an addin.
The same problem is reported with users that have the Power Commands addin installed. However, I only have CodeMaid v0.3.4 installed.
see also this connect issue: http://connect.microsoft.com/VisualStudio/feedback/details/539445/renaming-an-event-handler-produces-an-error-dialog
Hi Rudi -
Thanks for the nice comment. :) That issue is a new one on me, and like you say the little information available under the connect issue points to it being potentially related to extensions. If you disable CodeMaid, are you still able to reproduce the issue?
Thanks,
-Steve Cadwallader
Hi Tonka78 -
I can reproduce the issue as well, but unfortunately I do not have a resolution. The exception occurs within Visual Studio's code after CodeMaid catches and automatically runs code cleanup. A workaround is to disable CodeMaid's automatic cleanup on file save and perform cleanup manually. Another workaround is to use a third party tool (ex: ReSharper) to perform renaming.
Without more information from Microsoft I'm not sure how to proceed with resolving this issue. I have added comments to the existing Microsoft bug report here: https://connect.microsoft.com/VisualStudio/feedback/details/539445/renaming-an-event-handler-produces-an-error-dialog I recommend you add your vote/comments to the issue to try and garner more interest from Microsoft in looking into it further.
Thanks for your report,
-Steve Cadwallader