dotnet / dotnet/format

dotnet format cannot format the charset for *.json and *.csproj

Open
#1,755 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
1.9k
Forks
173
Avg merge
10d 13h
Merged PRs (30d)
1

Description

I have a `.editorconfig` file in my project that specifies the charset as `utf-8` for all the files:
```
[*]
charset = utf-8
```

But `dotnet format` cannot change the charset to `utf-8` if the `*.json`, `*.csproj` files are encoded by `utf-8 with BOM`.

## How to reproduce
1. Run `dotnet new webapi -o FormatDemo` to create a new web api project.
2. Create a `.editorconfig` file in the root folder and specify the charset as `uft-8` for all the files.
3. Note that the `launchSettings.json` file in the `Properties` folder is encoded by `utf-8 with BOM`.
4. Run `dotnet format`. Then the encoding of `launchSettings.json` is still `utf-8 with BOM`.
5. Change the encoding of `FormatDemo.csproj` to `utf-8 with BOM`.
6. Run `dotnet format` and it cannot format `FormatDemo.csproj` in `utf-8` either.

## Expected behavior

If any `*.json` and `*.csproj` files are encoded in `utf-8 with BOM`, `dotnet format` should format them to `utf-8` if `utf-8` is specified in `.editorconfig`. And vice versa.

Thanks.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.