dotnet format is a built-in .NET CLI tool that enforces .editorconfig rules automatically.
It fixes formatting, code style, and analyzer violations — no extra tools needed.
dotnet format --verify-no-changesReturns a non-zero exit code if any files need formatting. Use this in CI.
dotnet formatFixes everything it can automatically. Run this before committing.
dotnet format whitespacedotnet format styledotnet format analyzersThis repo includes a pre-commit hook that runs dotnet format --verify-no-changes before every commit.
# Copy the hook into your local git hooks directory
cp pre-commit .git/hooks/pre-commit
# Make it executable (macOS/Linux)
chmod +x .git/hooks/pre-commitgit config core.hooksPath .Note: This makes Git look for hooks in the repo root, where the
pre-commitfile already lives.
- Run
dotnet formatafter pulling changes to fix any conflicts - If a rule is too strict, adjust the severity in
.editorconfigrather than disabling format - Use
dotnet format --verbosity diagnosticto see exactly what's being changed - VS Code + C# Dev Kit will respect
.editorconfigrules for real-time feedback