web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to get number of custom lines of code in a class

(0) ShareShare
ReportReport
Posted on by 115

Hi guys,

Can anyone please guide me how can I count the number of lines of custom code written in any method in a class.

For example; In SysMailer class I added few lines of code in method quickSend which is at CUS layer (this could be at any layer). I have managed to get the total number of lines of code in each method by traversing it through treeNode and then by calling fieldNode.AOTgetExecuatableLineCount() method. However, now I just want to count custom lines of code.

I do have an idea of the sysCompare class which is used behind compare tool in AX to compare code on different layers. It highlighted the difference in red color. However, it does not tell me the number of lines of custom code.

Any idea would highly be appreciated.

*This post is locked for comments

I have the same question (0)
  • Dick Wenning Profile Picture
    8,705 Moderator on at

    use first

    public TreeNode getNodeInLayer(UtilEntryLevel layer, [boolean old])

    msdn.microsoft.com/.../treenode.getnodeinlayer.aspx

    than  your part again

  • AX QA Profile Picture
    115 on at

    Thanks Dick,

    I used getNodeInLayer method this way;

    treeNode = treeNode.getNodeInLayer(UtilEntryLevel::cus)

    and then treeNode.AOTgetSource() which returns the actual source code.

    I do have another treeNode object (baseTreeNode) which holds sys layer source Code.

    I compared baseTreeNode with treeNode, if there not equal which means there is custom code.

    Is there any method which can tell me difference in both layers which I can then use to calculate number of lines.

  • Dick Wenning Profile Picture
    8,705 Moderator on at

    why do you need it?

    did you import models, and want to see the difference,

    in that case create a baseline db and start a code compare project

  • Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    But what does it means? If you delete one standard line and replace with custom code, the number of lines is equal, which isn't sufficient information.

    You can say that you have one custom line, or you can say that deleting the line is also a change so you have two lines of changes.

  • AX QA Profile Picture
    115 on at

    Please have a look at below picture, the blue code is custom code and I want to calculate number of lines for this custom code. which will tell me how much % of code has been customized in this method.

    3301.Untitled.png

  • Florian Hopfner Profile Picture
    2,461 on at

    Not an answer to your question, but please do not do data validation in data modification methods. Please use validateWrite or validateField for that.

  • AX QA Profile Picture
    115 on at

    Thats another important point to work on Martin but initially I am trying to find custom line of code in a simple case where only few lines are added to a method as I showed.

  • AX QA Profile Picture
    115 on at

    I didn't get you what do you mean. Please stay on my question

  • Dick Wenning Profile Picture
    8,705 Moderator on at

    I think you should look on lcs.dynamics.com  customization analysis

    msdn.microsoft.com/.../dn458949.aspx

  • Suggested answer
    Martin Dráb Profile Picture
    237,880 Most Valuable Professional on at

    In that case, you've already got all information you need to implement it. For example:

    #AOT
    TreeNode node = TreeNode::findNode(@'\Classes\Application\getApplTables');
    int sys = node.getNodeInLayer(UtilEntryLevel::sys).AOTgetExecutableLineCount();
    int syp = node.getNodeInLayer(UtilEntryLevel::syp).AOTgetExecutableLineCount();

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans