Comprehensive C# coding standards covering syntax, formatting, naming conventions, and code generation principles for the Project KONGOR open-source codebase.
This skill enforces comprehensive C# coding standards for the Project KONGOR open-source project. It covers syntax, formatting, naming conventions, British English usage, and code generation principles to maintain consistency and quality across the codebase.
When writing or reviewing C# code for Project KONGOR, enforce the following guidelines:
**Acronyms and Initialisms:**
- ✅ `UserID`, `GetGUID`, `HTMLParser`
- ❌ `UserId`, `GetGuid`, `HtmlParser`
- ✅ `userGUID`, `accountID`, `httpStatusCode`
- ❌ `userGuid`, `accountId`, `hTTPStatusCode`
**Delegates and Lambda Parameters:**
- ✅ `numbers.Select(number => number * number);`
- ❌ `numbers.Select(x => x * x);`
**Symbol Names:**
- ✅ `configuration`, `administrator`, `implementation`
- ❌ `config`, `admin`, `impl`
**Async Methods:**
**Vertical Whitespace:**
**Switch Expressions:**
```csharp
return UserType switch
{
UserType.Staff => "internal",
UserType.Client => "external",
_ => throw new ArgumentOutOfRangeException(@$"Unsupported User Type ""{UserType}""")
};
```
**Using Directives:**
- ✅ `global using Aspire.Hosting;`
- ❌ `using global::Aspire.Hosting;`
**Code Comments:**
- Example: `// This Is A Sample Comment Explaining The Purpose Of The "request" Variable In The HTTP Handler`
**XML Documentation Summaries:**
```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>
```
**See Cref Tags:**
- ✅ `<see cref="CalculateTotal"/>`
- ❌ `<see cref="CalculateTotal(int, int)"/>`
- ✅ `colour`, `optimise`, `realise`
- ❌ `color`, `optimize`, `realize`
**Null-Forgiving Operator (!):**
- When using `Include` or `ThenInclude` in Entity Framework queries for navigation properties known to be non-null.
- When assigning `null!` is unavoidable without making code overly complex AND runtime null is impossible.
When generating code:
**Correctness:**
**Performance:**
**Security:**
**Consistency:**
**Targeted Implementation:**
**Simplicity Over Complexity:**
```csharp
public async Task<User> GetUserByID(int userID)
{
return await users.FirstOrDefault(user => user.ID == userID);
}
```
```csharp
return role switch
{
Role.Administrator => AccessLevel.Full,
Role.Moderator => AccessLevel.Limited,
Role.User => AccessLevel.Basic,
_ => throw new ArgumentException(@$"Unknown role ""{role}""")
};
```
```csharp
/// <summary>
/// Retrieves the user's configuration settings from the database.
/// If no configuration exists, creates a default configuration and returns it.
/// </summary>
/// <param name="userID">The unique identifier for the user.</param>
/// <returns>The user's configuration object.</returns>
public async Task<Configuration> GetUserConfiguration(int userID)
{
// Implementation Here
}
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/c-coding-guidelines-for-project-kongor/raw