unoplatform / uno.templates

Uno Platform project templates
https://platform.uno/
Other
16 stars 9 forks source link

[Bug] Invalid JSON (comment) in global.json shows up as error #767

Closed spouliot closed 1 week ago

spouliot commented 1 week ago

Current behavior

The global.json file used for templates is NOT valid JSON - since comments are not allowed in the format.

While this works in practice it's not

This makes VSCode always shows an error inside the file (filename is in red in the file explorer).

You can also see this inside the github editor itself

{
  // To update the version of Uno please update the version of the Uno.Sdk here. See https://aka.platform.uno/upgrade-uno-packages for more information.
  "msbuild-sdks": {
    "Uno.Sdk": "$UnoSdkVersion$"
  }
}

link

Expected behavior

To avoid tooling errors we need to use JSON-valid pseudo comments like

{
  "msbuild-sdks": {
    "//": "To update the version of Uno please update the version of the Uno.Sdk here. See https://aka.platform.uno/upgrade-uno-packages for more information.",
    "Uno.Sdk": "5.2.0-dev.2103"
  }
}

That makes both Github and VS Code happier.

Affected platforms

No response

Template Host

dotnet new

Host OS

macOS

Template Options

Anything that produce a Uno app project with the global.json file.

Template Version

This is still the case with the git version.

Anything else we need to know?

No response

jojorne commented 1 week ago

Does the parser not support jsonc? Also there are other places using jsonc. https://code.visualstudio.com/docs/languages/json#_json-with-comments

// .vscode/settings.json
{
  "files.associations": {
    "global.json": "jsonc"
  }
}
jeromelaban commented 1 week ago

@jojorne interesting finding, that would be an interesting change indeed.