Monday, March 29, 2010

New CodeRush Plugin: CR_RemoveRegions

Not much to say here other than that this plugin was inspired, nay requested, by Mr @JayRWren

Place your caret on a region and invoke this like refactoring and *all* regions in the current file will be removed.

Personally I like regions. I feel that when used judiciously, they add to code in the same way as comments. Obviously they can be abused, but that’s the same with any feature.

In any case… Jay requested it so I felt it only reasonable to provide him with this little plugin. Especially since it only took me about 20 minutes including time to make some coffee. :)

So here you are… CR_RemoveRegions  Enjoy.

Tuesday, March 16, 2010

New CodeRush Plugin: DX_DirectOptions

This is a very simple plugin that I developed, like most of DX_DirectOptionsmy plugins, to help me save some time. In this case it’s a very small amount of time.

In 90%+ of all cases when I’m loading the CodeRush options screen, I want to use either the “Templates” or the “Shortcuts” pages.

Therefore I have created a plugin which does nothing more than provide actions and menu options to launch each of these directly.

Simply install the plugin in the usual way and then restart either the DXCore or Visual studio.

When the restart is complete, you should have 2 additional menu options in your DevExpress menu.

[Note: The “Templates Options” menu item will only be present if you have the full CodeRush, or a trial of same, installed.]

Additionally these actions exist in their own right allowing you to bind a key to them if you want to. Their names are “ShowTemplateOptions” and “ShowShortcutOptions” respectively.

[As above: If you only have CodeRush Xpress installed, then the “ShowTemplateOptions” action will not have registered itself and will not be available.]

This plugin still loads the other options pages, but will ensure that the page you indicated is the one selected.

For more details, see the DX_DirectOptions’ wiki page

I'm considering placing these entries on their own submenu. I can envisage a scenario where other options pages get nominated for this and the list of entries on the DevExpress menu gets a bit overwhelming. I would supply an options page myself for picking which of these might show up in the menu.

Also It’s been suggested that these menu options should perhaps have their own Accelerator keys


Thursday, March 11, 2010

New Plugin: DX_GuidGen

I couldn’t find a StringProvider in CodeRush that would output a new Guid. So I built one :)

It’s a pretty simple plugin but I put up a wiki page anyway and you can download it from here.

Yeah I know…. There are many ways to produce this same behaviour, but I liked the idea of writing another simple StringProvider, because it allowed me time to additionally create the ‘NewStringProvider’ CodeRush template I recently added to my plugin templates.

Enjoy :)

[Note: I firmly believe that having taken the time to create this, and post it up on the web in this way, that I will find out it actually duplicates some CodeRush functionality in about 2 minutes from now.]

Yet More Designer Free CodeRush Plugins

Yup I have updated my Plugin Templates (Originally started here and continued here) to include a further 2 templates:

  • NewStringProvider
  • NewTextCommand

Again I have provided these in both C# and VB.Net so if you can find any flaws, or have ideas for improvements you’d like to see made. Just email me … and I’ll see what I can do :)

Plugin templates are available here.

Wednesday, March 10, 2010

More Designer Free CodeRush Plugins

[Update: I am now receiving help (from @surekill) for my chronically poor VB.Net –> C# conversions :D (Personally I blame the late nights). These templates now suck less :)] 

A couple of days ago (Erm I think) I posted here on how to use these new templates ….

  • NewAction<Space>
  • NewRefactoring<Space>
  • NewCodeProvider<Space>
  • NewIssue<Space>

… to kickstart the building of new plugins for the DXCore.

Well since then I’ve added 2 additional templates to those already provided

Now you can also call upon…

  • NewNavigationProvider<Space>
  • NewSmartTagMenu<Space>

The first of these produces code which will create items for the CodeRush “Jump To” menu.

The second one gives you code to produce your own menus (Like ‘Refactor’, ‘Code’ and ‘Jump To’)

The zip file which contained my previously exported templates now includes these 2 new ones… So feel free to download again, import them and get cracking on some new plugins :)

Tuesday, March 09, 2010

New plugin: CR_NavigateToDefinition

[CardsOnTable:I did not write this plugin. It was written by Jorge Rowies. Thanks so much Jorge. My life, at least, is now much easier]

I know what you’re thinking…. You’re thinking “Why the **** do I need a plugin for that?”… You’re thinking “Studio already does that!!”.

Please just bear with me… All will become clear[er]

So for those who aren’t already at this point let’s spin back a bit first.

What does this plugin do?

Well this plugin will navigate from a type or member to the declaration of that type or member. Which is to say it will find the source code of that element and position your caret on it.

Why do I need this plugin?

Well you might not. this plugin is built to serve an edge case scenario that might not apply to you.

Visual studio already has a function “Goto Definition” which appears to serve the same purpose as this plugin.

Visual Studio Limitations

Visual studio is capable of finding the source you are looking for if the source you are looking for is…

  • …in the same project as that from which you start.
  • …in a project referenced (only a project reference will do) from the project from which you start.

If you use file references then you are normally out of luck.

Why would I use File references if I have the source?

