Dynamics 365 Business Central 2023 wave 1 (BC22) is generally available last week. More details: Dynamics 365 Business Central 2023 release wave 1 (BC22)
I will continue to test and share some new features that I hope will be helpful.
New rule to enforce pragma warning ‘disable’ specifying a disabled rule:
It is possible to use the #pragma warning
disableto disable all rules. This is often not the intended use, so to support gating this, a new CodeCop rule has been introduced that allows mandating that disabled rules are specified explicitly.
What is Pragma Warning? We briefly discussed it in Preprocessor Directives in AL (Conditional Directives, Regions, Pragmas) before, let’s recap.
#pragma warninginstruction can enable or disable certain warnings. This can be used as a solution to avoid getting warnings on, for example, string length on fields that you cannot change. With the
#pragma warning disablestatement you disable the emit of the warning for a specific location in code, and with
#pragma warning restoreyou restore the warning back to it’s original state. If you do not
disableinstruction is valid for the rest of the file.
For example, there are 100 warnings in the following object “NewCustomerList.Page.al”.
You can enter “#pragma warning disable AL0604” to ignore “AL0604” warning.
Or, enter “#pragma warning disable” to ignore all warning. (In previous versions, there was no warning)
With this wave, a new, optional CodeCop rule AA0246 has been added. Enabling this allows you to enforce that, when suppressing diagnostics using the #pragma warning
disable, the code(s) of the diagnostics to suppress must be specified instead of suppressing all analyzer diagnostics and compiler warnings.
Suppressing all diagnostics is not allowed. Specify the diagnostic(s) that you want to suppress. AL (AA0246)
Give it a try!!!😁
Hope this will help.
Thanks for reading.