A drop-in .NET template that enforces consistent C# coding standards across your team.
No StyleCop setup. No configuration drift. No endless pull request discussions about formatting.
DotStyle provides a modern Seed → Ground → Enforce approach using native .NET tooling, .editorconfig, CI validation, and GitHub Copilot instructions.
The goal is simple:
Let developers and AI assistants write code that already follows your team's standards.
Every team eventually faces the same problems:
- Different formatting styles between developers
- Pull requests filled with style comments instead of meaningful reviews
- New developers missing hidden conventions
- AI-generated code that does not match your project standards
DotStyle moves these decisions from human discussions into automated rules.
Installing DotStyle adds the following files to your repository:
├── AGENTS.md # Repository instructions for GitHub Copilot
├── .editorconfig # C# formatting and style rules
├── Directory.Build.props # Enables analyzers and style enforcement
├── global.json # Locks the .NET SDK version
├── .vscode/
│ └── settings.json # VS Code format-on-save configuration
├── .gitignore # Standard .NET ignores
└── .github/
├── workflows/
│ └── code-style.yml # CI style validation
└── instructions/
└── csharp.instructions.md # C# specific Copilot instructions
DotStyle follows three layers:
| Layer | File | Purpose |
|---|---|---|
| 🌱 Seed | AGENTS.md |
Provides coding rules to GitHub Copilot before generating code |
| 🌍 Ground | .editorconfig |
Defines the actual C# style rules used by IDEs and tooling |
| 🚦 Enforce | GitHub Actions workflow | Prevents invalid style from reaching your main branch |
Install the template package:
dotnet new install Csharp.DotStyle.TemplatesVerify installation:
dotnet new list dotnet-governanceClone the repository:
git clone https://github.com/<your-account>/DotStyle.gitInstall locally:
dotnet new install ./content/dotnet-governanceNavigate to your existing .NET repository:
cd YourProjectRun:
dotnet new dotnet-governanceYour project now has the complete DotStyle governance setup.
Before committing, apply the formatting baseline:
dotnet formatCommit this separately:
chore: apply DotStyle formatting baseline
Avoid mixing formatting changes with feature changes because it makes reviews harder.
Check the repository without changing files:
dotnet format --verify-no-changes --verbosity normalThis is the same validation used by CI.
Formatting commits can make git blame noisy.
Create:
.git-blame-ignore-revs
Add your formatting commit SHA:
<formatting-commit-sha>
Enable it:
git config blame.ignoreRevsFile .git-blame-ignore-revsGitHub will automatically respect this file.
DotStyle includes instructions for AI-assisted development.
Copilot automatically reads:
AGENTS.md
.github/instructions/csharp.instructions.md
Verify it:
Ask Copilot:
What coding conventions should you follow in this repository?
It should reference your DotStyle rules.
| Feature | Supported |
|---|---|
| Visual Studio | ✅ Uses .editorconfig |
| JetBrains Rider | ✅ Uses .editorconfig |
| VS Code | ✅ Uses .editorconfig + format-on-save |
| dotnet CLI | ✅ Uses dotnet format |
| GitHub Actions | ✅ Automatic validation |
| GitHub Copilot | ✅ Repository-aware instructions |
Every pull request runs:
dotnet format --verify-no-changesIf formatting rules are violated, the build fails.
Developers fix issues locally:
dotnet format| Property | Value |
|---|---|
| Package ID | Csharp.DotStyle.Templates |
| Template Name | dotnet-governance |
| Identity | Csharp.DotStyle.Templates.DotStyleBaseline |
| Author | Majdi ZLITNI |
| License | MIT |
If your repository already contains:
.editorconfigDirectory.Build.props.github/workflows/code-style.yml
.NET will report conflicts.
Review the differences first.
Only use:
dotnet new dotnet-governance --forcewhen you intentionally want to overwrite existing files.
DotStyle focuses only on code consistency.
For deeper analysis consider adding:
- CSharpier — zero-config C# formatter
- SonarQube / SonarCloud — security, complexity, and quality analysis
These complement DotStyle but solve different problems.
Style discussions belong in configuration files, not pull requests.
Change the rule once in .editorconfig.
Let automation enforce it forever.