From 792a1fca4d03c872a6d4a6e9027cc1e9a7998fa2 Mon Sep 17 00:00:00 2001 From: Bela VanderVoort Date: Sat, 4 Jan 2025 15:34:50 -0600 Subject: [PATCH] self code review --- Src/CSharpier.VSCode/README.md | 9 ++++++--- Src/CSharpier.VSCode/package.json | 2 +- Src/CSharpier.VSCode/src/CustomPathInstaller.ts | 5 ++--- Src/CSharpier.VSCode/src/FormatDocumentProvider.ts | 1 + Src/CSharpier.VSCode/src/FormattingService.ts | 3 --- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Src/CSharpier.VSCode/README.md b/Src/CSharpier.VSCode/README.md index 7cb830f8c..8c748ac83 100644 --- a/Src/CSharpier.VSCode/README.md +++ b/Src/CSharpier.VSCode/README.md @@ -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 @@ -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` diff --git a/Src/CSharpier.VSCode/package.json b/Src/CSharpier.VSCode/package.json index f6463375d..7c59d83f3 100644 --- a/Src/CSharpier.VSCode/package.json +++ b/Src/CSharpier.VSCode/package.json @@ -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", diff --git a/Src/CSharpier.VSCode/src/CustomPathInstaller.ts b/Src/CSharpier.VSCode/src/CustomPathInstaller.ts index ed9c5d209..a12df1c10 100644 --- a/Src/CSharpier.VSCode/src/CustomPathInstaller.ts +++ b/Src/CSharpier.VSCode/src/CustomPathInstaller.ts @@ -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(); } diff --git a/Src/CSharpier.VSCode/src/FormatDocumentProvider.ts b/Src/CSharpier.VSCode/src/FormatDocumentProvider.ts index 69d5e25bc..38a102f8b 100644 --- a/Src/CSharpier.VSCode/src/FormatDocumentProvider.ts +++ b/Src/CSharpier.VSCode/src/FormatDocumentProvider.ts @@ -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 { const csharpierProcess = this.csharpierProcessProvider.getProcessFor(document.fileName); diff --git a/Src/CSharpier.VSCode/src/FormattingService.ts b/Src/CSharpier.VSCode/src/FormattingService.ts index e82550281..4524a1875 100644 --- a/Src/CSharpier.VSCode/src/FormattingService.ts +++ b/Src/CSharpier.VSCode/src/FormattingService.ts @@ -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, });