Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating the VSCode extension to support csharpier 1.0.0 #1428

Merged
merged 10 commits into from
Jan 8, 2025
3 changes: 3 additions & 0 deletions Src/CSharpier.VSCode/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.0.0
- Adding support for CSharpier 1.0.0 which includes the ability to format xml files.

## 1.9.2
- Add option for diagnostic level, default to warning
- Modify behavior of diagnostics so that new ones only appear on file save, not as a user types.
Expand Down
19 changes: 14 additions & 5 deletions Src/CSharpier.VSCode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

This extension makes use of the dotnet tool [CSharpier](https://github.com/belav/csharpier) to format your code and is versioned independently.

CSharpier is an opinionated code formatter for c#.
It uses Roslyn to parse your code and re-prints it using its own rules.
The printing process was ported from [prettier](https://prettier.io) but has evolved over time.
CSharpier is an opinionated code formatter for c# and xml. \
It provides very few options and provides a deterministic way to enforce formatting of your code. \
The printing process was ported from [prettier](https://prettier.io) but has evolved over time. \

## Installation

Expand All @@ -19,6 +19,9 @@ ext install csharpier.csharpier-vscode
## CSharpier Version
The extension determines which version of csharpier is needed to format a given file by looking for a dotnet manifest file. If one is not found it looks for a globally installed version of CSharpier.

## XML Formatting
Formatting XML is only available using CSharpier >= 1.0.0

## Dotnet Commands
The extension makes use of `dotnet` commands and uses the following logic to locate `dotnet`.
- If `dotnet.dotnetPath` is set try using that to find `dotnet`
Expand All @@ -27,12 +30,15 @@ The extension makes use of `dotnet` commands and uses the following logic to loc
- For non-windows - Try running `sh -c "dotnet --info"` to see if `dotnet` is on the PATH

## Default Formatter
To ensure that CSharpier is used to format c# files, be sure to set it as the default formatter.
To ensure that CSharpier is used to format files, be sure to set it as the default formatter.

```json
"[csharp]": {
"editor.defaultFormatter": "csharpier.csharpier-vscode"
}
},
"[xml]": {
"editor.defaultFormatter": "csharpier.csharpier-vscode"
},
```

## Usage
Expand All @@ -57,6 +63,9 @@ You can turn on format-on-save on a per-language basis by scoping the setting:
// Enable per-language
"[csharp]": {
"editor.formatOnSave": true
},
"[xml]": {
"editor.formatOnSave": true
}
```

Expand Down
Loading
Loading