This repository uses dotnet format to enforce consistent C# code style.
The dotnet format command is built into the .NET SDK starting with .NET 6 and later. Since this project requires .NET 8.0 SDK or later, you already have dotnet format available — no separate tool installation is needed.
Note: The standalone
dotnet-formatglobal tool was deprecated whendotnet formatwas integrated into the .NET 6 SDK in August 2021.
Run the formatting script with PowerShell Core (pwsh) on any supported platform:
.\format.ps1Or check without making changes:
.\format.ps1 -Checkdotnet formatdotnet format --verify-no-changesCode style rules are defined in .editorconfig at the repository root.
All pull requests are automatically checked for proper formatting. PRs with formatting issues will fail the build.
- Run
.\format.ps1locally - Review the changes
- Commit and push the formatted code
Most IDEs automatically read .editorconfig:
- Visual Studio: Built-in support, formats on save (Tools → Options → Text Editor → C# → Code Style)
- VS Code: Install "EditorConfig for VS Code" extension
- JetBrains Rider: Built-in support
Key style rules:
- Indentation: 4 spaces for C# (with
switchcase contents not additionally indented when inside a block, per.editorconfig), 2 for XML/JSON - Braces: Opening brace on new line
- Line endings: LF (Unix style)
- Trailing whitespace: Removed
- Using directives: System namespaces first, sorted alphabetically