X++ in AX7: Attributes without specifying ”Attribute”


The naming convention in X++ (and C# by the way) is to postfix attribute classes' name with "Attribute". When using the attribute to decorate a class, it is a bit verbose to type in "Attribute" as it is apparent from the context, so now in X++ - just like in C# - you can skip the last part of the name.
Example:

class MyTestCase extends SysTestCase 
{
    [SysTestMethodAttribute]
    public void testCase1()
    {
    }
}  
 

Is semantically identical to:

class MyTestCase extends SysTestCase 
{
    [SysTestMethod]
    public void testCase1()
    {
    } 
}  

Now, there is a difference in opinion on which one is best. One camp would argue that the shorter code is easier to read and write. Another camp would argue that referring to the same type in two different ways makes tooling (like refactoring tools, F12/Go to declaration and cross references tool) harder to implement. I agree with both, however, now the door is opened for this dual way of referencing and the tooling needs to follow suit. I'm in favor for the short notion.

 

 

THIS POST APPLIES TO MICROSOFT DYNAMICS AX7 TECHNICAL PREVIEW; IS PROVIDED AS-IS AND CONFERS NO RIGHTS.

Comments (0)

Skip to main content