Well your reasons may vary…  I myself have 3 reasons:

  1. Historically (VS2002, VS2003) had some file locking bugs which appeared to lock the produced binaries when intellisense accessed them which would prevent a rebuild until VS was restarted. (This was the reason we switched to File references only in the first place. It probably no longer applies.)
  2. For performance reasons it can be useful to be able to carve up your solution into multiple sub-solutions in order to work on a smaller section of the problem you are assigned to. Using File references allows you to do this quickly and easily as you are already referencing the binary versions of everything. (I have not had to do this in a while because CodeRush’s performance is really that good. But back in the day I had very poor hardware and CodeRush has not always been as performant (Damn it! It’s my blog and I say that ‘Performant’ is a perfectly valid word) as it is now.
  3. We have an external build process which builds reference versions of our dlls etc under known conditions. These are the files that ultimately go into out installers and therefore it makes sense that these are the versions of the files that are actually referenced by the various projects in a solution.

Other uses

So imagine that you’re coding against a 3rd party open source library. (Could be ASP.MVC. Could be Log4Net could be anything really.) You are referencing their binary because frankly you don’t see the value in trying to build their source as well as your own, but it’s comforting to  have it there in case you need it.

Now suddenly you come across a need to understand something about it’s internals. You have 2 choices:

  • Load the OS solution in a new copy of studio
  • Add the OS solution’s project’s to your existing copy of studio

The first of these is the simplest, but you now have to navigate through the OS solution as a separate entity which has no connection to your own project. Thee is no easy way to navigate between the OS solution and your own.

Instead consider adding their solution’s projects to your own. In some cases this is madness as they will have 15 or more projects and things can get out of hand very quickly. However in some cases like ASP.MVC or Log4Net, there are few projects in the OS solution and these can be added very quickly.

Normally this would not have provided any advantage. You would ask VS for the definition of ‘Controller’ and would be greeted with a wonderful view of the Object browser. This will of course give you a view of what members the ‘Controller’ has, but would do nothing for helping you learn how it worked…

With CR_NavigateToDefinition in place, you can now jump directly from a usage of ‘Controller’ to it’s actual definition in it’s own project and you didn’t have to alter any of your own references to do it.

If this plugin interests you you can find further details here

Monday, March 08, 2010

RedGate – Conducting ‘ANTS 6’ UX Testing

I have been asked by RedGate (Very clever people who bring your SQL Compare, Reflector and others) to see if any of you might be interested in helping out testing their upcoming Version 6 of ANTS Performance Profiler.

There are a few requirements:

  • You must be .NET Developers (who use either C# or Visual Basic .NET)
  • You must be using Windows Vista or Windows 7.
  • The application you are working on is either:
    • Reasonably File I/O bound (i.e. lots of reading and writing from disk) 
      • and/or
    • The .NET application makes use of SQL Server but it must NOT be SQL Server Express. You must also be using a local instance of SQL Server (i.e. the instance must be on the same computer as the process being profiled).
  • You are not using the Compact Framework (very unlikely but you never know)

The session is run remotely, only lasts 1hr and you only have to share your screen – RedGate wouldn’t have any control of your computer.

If this interests you in any way, email me ( with a subject line of “ANTS 6 UX Testing”, and I’ll see it gets to the right people.

Sunday, March 07, 2010

Designer Free CodeRush Plugins – The new CodeRush plugin Quick Start

Explaining how to start a new CodeRush plugin can be a little complex.

So I’ve knocked up a few CodeRush templates that should make it a lot easier :)

Step 1 - Import these Plugin Templates into your copy of CodeRush.

(DevExpress\Options … Editor\Templates … Right-click Templates … “Import Templates…”)

Step 2 - Create a new DXCore Plugin project via the “New Project” dialog

Step 3 - Activate any one of the following templates inside your plugin class.

  • NewAction<Space>
  • NewRefactoring<Space>
  • NewCodeProvider<Space>
  • NewIssue<Space>

You should now have a “CreateMyX” method which….

  • Creates the relevant component
  • Adds it to the components collection
  • Sets up the minimal mandatory properties.
  • Creates the relevant event handlers.
  • Attaches said event handlers to the component in question.

For example, one of the more simplistic things you might want to do is to create a new custom Action to Bind to a Key.

Here is the Default DXCore plugin as written in CS…


And here is what you get after executing “NewAction<Space>”  CSActionPlugin

After a little customization…  CSHelloWorldPlugin

The only think you need to do .. Is to call your new “CreateMyX” method from inside the “InitializePlugIn” method

You have a completely functional Hello World action ready to be bound to the key of your choice

Now you have to admit … That makes things a lot simpler…

I’ve even linked a few sections of code together with some CodeRush «Field» and «TypeLink» tokens in order to make customizing of that default code a little easier.

So if you’re interested in making plugins…. This should make things a little better.

Feel free to leave me some feedback… I’ve done my best to convert the original VB.Net versions to C#…. So it’s possible there were some issues in translation… But that’s what you get for picking such a strange language (I mean C# people… VB.Net FTW! :D)