Comments (17)
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.
It's still converting UTF-8 encoded files to Western European (Windows).
from format.
@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.
Thanks so much
from format.
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.
@RehanSaeed which version of dotnet-format are you using?
from format.
4.1.131201
from format.
@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.
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.
I am having this same issue:
Let me know if there's more info you need.
from format.
@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.
- Run
dotnet new console
- Run
code .
- Save Program.cs with the UTF-8 encoding
- Add .editorconfig
root = true
[*]
charset = utf-8
- Run
dotnet format -v d
No files formatted.
from format.
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.
My .editorconfig file does have the charset
set (and I did verify it's the only place it's set):
from format.
@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.
The git changes window in Visual Studio is reporting it, but I'll check out your suggestion tomorrow and report back. Thanks!
from format.
Have the same problem.
@JeroMiya
from format.
Test 1:
- I executed
dotnet format
. - In VS Git differents, It suggests the file encoding is GB2312:
But, In VS Code display is UTF-8.
Test 2:
- If input some chines in the file.
- Use
dotnet format
. - Git differents display the formatted file encoding is UTF-8.
Test 3:
When I use Resharper Code Cleanup, the formatted file encoding is correct!
In addition, if I commit Test 1 changes, then use Resharper Code Cleanup, The file will not change again.
from format.
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)
- --binarylog option broken HOT 3
- Please clarify if this tool is actively supported / worked on HOT 2
- Can I use dotnet format to just generate report and not make the changes to the file. HOT 2
- Issue: Limited Scope for Running the Tool on Changed Files in Pull Requests HOT 1
- running dotnet format on my unity project takes over an hour HOT 2
- .net 8.0.2 Blazor `_imports.razor` & using `IDE0005` HOT 4
- Not detect IDE0290. HOT 1
- IDE0051 format issues with Razor code behind files with SDK 8.0.200 HOT 4
- Questions around Contributing to the Repo HOT 5
- dotnet format is now part of the SDK repo HOT 1
- Wrong indentation when using primary constructor
- Simplify interpolation (IDE0071) - false positive with Enum and FormattableString
- CA1067 on C# record implementing a VB.NET interface
- Does not adhere to language set in `DOTNET_CLI_UI_LANGUAGE`
- Line wrapping and indentation of Collection Literals
- Error Changing document properties is not supported
- CS0534 validation adding wrong code. HOT 1
- pre-commit hook fails: no compatible SDK was found HOT 1
- Feature Request: Support for Excluding Specific Subcommands with --skip in dotnet format
- Can't suppress WHITESPACE warnings HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from format.