Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Overview of Attribute Classes [AX 2012]

Updated: November 18, 2009

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

In X++, any class that inherits from the SysAttribute class is called an attribute. The purpose of an attribute is to represent or store metadata about types and methods. An attribute can be attached to the definition of the following items:

  • Interface

  • Class

  • Method

    • Method on an interface

    • Method on a class

    • Method on a table

The system provides several attributes, including the SysObsoleteAttribute class. One use of the SysObsoleteAttribute class is to tell the X++ compiler that the compile should fail if a particular method is called in the source code. The X++ compiler rejects the compile, and it displays the specific message that is stored in this use of the attribute.

The system provides several attributes, including the SysObsoleteAttribute class. One use of the SysObsoleteAttribute class is to tell the X++ compiler that it should fail if a particular method is called in the source code. The X++ compiler rejects the compile, and it displays the specific message that is stored in this use of the attribute. The SysObsoleteAttribute class can also be used to tell the compiler to issue warning messages instead of errors.

Code Example

// X++
[SysObsoleteAttribute("The Automobile class might be a better choice for faster performance.", false)]
class Bicycle
{
    // Members of the Bicycle class go here.
}

You can perform reflection to find the attribute metadata that is attached to a class. The classes to use for attribute reflection are as follows:

On the previous reflection classes, the methods for reflecting on attribute metadata are as follows:

  • getAllAttributes method

  • getAttribute method

  • getAttributedClasses method

  • getAttributes method

For more information, see How to: Use Reflection to Get Attribute Class Metadata.

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.