Life as an X++ developer just got a bit easier. We have been ironing out some of the wrinkles regarding access specifiers in the X++ compiler lately. Most X++ developers might not have noticed, and might wonder: Didn’t it work like that already? Now it does – better letter than never. The goal is to be just C# - no surprises or idiosyncrasies required.

Better support for internal

Marking a method as internal ought to let you keep full control of the method. However, the compiler has not enforced the internal keyword in all cases, and thereby accepting external references. We will be hardening the compiler to first give warnings, and shortly thereafter give errors. We must close the hole before it spins out of control. The scope of this problem is proportional to the number of internal methods; which is exponentially increasing. We are aware of very few cases that can impact external parties; and are reaching out proactively.

  • (PU25) A warning is given when extending an internal class in a non-friendly model.
    “Base class ‘<name>’ is less accessible than class ‘<name>’”
  • (PU25) A warning is given when overriding aninternal method in a non-friendly model.
  • (PU26) A warning is given when overriding a public method and marking it as internal in the subclass.

Better support for protected internal.

It is now possible to change a from protected to protected internal without risking breaking anyone. Recall that protected internal is the union of protected and internal, the act of marking a protected method as protected internal must not limit any capabilities.

  • (PU24) Protected internal methods can be called from ExtensionOf classes. Previously the compiler generated invalid IL code causing runtime errors.
  • (PU25) Protected internal methods are wrappable by default. (Just like protected methods are).

InternalUseOnly can be used to soft lock-down APIs.

It is now possible to mark a method with InternalUseOnly to signal the intent-to-make-internal; just like SysObsolete(<Reason>, false) can be used to signal the intent-to-deprecate a method. In both cases consumers will receive a warning – effectively giving a grace period to react.

  • (PU25) Warn when methods marked with InternalUseOnly are wrapped; previous an error was given.

Note

All changes are in the compiler; and therefore, not affecting binary compatibility or updates of production environments.