Skip to content

Compilation directive is not available in this module (CompilationDirectiveNotAllowed)

Type Scope Severity Activated
by default
Minutes
to fix
Tags
Error BSL Critical Yes 1 error
unpredictable

Description

The set of compilation directives depends on the module type:

  • a managed form module accepts &AtClient, &AtServer, &AtServerNoContext, &AtClientAtServerNoContext;
  • a command module accepts &AtClient, &AtServer, &AtClientAtServer;
  • in a common module, &AtClient and &AtServer further restrict the contexts enabled by the module flags.

A directive from another module type's set is parsed without a syntax error but is not defined for this module. The most common case is &AtClientAtServer in a form module instead of &AtClientAtServerNoContext: the method becomes unavailable to some callers, and the behavior depends on the client type. For example, a call to such a method from a server procedure of the form does not compile, and the form does not open.

For a common module, the diagnostic checks whether at least one possible compilation context remains after applying the directive. For example, &AtClient excludes a method when only the External connection flag is enabled. &AtServerNoContext, &AtClientAtServerNoContext, and &AtClientAtServer do not declare an available common-module method, even when both client and server flags are enabled.

Enabling the shared supportThickClientFileMode setting also includes the file-mode thick client. In that case, a server common module without a client flag does not necessarily make &AtClient an invalid declaration: its method can still exist in a file-mode thick client. By default, that deployment mode is excluded, so such a method is considered unavailable. MemberAccessUnavailable separately checks calls in contexts where the method does not exist. The declaration check does not depend on that diagnostic's selected contexts or the surrounding preprocessor branch. Missing common-module metadata does not imply incompatible flags.

When a directive leaves no available contexts, CompilationDirectiveNeedLess does not add a duplicate recommendation. The recommendation remains for valid directives in common modules.

Examples

Incorrect (form module):

&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
    UpdateAppearance(ThisObject);
EndProcedure

&AtClientAtServer
Procedure UpdateAppearance(Form)
    ...
EndProcedure

Correct:

&AtClientAtServerNoContext
Procedure UpdateAppearance(Form)
    ...
EndProcedure

Sources

Snippets

Diagnostic ignorance in code

// BSLLS:CompilationDirectiveNotAllowed-off
// BSLLS:CompilationDirectiveNotAllowed-on

Parameter for config

"CompilationDirectiveNotAllowed": false