Search code examples
devexpresscoderush

CodeRush - Build a SELECT CASE framework


in CodeRush, is there a way to auto-fill a SELECT CASE statement with the available enumerations ?

So, given this enum declaration (or one with a lot more enumeration options)

Public Enum eMailTransmissionMethods
    unknown = 0
    IIS
    AutoEmailer
End Enum

I want to build the following framework.

    Select Case method
        Case eMailTransmissionMethods.IIS
        Case eMailTransmissionMethods.AutoEmailer
        Case eMailTransmissionMethods.unknown
    End Select

Solution

  • Simply:

    • Copy the identifier name to the clipboard
    • Type either select or switch (depending on your language of choice VB.Net vs C#)
    • Hit the space bar

    CodeRush works out the type of the identifier on the clipboard, and creates a branch for each value that the enumeration can hold.

    Another, more complete, version of this answer is detailed here on my blog complete with pics