So you want to write a CodeRush plugin

You have a simple idea for a CodeRush plugin.

  1. An Action you’d like to trigger from your IDE.
  2. A Refactoring or a CodeProvider you’d like to add.
  3. A new Context which you could use to fine tune the availability of your templates.
  4. A StringProvider, a TextCommand or a Code Issue.

But you can’t be bothered with all of that drag and drop visual designer business.

Visual Designers are Slow

From the moment you reach for the mouse you know you’ve already lost speed. Visual designers aren’t just slow though. They’re very awkward to use. Even if they responded at the speed of light, they’d still be awkward to use.

Assuming that they invoke instantly, you still have to wave that mouse around all over the place in order to get anything done at all.

For a simple control/component with 2 properties and 2 events the procedure is something like this.

  1. Mouse –> Open Toolbox
  2. Mouse –> Drag control onto design surface
  3. F4 –> Bring up properties tool window
  4. Mouse –> Scroll to find property
  5. Mouse –> Select property
  6. Keyboard –> Set property value
  7. Mouse –> Scroll to find property
  8. Mouse –> Select property
  9. Keyboard –> Set property value
  10. Mouse –> Click event tab in properties toolwindow.
  11. Mouse –> Scroll to find event
  12. Mouse –> Double-click Event to produce event handler.
  13. F4 to return to properties tool window
  14. Mouse –> Click event tab in properties toolwindow.
  15. Mouse –> Scroll to find event
  16. Mouse –> Double-click Event to produce event handler.
  17. That’s 8 mouse operations and 4 keyboard operations. It’s also 8 context changes (Mouse –> Keyboard or Keyboard –> Mouse)

    There have been improvements in this area (The toolbox can be searched or filtered using the keyboard), but so much switching from mouse –> keyboard –> mouse can’t be a good thing. Now I know what you’re thinking. There’s likely some set of really easy to remember set of keystrokes that can emulate all that mousing around. Yeah I’m sure I heard something like that once as well, but I sure can’t remember it now. It obviously wasn’t that intuitive.

    So what’s the alternative?

    Enter… CodeRush

    Well what is the toolbox ultimately used for? That’s right, it’s an easy way to write code quickly.

    Ok well CodeRush already has many ways to write code quickly. One of the most effective of these, is also one of the easiest to use.


    Type a few characters…. Hit space… Oh look there’s your code. Awesome!

    So back to the main point of this post: I’ve been putting together a group of templates that can ease the creation of plugins. I’m collecting these in a Github repository which I’m just going to leave over here.

    I’ll go through them in some upcoming posts, but the general gist is this.

    1. Place caret in plugin class.
    2. Invoke template.
    3. Call register method from InitializePlugin method.
    4. Follow instructions left in plugin.

    I’ve summarized these instructions in this handy screenshot.

    The Templates

    The templates presented emit code designed to replace the drag and drop designer approach typically used for such things. This is my own preferred approach. I do not suggest it is the only approach. However it is one that works for me :)

    Upcoming posts will walk you though several templates including (but not limited to) NewAction, NewRefactoring and NewCodeProvider.
    So stick around and we’ll help kick-start that plugin for you.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.