Enforces strict C# coding conventions for Project KONGOR including naming, formatting, documentation, and code generation practices with British English standards.
Enforce comprehensive coding standards for Project KONGOR, an open-source C# codebase. This skill ensures consistency in syntax, formatting, naming conventions, documentation, and code generation practices.
1. **Never use `var`** — always use explicit type names for variable declarations.
2. **Acronym and initialism casing:**
- PascalCase: Always uppercase (e.g., `UserID`, `GetGUID`, `HTMLParser`)
- camelCase: Only uppercase if not at the start (e.g., `userGUID`, `accountID`, `httpStatusCode`)
- WRONG: `UserId`, `GetGuid`, `HtmlParser`, `userGuid`, `accountId`, `hTTPStatusCode`
3. **Full variable names for delegates and lambdas** — never use single-letter abbreviations:
- RIGHT: `numbers.Select(number => number * number)`
- WRONG: `numbers.Select(x => x * x)`
4. **Use full words** — avoid abbreviations in symbol names:
- RIGHT: `configuration`, `administrator`, `implementation`
- WRONG: `config`, `admin`, `impl`
5. **Async method naming** — only use `Async` suffix when a synchronous version exists in the same scope.
1. **Indentation:** Always use four spaces. Never use tabs.
2. **File termination:** Always terminate files with a newline character.
3. **Vertical whitespace:** Keep consistent with surrounding code. Inspect existing code and match its conventions.
4. **Switch expression alignment:** Align lambda operators for readability:
```csharp
return UserType switch
{
UserType.Staff => "internal",
UserType.Client => "external",
_ => throw new ArgumentOutOfRangeException(@$"Unsupported User Type ""{UserType}""")
};
```
5. **Global using directives:** Prefer global usings in `Internals/UsingDirectives.cs`:
- Keep in lexicographic order, grouped by assembly
- Use `global using` syntax (not `using global::`)
- Example: `global using Aspire.Hosting;`
1. **Comments (StartCase):**
- Use StartCase for comments, preserving original casing for acronyms and symbol names
- Example: `// This Is A Sample Comment Explaining The Purpose Of The "request" Variable In The HTTP Handler`
2. **XML summaries (sentence case):**
- Use sentence case with correct indentation and punctuation
- End each sentence with punctuation
```csharp
/// <summary>
/// This method retrieves user information based on the provided user ID.
/// It does so by using the "request" variable from the HTTP handler.
/// </summary>
```
3. **Symbol references:**
- Use `<see cref="SymbolName"/>` tags when possible
- Do not include parameters: `<see cref="CalculateTotal"/>` (not `<see cref="CalculateTotal(int, int)"/>`)
- Otherwise, enclose symbol names in double quotes: `"GetUserData"`
4. **Boolean and null literals in comments:**
- Use uppercase: `TRUE`, `FALSE`, `NULL` to distinguish from natural language
5. **Only add comments that add value** — avoid obvious statements. Explain why, not what.
**Always use British English** for all code and comments. Never use American English.
1. **Null-forgiving operator (`!`)** — avoid except in these cases:
- Entity Framework `Include`/`ThenInclude` navigation properties known to be non-null
- Assigning `null!` when unavoidable and runtime null is impossible
2. **Security:** Follow best practices to prevent injection attacks, data leaks, and unauthorized access. Check online sources when necessary.
1. **Syntactic correctness:** Ensure generated code adheres to language best practices. Verify against latest standards when possible.
2. **Performance optimization:** Write efficient code unless readability/maintainability suffers significantly.
3. **Consistency:** Match existing codebase style, conventions, and architecture. Inspect surrounding code.
4. **Targeted objectives:** Avoid unnecessary features. Keep code minimal and aligned with specified goals.
5. **Simplicity over complexity:**
- Avoid over-engineering
- Prefer straightforward, easy-to-understand code
- Minimize unnecessary abstractions or layers
6. **When in doubt:** Present options clearly to the user and let them decide.
```csharp
// Internals/UsingDirectives.cs
global using System;
global using System.Collections.Generic;
global using System.Linq;
global using Microsoft.EntityFrameworkCore;
// UserService.cs
/// <summary>
/// Retrieves user information based on the provided user ID.
/// Uses Entity Framework to query the "Users" table.
/// </summary>
public async Task<UserData> GetUserDataAsync(int userID)
{
List<User> users = await dbContext.Users
.Where(user => user.ID == userID)
.Include(user => user.Profile!)
.ToListAsync();
return users.FirstOrDefault() switch
{
not null => MapToUserData(users.First()),
null => throw new InvalidOperationException($"User with ID {userID} not found.")
};
}
```
When generating or reviewing code, ensure:
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/c-project-kongor-coding-standards/raw