Overview of Attribute Classes

Applies To: Microsoft Dynamics AX 2012 R3, 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.

SysObsoleteAttribute

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.

Gg864301.collapse_all(en-us,AX.60).gifCode Example

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

Reflection on Attribute Metadata

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.

See also

Attributes on X++ Types and Methods

Announcements: New book: "Inside Microsoft Dynamics AX 2012 R3" now available. Get your copy at the MS Press Store.