microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
722 stars 242 forks source link

Never-Ending 'Loading Workspace' Issue with 'jsonc' Format in 'app.json' #7653

Closed zabcik closed 4 months ago

zabcik commented 5 months ago

1. Describe the bug Encountering a persistent 'Loading workspace' issue in the 'AL Language' extension when 'app.json' contains 'jsonc' (JSON with Comments) compliant elements. The issue does not manifest immediately after making comments in 'app.json'; rather, it occurs upon reloading the project.

2. To Reproduce

  1. Configure '.json' to use 'JSON with Comments' format.
  2. Execute 'AL: Go!' command.
  3. Download symbols using 'AL: Download Symbols'.
  4. Create a package using 'AL: Package' - package creation is successful.
  5. Insert a comment or leave a trailing comma in 'app.json', compliant with 'jsonc'.
  6. Create a package package - package creation is again successful.
  7. Reload the window. This results in a never-ending 'Loading workspace: Preparing project: "ALProject1"' message.
  8. Compile the project using 'alc.exe' - this results in successful compilation.

File app.json:

{
  "id": "376236a7-9c7d-452c-9373-0491c7a776f3",
  "name": "ALProject3",
  "publisher": "Default Publisher",
  "version": "1.0.0.0",
  "brief": "",
  "description": "",
  "privacyStatement": "",
  "EULA": "",
  "help": "",
  "url": "",
  "logo": "",
  "dependencies": [],
  "screenshots": [],
  "platform": "1.0.0.0",
  "application": "20.0.0.0",
  "idRanges": [
    {
      "from": 50100,
      "to": 50149
    }
  ],
  "resourceExposurePolicy": {
    "allowDebugging": true,
    "allowDownloadingSource": true,
    "includeSourceInSymbolFile": true
  },
  "runtime": "10.0",
  "features": [
    "NoImplicitWith", // There is trailing comma and comment.
  ]
}

2024-01-25_17-48-20

3. Expected behavior The 'AL Language' extension should either show an error if 'app.json' is not correctly formatted or fully support 'jsonc'.

4. Actual behavior The extension allows the project to be packaged successfully after "jsonc" compliant modifications but fails after reload the workspace, leading to a never-ending loading state.

5. Versions:

6. Suggested Fix/Workaround: Either implement full 'jsonc' support for 'app.json' or ensure the extension displays an error for non-compliant formats.

rdebath commented 5 months ago

Sorry to point you at https://github.com/microsoft/AL/issues/5315 and https://github.com/microsoft/AL/issues/6909 Microsoft are specifically using a fascist json loader for the app.json file rather than the normal one, they haven't given a reason for this. Microsoft "discussed" this issue and don't care.

They also pretend that your step (1) is unreasonable.

I suggest this in settings.json so vscode checks for json-404.

    "files.associations": {
        // Beware publish is seriously broken; it fails silently when app.json has comments.
        "app.json": "json"
    },
zabcik commented 5 months ago

Hello rdebath,

It's a pity that 'AL Language' and 'alc.exe' do not load 'app.json' with the same restrictions. I am also curious about what 'AL Language' actually does during the endlessly long loading of the workspace... It's unfortunate that 'AL Language' doesn't show an error when 'app.json' is not correct for it.

Thank you for provided workaround with "files.association".