Skip to content

[BUG]: Error thrown when parsing JSON config file for C# extension #36

Description

@tylervz

Describe the bug

When opening any VS Code workspace, the Output tab shows the following error because the extension failed to parse a JSON config file of the C# extension:

["ERROR" - 3:04:20 PM] Error: Failed to parse a required JSON file: "/Users/myusername/.vscode/extensions/ms-dotnettools.csharp-2.130.5-darwin-x64/src/xaml/language-configuration.json"

	Parse Errors:

	Error 1 - Value Expected at "/Users/myusername/.vscode/extensions/ms-dotnettools.csharp-2.130.5-darwin-x64/src/xaml/language-configuration.json:70:3"

	Stack Trace:
	at Object.readJsonFile (/Users/myusername/.vscode/extensions/ycodetech.automatic-comment-blocks-1.1.14/out/src/utils.js:49:23)
	at /Users/myusername/.vscode/extensions/ycodetech.automatic-comment-blocks-1.1.14/out/src/configuration.js:337:36
	at Array.forEach (<anonymous>)
	at /Users/myusername/.vscode/extensions/ycodetech.automatic-comment-blocks-1.1.14/out/src/configuration.js:336:19
	at Map.forEach (<anonymous>)
	at Configuration.setLanguageConfigDefinitions (/Users/myusername/.vscode/extensions/ycodetech.automatic-comment-blocks-1.1.14/out/src/configuration.js:334:38)
	at new Configuration (/Users/myusername/.vscode/extensions/ycodetech.automatic-comment-blocks-1.1.14/out/src/configuration.js:71:14)
	at Object.<anonymous> (/Users/myusername/.vscode/extensions/ycodetech.automatic-comment-blocks-1.1.14/out/src/extension.js:13:21)
	at Module._compile (node:internal/modules/cjs/loader:1713:14)
	at Module._extensions..js (node:internal/modules/cjs/loader:1847:10)
	at Module.load (node:internal/modules/cjs/loader:1448:32)
	at Module._load (node:internal/modules/cjs/loader:1270:12)
	at c._load (node:electron/js2c/node_init:2:18041)
	at r._load (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:801:6589)
	at e._load (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:619:28611)
	at n._load (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:611:27731)
	at TracingChannel.traceSync (node:diagnostics_channel:328:14)
	at wrapModuleLoad (node:internal/modules/cjs/loader:244:24)
	at Module.require (node:internal/modules/cjs/loader:1470:12)
	at require (node:internal/modules/helpers:147:16)
	at Pk._doLoadModule (file:///Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:650:1614)

Here is the content of /Users/myusername/.vscode/extensions/ms-dotnettools.csharp-2.130.5-darwin-x64/src/xaml/language-configuration.json:

{
	"comments": {
		"blockComment": [ "<!--", "-->" ]
	},
  "brackets": [
    [ "<!--", "-->" ],
    [ "<", ">" ],
    [ "{", "}" ],
    [ "(", ")" ]
  ],
  "autoClosingPairs": [
    {
      "open": "{",
      "close": "}"
    },
    {
      "open": "[",
      "close": "]"
    },
    {
      "open": "(",
      "close": ")"
    },
    {
      "open": "\"",
      "close": "\"",
      "notIn": [ "string" ]
    },
    {
      "open": "'",
      "close": "'",
      "notIn": [ "string" ]
    },
    {
      "open": "<!--",
      "close": "-->",
      "notIn": [ "comment", "string" ]
    }
  ],
	"surroundingPairs": [
		{ "open": "'", "close": "'" },
		{ "open": "\"", "close": "\"" },
		{ "open": "{", "close": "}"}
	],
	"colorizedBracketPairs": [
	],
	"folding": {
		"markers": {
			"start": "^\\s*<!--\\s*#region\\b.*-->",
			"end": "^\\s*<!--\\s*#endregion\\b.*-->"
		}
	},
	"wordPattern": {
		"pattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)"
	},
  "onEnterRules": [
    {
      "beforeText": "^\\s*(<([A-Za-z0-9_.-]+)([^/>]*(?!/)>)[^<]*)(?!.*<\\/\\2>)$",
      "afterText": "^\\s*<\\/([A-Za-z0-9_.-]+)[^>]*>$",
      "action": {
        "indent": "indentOutdent"
      }
    },
    {
      "beforeText": "^\\s*(<([A-Za-z0-9_.-]+)[^</]*)$",
      "action": {
        "indent": "indent"
      }
    },
  ]
}

The trailing comment after the last object in the onEnterRules array is what is tripping up ycodetech.automatic-comment-blocks-1.1.14/out/src/utils.js and causing the error to be thrown. Although having a trailing comma in a JSON array is not valid JSON, the language-configuration.json in the source repository of the C# Visual Studio Code extension contains a trailing comma, and so I think this extension needs to support reading JSON with trailing commas.

As a workaround, I can manually open up the /Users/myusername/.vscode/extensions/ms-dotnettools.csharp-2.130.5-darwin-x64/src/xaml/language-configuration.json file on my computer and remove that trailing comma. However, eventually, the comma and the error return; I think this happens when the C# extension updates.

Expected behavior
This plugin should not throw any errors when opening a VS Code workspace, even if the user has the C# Visual Studio Code extension installed.

Additional context
Automatic Comment Blocks version 1.1.16
C# Extension version 2.140.9
.NET Install Tool extension version 3.1.0
VS Code Version: 1.129.0 (Universal)
Commit: 125df4672b8a6a34975303c6b0baa124e560a4f7
Date: 2026-07-15T00:08:44Z (3 days ago)
Electron: 42.6.0
ElectronBuildId: 14623276
Chromium: 148.0.7778.280
Node.js: 24.18.0
V8: 14.8.178.38-electron.0
OS: Darwin x64 24.6.0

Here's the latest Output:
auto-comment-blocks-output.txt. My apologies if this file doesn't match the contents of my bug report exactly. I originally opened the same issue](kevb34ns#47) in the parent repository and then today I realized I actually have your fork of the extension installed.

I discovered that this issue was resolved when I upgraded the Node dependencies of that parent plugin: kevb34ns#48

Please let me know if you'd like me to make a similar pull request for this repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions