Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DotStyle Templates

NuGet

DotStyle: .NET Code Governance Baseline (Copilot-Ready)

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.


Why DotStyle?

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.


What's Included

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

How It Works

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

Installation

Option 1 — Install from NuGet

Install the template package:

dotnet new install Csharp.DotStyle.Templates

Verify installation:

dotnet new list dotnet-governance

Option 2 — Install from Source

Clone the repository:

git clone https://github.com/<your-account>/DotStyle.git

Install locally:

dotnet new install ./content/dotnet-governance

Create a DotStyle Baseline

Navigate to your existing .NET repository:

cd YourProject

Run:

dotnet new dotnet-governance

Your project now has the complete DotStyle governance setup.


Recommended First Run

Before committing, apply the formatting baseline:

dotnet format

Commit this separately:

chore: apply DotStyle formatting baseline

Avoid mixing formatting changes with feature changes because it makes reviews harder.


Verify Formatting

Check the repository without changing files:

dotnet format --verify-no-changes --verbosity normal

This is the same validation used by CI.


Git Blame Optimization

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-revs

GitHub will automatically respect this file.


GitHub Copilot Integration

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.


Supported Developer Experience

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

CI Enforcement

Every pull request runs:

dotnet format --verify-no-changes

If formatting rules are violated, the build fails.

Developers fix issues locally:

dotnet format

Template Development

Package Information

Property Value
Package ID Csharp.DotStyle.Templates
Template Name dotnet-governance
Identity Csharp.DotStyle.Templates.DotStyleBaseline
Author Majdi ZLITNI
License MIT

Handling Existing Files

If your repository already contains:

  • .editorconfig
  • Directory.Build.props
  • .github/workflows/code-style.yml

.NET will report conflicts.

Review the differences first.

Only use:

dotnet new dotnet-governance --force

when you intentionally want to overwrite existing files.


Optional Extensions

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.


The Main Rule

Style discussions belong in configuration files, not pull requests.

Change the rule once in .editorconfig.

Let automation enforce it forever.

About

A drop-in .NET code standards template designed for modern teams. Enforce clean C# practices through native tooling, automate style checks in CI, and guide AI coding assistants with repository-level instructions.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors