diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d24f8a7..87188fd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -185,7 +185,7 @@ dotnet format --verify-no-changes pwsh ./scripts/format.ps1 ``` -See [README-FORMATTING.md](README-FORMATTING.md) for detailed formatting rules. +See [README-FORMATTING.md](docs/README-FORMATTING.md) for detailed formatting rules. --- diff --git a/README.md b/README.md index 9bacc89..ba822b7 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) f - **GitHub Repository:** [https://github.com/Chris-Wolfgang/ETL-Abstractions](https://github.com/Chris-Wolfgang/ETL-Abstractions) - **API Documentation:** https://Chris-Wolfgang.github.io/ETL-Abstractions/ -- **Formatting Guide:** [README-FORMATTING.md](README-FORMATTING.md) +- **Formatting Guide:** [README-FORMATTING.md](docs/README-FORMATTING.md) - **Contributing Guide:** [CONTRIBUTING.md](CONTRIBUTING.md) --- @@ -154,7 +154,7 @@ dotnet format dotnet format --verify-no-changes ``` -See [README-FORMATTING.md](README-FORMATTING.md) for detailed formatting guidelines. +See [README-FORMATTING.md](docs/README-FORMATTING.md) for detailed formatting guidelines. ### Building Documentation diff --git a/docs/README-FORMATTING.md b/docs/README-FORMATTING.md new file mode 100644 index 0000000..9409890 --- /dev/null +++ b/docs/README-FORMATTING.md @@ -0,0 +1,68 @@ +# Code Formatting + +This repository uses `dotnet format` to enforce consistent C# code style. + +## Prerequisites + +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-format` global tool was deprecated when `dotnet format` was integrated into the .NET 6 SDK in August 2021. + +## For Developers + +### Before Committing + +Run the formatting script with PowerShell Core (`pwsh`) on any supported platform: + +```powershell +pwsh ./scripts/format.ps1 +``` + +Or check without making changes: + +```powershell +pwsh ./scripts/format.ps1 -Check +``` + +### Manual Formatting + +```bash +dotnet format +``` + +### Check Formatting (like CI does) + +```bash +dotnet format --verify-no-changes +``` + +## Configuration + +Code style rules are defined in `.editorconfig` at the repository root. + +## CI/CD + +All pull requests are automatically checked for proper formatting. PRs with formatting issues will fail the build. + +### If CI Fails + +1. Run `pwsh ./scripts/format.ps1` locally +2. Review the changes +3. Commit and push the formatted code + +## IDE Integration + +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 + +## Formatting Rules + +Key style rules: +- **Indentation**: 4 spaces for C# (with `switch` case 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) for most files; PowerShell scripts (`*.ps1`) use CRLF as configured in `.editorconfig` +- **Trailing whitespace**: Removed +- **Using directives**: System namespaces first, sorted alphabetically diff --git a/scripts/format.ps1 b/scripts/format.ps1 index 1c4dc1e..0a296dc 100644 --- a/scripts/format.ps1 +++ b/scripts/format.ps1 @@ -11,11 +11,11 @@ If specified, only checks formatting without making changes (like CI does). .EXAMPLE - .\format.ps1 + pwsh ./scripts/format.ps1 Formats all code in the repository. .EXAMPLE - .\format.ps1 -Check + pwsh ./scripts/format.ps1 -Check Checks formatting without making changes. #>