Giter VIP home page Giter VIP logo

Comments (17)

JoeRobich avatar JoeRobich commented on August 11, 2024 1

Hi @shargon,
We now have support for the charset editorconfig option in our myget feed. We are waiting until analyzer support is merged in before we make a 4.x release to NuGet.
Run dotnet tool install -g dotnet-format --version 4.0.40103 --add-source https://dotnet.myget.org/F/format/api/v3/index.json to install.
You can use the combination of --dry-run and --check options to run formatting against your project and have it return a non-zero exit code if changes are required.
Please let us know if you run into any issues.

from format.

RehanSaeed avatar RehanSaeed commented on August 11, 2024 1

It's still converting UTF-8 encoded files to Western European (Windows).

from format.

JeroMiya avatar JeroMiya commented on August 11, 2024 1

@JoeRobich Could you take a second look at this? I don't see a new issue being filed, and this issue that @celluj34 describes can still be reproduced with version 5.0.211103 of dotnet-format.

I'm experiencing the same issue. I have an .editorconfig with:

[*]
charset = utf-8

And running dotnet-format with --fix-whitespace will convert some files from "UTF-8 with signature" or "UTF-8 without signature" to "Western European (Windows)".

At first I thought it was noticing that the UTF-8-BOM encoded files didn't match the .editorconfig setting, but reformatted it to the wrong encoding. But, if I try setting it to UTF-8 without signature and run the formatter again, it still changes it to Western European (Windows).

from format.

shargon avatar shargon commented on August 11, 2024

Thanks so much

from format.

RehanSaeed avatar RehanSaeed commented on August 11, 2024

I have the following in my .editorconfig file:

[*]
charset = utf-8

When I run dotnet format, all my .cs files are changed from UTF-8 to Western encoding. What am I doing wrong?

from format.

jmarolf avatar jmarolf commented on August 11, 2024

@RehanSaeed which version of dotnet-format are you using?

from format.

RehanSaeed avatar RehanSaeed commented on August 11, 2024

4.1.131201

from format.

jmarolf avatar jmarolf commented on August 11, 2024

@RehanSaeed does this issue still reproduce if you install the (beta) 5.0 version?

dotnet tool install -g dotnet-format --version 5.0.142902 --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json

from format.

jmarolf avatar jmarolf commented on August 11, 2024

Thanks, it likely has to do with which code pages are available on your machine. Can you open up a new issues giving:

  • Your operating system and version
  • the set of language packs you have installed
  • You default language version.

from format.

celluj34 avatar celluj34 commented on August 11, 2024

I am having this same issue:

OS and Version:
image

dotnet format version:
image

Languages installed:
image

Let me know if there's more info you need.

from format.

JoeRobich avatar JoeRobich commented on August 11, 2024

@celluj34 @RehanSaeed Could either of you share files or steps that repro this behavior? The steps I tried are as follows. Ran through these on both MacOS and an up to date Windows 10.

  1. Run dotnet new console
  2. Run code .
  3. Save Program.cs with the UTF-8 encoding
  4. Add .editorconfig
root = true

[*]
charset = utf-8
  1. Run dotnet format -v d

No files formatted.

from format.

celluj34 avatar celluj34 commented on August 11, 2024

Two files are exhibiting the issue for me: https://drive.google.com/drive/folders/1EoPXUBa67AR537ZLHCJsqFIj0wP7is0t?usp=sharing

These are the only two files in the solution with this issue. There are other .cs files in the same folder as well as elsewhere in the project and solution.

image

My .editorconfig file does have the charset set (and I did verify it's the only place it's set):
image

from format.

JoeRobich avatar JoeRobich commented on August 11, 2024

@JeroMiya Who is reporting the encoding as Western European (Windows)? Without a BOM, the heuristic used to guess a file encoding in editors like VS Code can sometimes be confused when two encodings would produce the equivalent bytes on disk. If it is VSCode telling you the files are Western Europe (Windows), then you can configure the files.guessableEncodings setting to restrict the guesses to encodings that you know you use.

from format.

JeroMiya avatar JeroMiya commented on August 11, 2024

The git changes window in Visual Studio is reporting it, but I'll check out your suggestion tomorrow and report back. Thanks!

from format.

jerviscui avatar jerviscui commented on August 11, 2024

Have the same problem.
@JeroMiya

from format.

jerviscui avatar jerviscui commented on August 11, 2024

Test 1:

  1. I executed dotnet format.
  2. In VS Git differents, It suggests the file encoding is GB2312:
    image
    But, In VS Code display is UTF-8.

Test 2:

  1. If input some chines in the file.
  2. Use dotnet format.
  3. Git differents display the formatted file encoding is UTF-8.
    image

Test 3:
When I use Resharper Code Cleanup, the formatted file encoding is correct!
image

In addition, if I commit Test 1 changes, then use Resharper Code Cleanup, The file will not change again.

from format.

dnperfors avatar dnperfors commented on August 11, 2024

I had the same issue, but looking deeper into it I found that the original encoding was wrong (UTF8-BOM) and the new encoding was correctly set (UTF-8). In other words it is working correctly, but VisualStudio can't handle these changes very well.

from format.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.