Skip to content

Commit

Permalink
Updating the VSCode extension to support csharpier 1.0.0 (#1428)
Browse files Browse the repository at this point in the history
Includes

- Changes so that the extension can provide formatting for xml on
csharpier 1.0.0
- Changes to support the new tool name + command names on csharpier
1.0.0
- Cleaning up some code that was hiding exception details when things
were failing.
  • Loading branch information
belav authored Jan 8, 2025
1 parent cd052a7 commit 75be6ab
Show file tree
Hide file tree
Showing 14 changed files with 883 additions and 151 deletions.
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

0 comments on commit 75be6ab

Please sign in to comment.