Best practices in Microsoft Dynamics AX




Microsoft Dynamics AX development environment includes Best Practice Tools which checks the code for best practice and generate error, warning and information messages according to severity. We have similar tool like this in Microsoft .NET Framework named as FxCop and for C and C++ we have Prefix and PREfast. The Best Practices tool runs with the compiler, and we can see the results on the Best Practices tab of the Compiler Output dialog box.














Results are displayed with the following severity code:
  • Information
  • Warnings
  • Errors


If you double-click on an error message, this will open the code editor.


You can define the best practice rules that you want to run in the Best Practice Parameters dialog box: from the Microsoft Dynamics AX drop-down menu, click Tools\Options\Development and then the Best Practices button.










Also you need to set the error level of compiler to 4 from Tools\Options\Development\Compiler if you want Best Practice errors to be reported.


We can stop a particular piece of code from generating Best Practice error at design time as well as at run time.




1. By using a BP Deviation documented comment
Add this comment above the line of code causing the BP problem

//BP Deviation documented


2. In the macro add a line like given in below example which will contain the AOT path and the error code text we want to ignore.


Example:
<violation errorcode="#BPErrorLabelNotDefined" path="\Data Dictionary\Tables\FiscalDocumentInfoAdicTmp_BR" />


After editing the SysBPCheckIgnore macro, go to SysBPCheck class and recompile the class, and then after restarting the MS Dynamics AX, the error or the warning will be suppressed.


3. To suppress best practice check at run time
Create a new Job and add the following code.


SysBpCheck::ignore(#error_code_text _to_suppress);


Run the job. It will suppress that particular BP error mentioned in code till Microsoft Dynamics AX session continues.
We can only suppress warnings which are generated by actual code not by metadata
.








0 comments:

Related Posts Plugin for WordPress, Blogger...
Copyright © 2013 futureX | Blogger Template by Clairvo