csharp-house-style
Skill1 starsChanged 6 days agoMITView on GitHub
The house C# style enforced by .editorconfig and the build - this. qualification, usings inside file-scoped namespaces, discards, regions, primary constructors, nullable and naming. Use whenever writing or reviewing C# in this solution.
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-a-use-caseSkill
- api-conventionsSkill
- branches-and-pull-requestsSkill
- cancellationSkill
- ci-for-your-solutionSkill
- ci-pipelineSkill
- clean-architecture-layersSkill
- configuration-and-environmentsSkill
- coverageSkill
- data-access-ef-coreSkill
- database-migrationsSkill
- docker-and-composeSkill
- docs-and-voiceSkill
- errors-and-exceptionsSkill
- expose-a-use-caseSkill
- family-syncSkill
- health-checksSkill
- integration-testsSkill
- json-serializationSkill
- mapping-with-mapperlySkill
- mcp-inspectorSkill
- mediatorSkill
- optional-token-authSkill
- packages-and-dependenciesSkill
- pagingSkill
- presentation-integration-testsSkill
- releasesSkill
- sample-dataSkill
- security-findingsSkill
- serilogSkill
- telemetrySkill
- template-authoringSkill
- test-designSkill
- time-providerSkill
- unit-testsSkill
- validationSkill
- writing-a-skillSkill
- xml-docs-and-openapiSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Write the code to match a neighbouring file.
- Very specific: line 33
Run dotnet format to fix whitespace and using order.
- Very specific: line 34
Run dotnet build and fix every warning.
- Very specific: line 39
Add #pragma warning disable or <NoWarn> to quiet an analyser.
- Distinctive: line 41
Leave unused usings; IDE0005 fails the build.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
C# house style
The rule
.editorconfig holds the style and the build enforces it (EnforceCodeStyleInBuild, AnalysisLevel latest-recommended, TreatWarningsAsErrors, all in Directory.Build.props). If the build is clean and dotnet format --verify-no-changes passes, the style is right. These are the parts that differ from most .NET code, so they're the ones people trip on.
| Rule | Looks like |
File-scoped namespace first, then using directives inside it | namespace X.Y; then using Mediator; |
Qualify members with this. | this.context.Reviews, this.RuleFor(...) |
Discard unused results with _ = | _ = services.AddScoped<...>(); |
var everywhere | var result = ... |
Braces on every if, Allman style | opening brace on its own line |
| Block bodies for methods and constructors | no => expression methods |
| Primary constructors for injected services | public class XHandler(IRepo repository) |
#region to group long classes | #region Authors ... #endregion Authors |
| Nullable reference types on | string? when null is a real value |
| Collection expressions | [.. result.Select(...)], List<T> x = []; |
Async methods return ValueTask in handlers, Task in repositories | as the interfaces declare |
Naming: PascalCase types and members, camelCase locals and parameters, no underscores on fields (this. tells you it's a field). Interfaces start with I.
Steps
- Write the code to match a neighbouring file.
- Run
dotnet formatto fix whitespace and using order. - Run
dotnet buildand fix every warning. Nullable warnings are fixed with real null handling, not!, except for EF navigation properties (= null!).
Don't
- Move usings above the namespace or drop
this.to match another codebase. - Add
#pragma warning disableor<NoWarn>to quiet an analyser. - Use
_camelCasefields. - Leave unused usings; IDE0005 fails the build.
Check
dotnet format --verify-no-changes
dotnet buildDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

