Posted


Blog Review Tips Visual Studio Extensions

I tend to use lots of different tools to make my job easier, nearly all are free and available to everyone right now. Every now and then I will write about one, whether it be a tool kit, extension, utility, service or just a cheat sheet.

A few years ago I was lucky to have ReShaper available at a previous employer, it’s a great tool if you can afford it, if you don’t fancy paying a premium for a great set of tools you can get a chunk of what ReSharper does with free tools, it won’t be as nice as the real thing, but it’s almost there. 

resharper
via

If you can afford to use ReSharper I would definitely recommend it, otherwise keep an eye out for more in this series as I will cover what I use instead.

So first up in the series of tips; Codemaid, it’s a free VS extension, available for VS 2010/2012/2013. To get started with CodeMaid, first install it from the “Extensions and Updates” gallery within VisualStudio, it even works with ReSharpers clean-up tools if you are lucky enough to have it.

codemaid
codemaidwithresharper

A nice feature included in CodeMaid is “Find In Solution”, I’ve never understood why this hasn’t made it into power tools or ever VisualStudio itself for that matter. It seems so simple, yet saves me so much time. It’s pretty simple, when I am working on a piece of code I can find it in my solution Explorer by right clicking on the code, click on the mentioned option and my solution explorer shoes where the file exists in my solution, simple really.

codemaidfindinsolution

CodeMaid’s main feature was always going to be clean up of code, and it does it really well. The currently support file types are

C#, C++, F#, VB

XAML, XML

HTML, CSS, LESS, SCSS, JavaScript, TypeScript

codemaidfiletypes

It will also ignore T4 generated code if you like, along with any other files you like that match a RegEx. I’m not sure about other coders, but that covers pretty much everything (JSON?).

Most of what CodeMaid does can already be done in VisualStudio, but they had added bits to it, or made it slightly easier. For example the remove and sort function runs on save (along with my clean-up, which are both optional), however you are also given the option to reinsert using statements into files, which is pretty handy, especially on some of my projects that use Linq heavily.

CodeMaid is great at inserting line breaks, or the odd keyword to keep the code clean and stick to current conventions (All can be turned off if you don’t tend to follow them), it will insert lines before, after and between pieces of code, a few examples being:

Before namespaces

Between multi-line property accessors

After methods

And insert blank space before self-closing angle brackets

codemaidinsert

It will also add explicit modifiers on pretty much everything, which has come in extremely helpful when tidying up code, as things can so often slip through the net.

The tool will, naturally remove blank lines and spaces, and can even remove regions if you have decided not to use them.

codemaidremove

Talking of regions, it has a few region focused features: CodeMaid can add them in, sort them out, remove them entirely, add names to the close, it even uses them on the CodeMaid Spade

CodeMaid Spade is like the member drop down on steroids. It makes navigating the currently loaded piece of code so much easier than before, you can sort my by type and alphabetically, it shoes all the info you would expect and how many times they are used in your code.

codemaid-spade

Finally the extension can also be used on all of your code at one, after using CodeMaid for a few months I decided that I wanted all the files to be cleaned. It took a while to process and took even longer to check through just in case there where breaks in the code (There wasn’t and it worked perfectly). After running it I didn’t realise how messy I had been in the past, it is now set to run on save, so from now on I will have a much cleaner code base.

So that’s my thoughts on CodeMaid, for a free tool it really is awesome.