csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

[VSCode Extension] Allows to deactivate diagnostics only for XML files

Open sharky98 opened this issue 5 months ago • 1 comments

Environments

  • IDE Version: VSCode 1.102.0
  • Extension Version: 2.0.8
  • CSharpier Version: 1.0.3
  • Operating System: Linux
  • .csharpierrc Settings: none
  • .editorconfig Settings: none

Expected behavior

Since I use another VSCode extension for XML (DotJoshJohnson.xml), diagnostic warnings from CSharpier should not appear on XML files.

I was expecting to be able to configure it with the following (note that another formatter is configured for XML).

"[xml]": {
    "editor.defaultFormatter": "DotJoshJohnson.xml",
    "csharpier.enableDiagnostics": false
},
"[csharp]": {
    "editor.defaultFormatter": "csharpier.csharpier-vscode"
},

Actual behavior

  • Using "csharpier.enableDiagnostics": false inside the [xml] key return This setting cannot be applied because it is not registered as language override setting..
  • Using "csharpier.enableDiagnostics": false globally also disable diagnostics for C# files, even though the description seems to indicate otherwise ("code that is not formatted with CSharpier", since I am using CSharpier to format C#, I was expecting the diagnostics to stay).

sharky98 avatar Jul 13 '25 20:07 sharky98

For the record, I tried to workaround by modifying the extension manually (monkey patch) by removing the XML reference in two places. But that did not change the fact that the CSharpier diagnostic still return warning for XML files. At least I tried 😅

https://github.com/belav/csharpier/blob/e752f9ffdde614ac15a3767511408805ca722ce8/Src/CSharpier.VSCode/package.json#L30-L33

https://github.com/belav/csharpier/blob/e752f9ffdde614ac15a3767511408805ca722ce8/Src/CSharpier.VSCode/src/Extension.ts#L22

So in the end I went with a .csharpierignore that ignore all XML files. It worked, but I think this should be an extension settings and not a "core" settings.

sharky98 avatar Jul 13 '25 20:07 sharky98