Archive for the ‘Coding Helpers’ Category

Coding Helpers – Auto Declare

February 4th, 2011 Comments off

Auto Declare allows you to quickly declare a variable (field, local or parameter) based on its type. To apply Auto Declare, type the class name and press the Ctrl+A shortcut. The variable will be declared with an appropriate name, and an action hint will be shown:

CodeRush Auto Declare

Read more…

Coding Helpers – Move to Region

February 3rd, 2011 Comments off

The Move to Region (also known as Member MoverCodeRush feature extends the Member drop down menu with a menu item that allows you to move the active member to a region according to your preference:

CodeRush Member Icons and Move to Region preview

Read more…

Unbound Actions – Toggle Region

January 27th, 2011 Comments off

The ToggleRegion action changes the collapsed state of the currently active region. This functionality is very similar to the existing “Toggle Regions Outlining” shortcut, provided by CodeRush. The only difference is that you can collapse the active region using the ToggleRegion action when the editor caret is located anywhere inside of a region, while the “Toggle Region Outlining” shortcut is available only on the line with a region directive. The action is not bound to any key, so you might want to do it via the Shortcuts options page in the Options Dialog.

Products: CodeRush Pro
Versions: 11.1 and up
VS IDEs: any
Updated: Aug/30/2011
ID: C061

Coding Helpers – Toggle Regions Outlining

January 27th, 2011 Comments off

When the editor caret is on the line with a region directive, you can press the Space key to collapse or expand the outline of a region. There are built-in shortcuts for toggling outline expansion, but they are probably more tricky to press and remember, e.g. “Ctrl+M, M” (hold the Control key and press the M key twice in the Visual C# keyboard mapping scheme).

CodeRush Toggle Region Outlining

Read more…

Code Providers – Remove Region Directives

January 26th, 2011 Comments off

This simple code provider, as the name says, removes the two lines of region directives:

  • #region and #endregion lines in CSharp
  • #Region and #End Region lines in Visual Basic
  • #pragma region and #pragma endregion lines in C++

It is available on any of the two directives – either starting or ending:

Read more…

Coding Helpers – Auto Create Region

January 26th, 2011 Comments off

If you prefer your code to be wrapped into region directives (#region … #endregion in CSharp, or #Region … #End Region in Visual Basic), the Auto Create Region feature from CodeRush will help. To create a named region around a method, property or event, press “Ctrl+3” key anywhere inside of an active member. This will execute the “RegionAutoCreateaction, which wraps the active member into region directives. The region name will be the same as member’s name and will wrap all attached elements, such as XML doc comments or attributes as well.

Read more…

Code Providers – Seal Class

January 16th, 2011 1 comment

This is one of the simplest code provider operations which simply marks the active class as ‘sealed’ (CSharp) or ‘NotInheritable‘ (Visual Basic). The sealed modifier is used to prevent inheriting from a class. For example, this can be useful when creating ‘helper’ classes containing utility methods that should never be extended by overriding the existing functionality. Another benefit of this code provider is that it enables a hypothetical run-time optimization, because having a sealed class known to never have any derivations; it is possible for the compiler to transform virtual function member invocations into non-virtual which take less time to perform.

Read more…

Coding Helpers – Scope Cycle

November 11th, 2010 Comments off

The Scope (Visibility) Cycle feature adds the capability to quickly change the visibility modifier of the active member using a single shortcut. In a source code file, if your text caret is anywhere within or on a member (method, function, property, class, etc) definition, you can use the Alt key with the Up and Down arrow keys, to cycle through the legal visibility modifiers:

Read more…