XamlStyler icon indicating copy to clipboard operation
XamlStyler copied to clipboard

Files with UTF-16 encoding fail when running xstyler on Ubuntu

Open mrlacey opened this issue 2 months ago • 0 comments

Describe the bug

UTF-16 encoded files fail a passive check from xstyler when run on Ubuntu (as part of a GitHub Action)

I'm working on a project where we need some files encoded as UTF16 (while most are encoded with UTF-8)

This is causing issues with our CI checks (that runs on a Ubuntu machine via GitHub Actions).

To Reproduce Steps to reproduce the behavior:

  1. Create XAML file that is formatted to meet the standards defined in that settings file
  2. Verify (on Windows) that the file is formatted as expected/desired.
  3. Run XStyler.Console on a Ubuntu machine to check the same file using the --passive flag

Here's a repo I created that reproduces this: https://github.com/mrlacey/xamlstyler-encoding-bug

You can see the files all pass the GitHub action when run on Windows: https://github.com/mrlacey/xamlstyler-encoding-bug/actions/runs/8621842608/job/23631611557 But the UTF-16 encoded files fail on Ubuntu: https://github.com/mrlacey/xamlstyler-encoding-bug/actions/runs/8621842604/job/23631611559#step:5:37

Everything is the same in those actions apart from the machine they run on.

Expected behavior A clear and concise description of what you expected to happen.

  1. Rules should be applied consistently across all platforms.
  2. All encodings should be supported "everywhere"
  3. The reason for a FAIL (as part of a passive check) should be provided. (Working out why this failure was happening was slow and frustrating.)

Screenshots If applicable, add screenshots to help explain your problem.

External Configuration If you are using an external configuration, please attach to help reproduce the issue.

Version Info (please complete the following information):

  • OS: Ubuntu (22.04.4)
  • Visual Studio: n/a
  • XAML Styler: Console 3.2404.2

Additional context

We're left with two Workarounds:

  1. Run the action on Windows (this is slower and more expensive)
  2. Exclude those files from the checks. (Although this means adding another process to create the list of files we want checking and that we really do still want those files to meet the defined formatting standards.)

I've also noticed that xstyler will change the encoding of files when it updates them. Is this deliberate? Should I open a separate issue for this?

mrlacey avatar Apr 09 '24 20:04 mrlacey