Archive

Posts Tagged ‘Coding Helpers’

Code provider to format the String.Format call output

September 4th, 2012 Comments off

The String.Format call is the best approach for outputting information for the user to read. It replaces the format items in the specified template string with the string representation of the corresponding objects. The template string contains text that is desired in the final string and one or more format item placeholders, which will be replaced with other values passed as arguments to the String.Format call as either variable references or other literals.

Read more…

Code providers for working in two-dimensional space

September 4th, 2012 Comments off

There are two code providers that are useful when you have written the code to work in one dimension, but if you want to create a similar code to work in a two-dimensional space, here is an example:

Read more…

Code Providers – Convert to Integer

August 30th, 2012 Comments off

The Convert to Integer code provider allows you to wrap an expression returning a non-integer value to Math.Ceiling, Math.Floor, or Math.Round. Consider the following code sample:

CodeRush Convert to Integer sample code

Read more…

Code providers for converting unimplemented properties

August 30th, 2012 Comments off

CodeRush has two code providers that allow you to convert unimplemented properties into a property with backing store field or into an auto-implemented property quickly:

  • Convert to Property with Backing Store
  • Convert to Auto-implemented Property

Read more…

Implementing the IDisposable pattern using CodeRush

August 15th, 2012 4 comments

The IDisposable Pattern is used to release and close unmanaged resources such as files, streams, and handles as well as references to managed objects that use unmanaged resources, held by an instance of the class. For classes that require a resource cleanup, we recommended following the IDisposable pattern, which provides a standard and unambiguous pattern. The pattern has been designed to ensure reliable, predictable cleanup, and to prevent temporary resource leaks.

Read more…

Coding Helpers – Add Initialization

August 15th, 2012 Comments off

The Add Initialization code provider inserts an initialization of the selected field or auto-implemented property to each constructor of the active type. The code provider is useful when you want to initialize those objects with a different default value:

Read more…

Coding Helpers – Add Else Statement

August 15th, 2012 Comments off

The Add Else Statement code provider performs the operation its name implies – it generates the ‘else’ statement of the current conditional statement. The ‘else’ statement is required when you want to execute a piece of code if a condition is not met. In other words, the ‘else’ is useful when an alternative case is required on the ‘if’ statement.

Read more…

Coding Helpers – Add XML Comments

August 14th, 2012 Comments off

Programming languages such as C# and Visual Basic support the creation of XML Documentation Comments, allowing developers to quickly annotate and document their source code to keep the documentation in a standard format and to gain benefit from the information as you code. Documentation is important to ensure that developers can quickly learn and use the source code.

Read more…