Modifier

Partager via


AppSourceCop Error AS0077

Adding a var modifier in events is not allowed

Description

Adding a var modifier in events is not allowed as it might break the runtime behavior of extensions subscribing to it.

Remarks

This error ensures that the behavior of events remains consistent and predictable. Adding a var modifier to an event parameter can alter how the parameter is handled, potentially causing issues for extensions that subscribe to the event. These extensions might not be designed to handle parameters passed by reference, leading to compatibility issues and runtime errors. Maintaining the original parameter passing mechanism (by value) ensures that the event's behavior remains stable and that dependent extensions continue to function as expected.

How to fix this diagnostic?

To resolve this error, follow these steps:

  1. Locate the event in your code where the var modifier has been added to a parameter.
  2. Modify the event definition to remove the var modifier from the parameter.

AppSourceCop Analyzer
Get Started with AL
Developing Extensions