CodeRush - create a SELECT CASE structure

in CodeRush, is there a way to automatically populate a SELECT CASE statement with available enums?

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

Public Enum eMailTransmissionMethods unknown = 0 IIS AutoEmailer End Enum 

I want to create the following structure.

  Select Case method Case eMailTransmissionMethods.IIS Case eMailTransmissionMethods.AutoEmailer Case eMailTransmissionMethods.unknown End Select 
+4
source share
2 answers

Just:

  • Copy identifier name to clipboard
  • Enter either select or switch (depending on your choice of language VB.Net vs C #)
  • Press spacebar

CodeRush designs the type of identifier on the clipboard and creates a branch for each value that may contain an enumeration.

Another, more complete version of this answer is described in detail here on my blog complete with photos.

+6
source

In addition to the template, if you have a Refactor! complete with the CodeRush installation, you can use the " Create random blocks from Enum " refactoring, which allows you to create a case case statement. It is available in a reference or local (parameter) declaration of the enumeration type.

+5
source

Source: https://habr.com/ru/post/1347088/


All Articles