Package methods with @NamespaceAccessible are not available to orgs in the same namespace

Issue #1543 new
Raihan Navroze created an issue

Steps to reproduce:

  1. Make a package with classes and methods marked as @NamespaceAccessible
  2. Create a new project in IC, create a new scratch org within the same namespace and install the package to this new scratch org
  3. Build the OST from the new scratch org with the plugin installed
  4. Attempt to write code referring to the @NamespaceAccessible methods

Expected result:

The method is available in the OST and can be used to autocomplete code.

Actual result:

The method shows up in red and shows a warning of “Cannot resolve symbol”

Example case:

This class and method is inside a package within the same namespace.

This is in the new scratch org:

(PS Same issue with namespace.TestNamespaceAccessible.testing())

Comments (4)

  1. Scott Wells repo owner

    Raihan, I apologize but I don't think there's anything I'm going to be able to do about this right now. Any second-generation package with a namespace, whether managed or unlocked, applies code obfuscation to all packaged Apex types. In the case of global symbols in global types, the accessible skeleton is available, but for a class like the one in your example, the body is returned as (hidden). As a result, there's no way to access the @NamespaceAccessible interface of that type programmatically from the API.

    Salesforce is aware of this, though I'm not sure when it will be resolved. Once they do resolve it, I will update IC's OST generation to ensure that the @NamespaceAccessible interface is available to callers in the same namespace.

  2. Matt Simonis

    As a workaround to this, I have been pulling down the outside project code annotated with @NamespaceAccessible into an untracked (gitignored) folder in the sfdx source format. This will allow the OST to pick up on those classes, but not pick it up when making commits.

  3. Log in to comment