Archive

Author Archive

Code Issues – Field can be read-only

January 23rd, 2011 Comments off

Cause:

This code issue shows a hint (suggestion) on the fields which can be marked as read-only. When a field declaration includes a readonly modifier, assignments to the fields introduced by the declaration can only occur as part of the declaration or in a constructor (instance or static) in the same class. Read-only fields cannot be changed by other code or the code from team members, thus making it less likely to be messed up by someone who doesn’t understand the purpose of the code.

Sample:

CodeRush Field Can Be Readonly Preview

How to fix:

The Make Read-only refactoring is a code fix for this issue:

CodeRush Make Read-only Fix

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

Code Issues – Property cannot have void type

January 22nd, 2011 Comments off

Cause:

A property is a member that provides a flexible mechanism to read, write, or compute the value of a field, thus it cannot have a void type. Properties are actually special methods called accessors (getter or setter) and they must have a specific non-void type according to most language specifications.

Read more…

Code Issues – Constructor must declare a body

January 21st, 2011 Comments off

Cause:

The Constructor must declare a body code issue shows an error if there is a constructor without a body. Constructors are similar to usual methods and whenever a class or struct is created, its constructor is called. Constructors should always declare its body to properly initialize a class or struct.

Read more…

Code Issues – Cannot create an instance of interface

January 21st, 2011 Comments off

This code issue shows an error if there is an attempt to initialize an instance of a interface. Interfaces cannot be instantiated, they contain only the signatures of methods, properties or events. The implementation of these members is done in the class that implements the interface.

Read more…

Code Issues – Abstract member cannot be private

January 21st, 2011 Comments off

This code issue shows an error when an abstract member with the private visibility keyword is found. Abstract members are incomplete, and must be implemented in a derived class. That’s why abstract members can not be private – they must be visible in a derived class.

Read more…

Code Issues – Empty namespace declaration

January 21st, 2011 Comments off

Cause:

This code issue shows a dead code, which is redundant. Empty namespace declarations don’t have any value, and can be safely removed.

Sample:

CodeRush Code Issues - Empty namespace declaration

How to fix:

  • Remove the empty namespace declaration.
—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: any
Updated: Nov/12/2012
ID: C048

Code Issues – Can initialize conditionally

January 21st, 2011 Comments off

Cause:

This code issue may improve the efficiency of the code. It is shown if the initialization can be moved to an ‘else’ block of the following conditional statement. If the condition of the conditional statement is met, than the first initialization is unnecessary. This issue is shown as a suggestion (hint).

Read more…

Refactorings – Move Type to File

January 19th, 2011 Comments off

The Move Type To File refactoring allows users to move a given class, structure, interface, enumeration or delegate to a separate file. It is available when there are two or more types in the current source file.

Refactoring moves a type with a name that differs from the file name to a new source file. All comments, attributes, and XML doc comments relating to the type are moved with the type. The file will be located in the same folder as the current file and automatically added to the project. The name of the new file is based on the type’s name on which refactoring is applied.

Read more…