New CodeRush Plugin Template – NewAction

Note: The template referred to by this post does not ship with CodeRush. To install it, see instructions towards the end of the post

This post describes the first new plugin template in a series. The series itself is introduced in my previous post - So you want to write a CodeRush plugin

PurposeShortcutsCommands

The NewAction template provides the single quickest way to create a new action for your plugin. Actions are named bits of code which an user can trigger via a shortcut (mouse, keyboard or menu).

Each new action creates an entry which will be placed in the commands dropdown on the shortcuts page.

Usage

First you’ll need a plugin project. An existing project is fine, or you can create a new one via:

    1. File \ New \ Project
    2. DxCore \ (VSIX) Standard Plug-in

NewCSharpPlugin

Once you are in your new project, you’ll see code like this:

NewPluginCode

As indicated in the screenshot, there you should:

  • Expand the template in the body of your main plugin class.
  • Call the new registerXXXX method from within the InitializePlugin method.

In more detail the steps are:

  1. Expand the template
    1. Position the caret in the body of the plugin class
    2. Type NewAction and hit <space>
      (Note:Those using FrictionFree mode will need to use <tab> instead of <space>)

      NewActionExpandedCS_thumb2
  2. Fill out the generated fields: The first is used to name the methods associated with your action. the second is used to provide the internal name of your action. The one which CodeRush will use and which must be bound to a shortcut in order to be triggered.
  3. Add a call to the generated Register method to your plugin’s InitializePlugin method.

    InitializeMyAction
  4. Add your plugin specific code to the generated Execute method. In the example below I have added a simple call to show a simple "”Hello World” MessageBox.

    ActionExecuteHelloWorld

All of these steps involve coding. None of them take you through designers, and there’s no searching for the right properties or events.

The Action does, of course, have more properties and events to investigate, but this template provides the basic setup which almost every action will require.

Download and Install

This template is available in the CodeRush Plugin Templates repository on Github

To install this template you need (the raw version of) CS_NewAction.xml from the repository.

Update: If you’re using the Template Importer plugin, you can pass it this url to import the NewAction template straight off the web.

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.