csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

VS Code extension doesn't register CSharpier as a formatter for XAML files

Open fgimian opened this issue 1 month ago • 2 comments

Environments

  • IDE Version: 1.105.1
  • Extension Version: 2.1.0
  • CSharpier Version: 1.2.1 will NOT be the same as the extension version
  • Operating System: Windows 11 Pro
  • .csharpierrc Settings: N/A
  • .editorconfig Settings: N/A

Log Output N/A

Steps to reproduce

  1. Open a XAML file, hit Ctrl+Alt+P and search for "Format Document With..."
  2. Notice that CSharpier is not an option for formatting XAML files

Expected behavior Since CSharpier can format XAML files, I would have hoped it would appear as an option so I could use it instead of the C# formatter that comes as part of the C# extension.

Actual behavior Only the C# formatter is available for XAML files, not CSharpier.

fgimian avatar Nov 11 '25 03:11 fgimian

When I open a new xaml file it isn't associated with a language - see languages

For csharpier to format it, it would need to be associated with xml. If I select xml as the language for the file (seems to be available when the file has no content and with a keyboard shortcut) then I can format it.

You can also associate extensions with a given language - which is the better way to go.

    "files.associations": {
        "*.xaml": "xml"
    }

Chatgpt seems to think I can do this at the extension level, but I haven't found any other documentation confirming that. Are you using any xaml extensions? I'll take a look at trying to add this association at the extension level.

belav avatar Nov 15 '25 16:11 belav

Thanks heaps for the reply. So it seems the Microsoft C# VS Code extension actually registers a XAML language in the editor.

Image

I can confirm that the XAML language dissappears when the C# extension is disabled.

For the moment, your suggested configuration does solve the problem, but it may be ideal if the extension registered itself as a formatter for the XAML language installed by the C# extension too, if that's possible. 😄

Cheers Fotis

fgimian avatar Nov 16 '25 00:11 fgimian