X++ in AX7: Method signatures


This post is about one of the more subtle changes in AX7. AX7 uses the .NET runtime, aka CLR. This has some implications for method signatures. In the CLR a method’s signature includes casing, parameters and return type. In AX2012 a method’s signature was simply the method’s name – case insensitive.

Why is this important? If you change a method’s signature, then all references to the method needs to be recompiled. Including those changes that appear harmless, like:

  • Fixing a casing issue in a method name, e.g. “somemethod” -> “someMethod”.
  • Changing return type from void to <something>

Here is an example, where I changed the casing of a method, that is being consumed by a test. I did NOT recompile the test before running it.

Notice the System.MissingMethodException: Method not found: ‘Void Dynamics.AX.Application.MyClass.myMethod()’. The CLR only knows of a method with all lower case.

Optional parameters
It is still safe to add and remove (unused) optional parameters. The X++ compiler uses CLR’s method overloading, i.e. several methods with the same name and the variations of supported parameters are produced by the compiler.

Lesson to learn
Do not change a method’s signature, unless you are willing (and able) to recompile all consumers.

 

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

Comments (2)

  1. Waldemar Pross says:

    I always liked the .NET way of method signatures where you can have the same method with one or three parameters. Calling AX methods with 1 mandatory parameter and 3563874 optional parameters was painful sometimes.

  2. Christian Jung says:

    I hope that the AX devs working at Microsoft are among the readers of this blog.

    SCNR 😉

Skip to main content