Skip to content

Commit

Permalink
self code review
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Jan 4, 2025
1 parent eca9569 commit 792a1fc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
9 changes: 6 additions & 3 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# 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.
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 Down
2 changes: 1 addition & 1 deletion Src/CSharpier.VSCode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "csharpier-vscode",
"displayName": "CSharpier - Code formatter",
"description": "Code formatter using csharpier",
"version": "1.9.2",
"version": "2.0.0",
"publisher": "csharpier",
"author": "CSharpier",
"homepage": "https://marketplace.visualstudio.com/items?itemName=csharpier.csharpier-vscode",
Expand Down
5 changes: 2 additions & 3 deletions Src/CSharpier.VSCode/src/CustomPathInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ export class CustomPathInstaller {
const result =
process.platform !== "win32"
? path.resolve(process.env.HOME!, ".cache/csharpier", version)
: // TODO use two copies of the repo to figure out why csharpier thinks props is not supported

// TODO this is just csharpier.exe on windows, will linux have all lower case too?
: // TODO this is just csharpier.exe on windows, will linux have all lower case too?
// TODO test this with older csharpier to see what it does with xml files, maybe log something to tell the user
path.resolve(process.env.LOCALAPPDATA!, "CSharpier", version);
return result.toString();
}
Expand Down
1 change: 1 addition & 0 deletions Src/CSharpier.VSCode/src/FormatDocumentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class FormatDocumentProvider {

async formatDocument(
document: TextDocument,
// the diagnostic service calls format on almost every keypress, avoid logging those formats so we don't spawn the output
writeLogs: boolean = true,
): Promise<string | null> {
const csharpierProcess = this.csharpierProcessProvider.getProcessFor(document.fileName);
Expand Down
3 changes: 0 additions & 3 deletions Src/CSharpier.VSCode/src/FormattingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import { Logger } from "./Logger";

export class FormattingService {
constructor(private readonly formatDocumentProvider: FormatDocumentProvider) {
// TODO will this cover all the actual xml files, maybe we need to use patterns?
// { pattern: '**/*.{props,csproj}' }

languages.registerDocumentFormattingEditProvider("xml", {
provideDocumentFormattingEdits: this.provideDocumentFormattingEdits,
});
Expand Down

0 comments on commit 792a1fc

Please sign in to comment.