Archive

Author Archive

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 Issues – Try statement without catch or finally

January 24th, 2011 Comments off

Cause:

This code issue shows an error if a ‘try’ statement doesn’t have a ‘catch’ or ‘finally’ statement. The try block must be completed, whether with catch or finally blocks.

The try block contains the guarded code that may cause the exception. The block is executed until an exception is thrown or it is completed successfully.

Read more…

Code Issues – Static constructors must be parameterless

January 24th, 2011 Comments off

Cause:

A static constructor is used to initialize any static data, or to perform a particular action that needs performed once only. Parameters are not allowed for static constructors.

Read more…

Code Issues – Interface expected

January 23rd, 2011 Comments off

This code issue shows an error when the structure is derived from a non-interface type. Structures can only inherit from other interfaces according to various language specifications.

Read more…

Code Issues – Unused setter

January 23rd, 2011 Comments off

Cause:

This code issue shows a dead code when there are unreferenced private property setters. Unused property setters of private properties can be safely removed, which will improve code readability.

Sample:

CodeRush Unused Setter Sample

How to fix:

  • Apply the Remove Setter code fix:

CodeRush Remove Setter Fix

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: any
Updated: Nov/12/2012
ID: C054

Code Issues – Redundant Constructor

January 23rd, 2011 Comments off

Cause:

This code issue shows a hint (suggestion) that a redundant constructor can be safely removed. Redundant constructor is a public, parameterless constructors without any code inside of its body. This constructor doesn’t call base type constructors and it is alone in the current class. The constructor is redundant because such constructors are automatically generated by the compiler. Removing the redundant constructors may improve code readability.

Sample:

CodeRush Code Issues - Redundant сonstructor

How to fix:

  • Remove the redundant constructor by applying the corresponding Remove Redundant Constructor refactoring:

CodeRush Redundant Constructor Fix 1

  • Add another constructor to the class, so the original constructor is no longer redundant:

CodeRush Redundant Constructor Fix 2

Also, see the full list of code issues specific to constructors.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: any
Updated: Nov/12/2012
ID: C053