Use of a method/property unavailable in the target platform version (UnavailableMemberCall)¶
| Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
|---|---|---|---|---|---|
Error |
BSL |
Major |
Yes |
5 |
suspicious |
Description¶
The diagnostic triggers on a method call or property access of a platform type that is available only since a platform version newer than the project compatibility mode. Using such a member will fail in the environment matching the selected compatibility mode.
The version a member becomes available in is taken from the syntax assistant of the installed 1C platform (via bsl-context) or from the bundled reference. Triggering respects the target platform version: a member is treated as unavailable when the target version is lower than the version the member was introduced in. The target version is resolved by priority: the v8platform.targetVersion setting, then the configuration compatibility mode, and if neither is set the newest platform is assumed and the check does not trigger.
When the object type may be inferred as one of several types (for example, a variable assigned values of different types in different code branches), the diagnostic triggers if the member is unavailable for at least one of the possible types.
Besides members, the diagnostic checks construction of the type itself - New TypeName(...). The version a type was introduced in comes from its main page in the syntax assistant, so this check works only with an installed 1C platform. The New("TypeName") form is not checked: the type name there is computed at runtime.
Examples¶
The target platform version is 8.3.10 (v8platform.targetVersion or the compatibility mode), while the ВопросАсинх (DoQueryBoxAsync) method is available only since 8.3.18:
// Triggers: the method is available only since version 8.3.18
Оповещение = Новый ОписаниеОповещения("ПослеВопроса", ЭтотОбъект);
ВопросАсинх(Оповещение, "Продолжить?", РежимДиалогаВопрос.ДаНет);
Fix it by raising the target platform version to a supported one, or by using a member available in the target version (for example, the synchronous Вопрос / DoQueryBox):
Ответ = Вопрос("Продолжить?", РежимДиалогаВопрос.ДаНет);
Construction of a type missing from the target version. The JSONReader type is available only since 8.3.6, while the target platform version is 8.3.5:
// Triggers: the type is available only since version 8.3.6
Reader = New JSONReader();
Fix it by raising the target platform version to 8.3.6 or higher, or by solving the task with types available in the target version (there is no built-in JSON type before 8.3.6, so such data is read as text):
Reader = New TextReader(FileName);
Sources¶
- Source: 1C:Enterprise 8 platform syntax assistant
Snippets¶
Diagnostic ignorance in code¶
// BSLLS:UnavailableMemberCall-off
// BSLLS:UnavailableMemberCall-on
Parameter for config¶
"UnavailableMemberCall": false