Suppress AL warnings

Enabled for Public preview General availability
Admins, makers, or analysts, automatically This feature is released. Aug 1, 2020 This feature is released. Oct 1, 2020

Business value

In some cases, compiler or analyzer warnings are due to intended code use. To reduce clutter so that developers can focus on warnings that must be addressed, we are adding support to explicitly suppress warnings, either for a whole extension or locally in a code enclosure.

Feature details

There are two ways to support warnings:

  • Globally for an extension
  • Locally

Remember 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).

Global

We have added a new suppressWarnings property in the app.json manifest so that you can suppress a comma-separated list of warning IDs when you compile the extension:

"suppressWarnings": [Warning ID,Warning ID2,...]

Local

Directives is a new construct in the AL language that specifies how the AL compiler treats an enclosed section of code. The same concept is known in other languages. The specific directive instructions must be supported by the compiler—you cannot create custom preprocessing instructions.

One of the new directives is a warning pragma, which you can set around a code section to suppress a comma-separated list of warnings only in that enclosure. If no end pragma closure is provided, it will be the rest of the file. The restore returns it to whatever global suppression state there is as described above. When no warning numbers are specified, disable disables all warnings and restore enables all warnings.

#pragma warning disable warning-list
#pragma warning restore warning-list 

Thank you for your idea

Thank you for submitting this idea. We listened to your idea, along with comments and votes, to help us decide what to add to our product roadmap.

See also

Preprocessor Directives in AL (docs)