In the Introduction article of series we understand different types of Preprocessor directives available in Business Central.
Preprocessor Directives are available starting Business Central 2020 Release Wave 2.
You can read other articles in this series using this link.
In this article we will understand how to use Pragma Directives.
The #pragma directive gives the compiler special instructions for the compilation of the file in which it appears.
The #pragma directive has a number of actions that can be used with the pragma instructions below, these are disable, restore, and enable.
AL supports the following pragma instructions:
- Pragma Warning
- Pragma ImplicitWith
What Pragma Warning Does?
- The #pragma warning instruction can enable or disable certain warnings.
- This can be used as a solution to avoid getting warnings.
- With the #pragma warning disable statement you disable the emit of the warning for a specific location in code, and with #pragma warning restore you restore the warning back to it's original state.
- If you do not restore, the disable instruction is valid for the rest of the file.
** It is important to be aware that most warnings are there for a reason, and suppressing them could lead to sudden impact if warnings are changed to errors, such as obsoletes.
How to Implement Pragma Warning Directives?
- Global Implementation
- We have to use app.json file.
- Parameter Name suppressWarnings.
- Local Implementation
- We can set that in any object using two directive.
- #pragma warning disable warning-list
- #pragma warning restore warning-list
What Pragma ImplicitWith Does?
How to Implement ImplicitWith?
Hope you like this series.
If you have any questions, add as comments to this article.
Comments
Post a Comment