Skip to main content

msdyn365bc Preprocessor Directives - Pragma Directives.

Hi Readers,

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.

    Regards,
    Saurav Dhyani
    www.sauravdhyani.com

    Comments

    Popular posts from this blog

    VIEW SERVER STATE permission on SQL Server?

    Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

    BC 21 and Higher - PowerShell Cmdlet (Replacement of Business Central Administration).

    Hi Readers, As discussed in last article about deprecating of Business Central Administration, there are few common actions that we use in administration till Business Central 20. For our on-prem customers, we will still require doing activities. As Microsoft suggest we need to start using PowerShell cmdlet.    Let's see how to do those via PowerShell, or Administration Shell. I will be keep adding commands as you comment to this article.

    Send Mail with Attachment From Navision.

    Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing -