Home > Code Generation > Declare Attribute CodeRush code provider

Declare Attribute CodeRush code provider

June 1st, 2012

Attributes provide a powerful method of associating declarative information by decorating elements of the code, such as types, methods, properties, parameters and assemblies. Once an attribute is associated with a program entity, it can be queried at run time and used in various cases, for example, associating a help document with program entities (via the Help attribute), or marking an item as out of date (via the Obsolete attribute).

As the name says, the Declare Attribute code provider generates a new attribute class for an undeclared attribute reference:

CodeRush Declare Attribute preview

It adds the appropriate AttributeUsage attribute for the newly declared attribute with the corresponding attribute target, which can be easily modified using the Text Fields CodeRush feature:

CodeRush Declare Attribute result step#1

Simply press Enter when you are done with the name of the attribute and you will be navigated to the attribute target for further modification:

CodeRush Declare Attribute result step#2

If the attribute target is valid, pressing the Enter key for the second time will move you inside the constructor of the class.

—–
Products: CodeRush Pro
Versions: 12.1 and up
VS IDEs: 2008 and up
Updated: Sep/21/2012
ID: C167

Similar Posts:

  1. June 7th, 2012 at 15:48 | #1

    Hi Alex. I have translated your nice article and published on the following URL:
    http://d.hatena.ne.jp/gsf_zero1/20120608/p1
    Arigato!,

  2. June 7th, 2012 at 22:22 | #2

    Hi Hideaki, thanks!