X++: Create a list of child classes or find extended methods

Jet another small X++ job: This job shows a list of child classes per parent class.
If you want so see the parent-child relationship in AX2012, the best way is to Right click on the class > Add-ons > Type hierarchy browser.
The Type hierarchy browser shows the relationships between parent and child classes as well as the methods in each class. While this is great functionality I use regularly, I found it a bit difficult to see which child classes inherit or override a particular parent method.
I wanted to add a parameter variable to the header of one of the invent movement child methods. Parent and child methods in X++ must have exactly the same parameters. This means if you want to add a parameter to a child method you must also add it to the parent method and to all the other children that over rides that particular method. The list below shows me how many child classes I need to modify if I want to add a parameter to one child method.
For example, the InventMovement class has 85 child classes. Only 24 of those children overrides the method “DefaultDimension”. If you want to pass an extra boolean parameter to any of those 24 “DefaultDimension” methods, you have to add it to the definition of all 24 methods and to the parent.
This job creates a list of the 24 classes that overrides the “DefaultDimension” method in the InventMovement class.
My first instinct was to use the SysDictClass’s hasObjectMethod method, but since the method is available on all children through inheritance, it always evaluate to true.
if(childDictClass.hasObjectMethod(methodStr(InventMovement, DefaultDimension)))
Instead, you need to check if the method “DefaultDimension” is a method node under the class node in the AOT.
//Tina van der Vyver //makecreatereiterate.com static void showExtendedMethods(Args _args) { #define.ClassPath(@"\Classes\%1") SysDictClass dictClass; List extendedClassList; ListEnumerator listEnumerator; ClassName className; MethodName methodName; ClassId childClass; TreeNode childClassNode; TreeNode methodNode; int numberofMethods; //set parent class and method you want to investigate className = "InventMovement"; methodName = "DefaultDimension"; dictClass = new SysDictClass(className2Id(classname)); extendedClassList = dictClass.extendedBy(); //loop through all child classes if (extendedClassList.elements()) { listEnumerator = extendedClassList.getEnumerator(); setprefix(strfmt("Class %1 extended by %2 classes.", className, int2str(extendedClassList.elements()))); while (listEnumerator.moveNext()) { childClass = listEnumerator.current(); childClassNode = TreeNode::findNode(strFmt(#ClassPath, classId2Name(childClass))); //Try to find a method node for the method you are looking for methodNode = childClassNode.AOTfindChild(methodName); if (methodNode) { numberofMethods++; info(ClassId2Name(childClass)); } } info(strfmt("%1 child classes override the method '%2'.", numberofMethods, methodName)); } }