mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
* feat(rules): add C# language support * feat: add everything-claude-code ECC bundle (#705) * feat: add everything-claude-code ECC bundle (.claude/ecc-tools.json) * feat: add everything-claude-code ECC bundle (.claude/skills/everything-claude-code/SKILL.md) * feat: add everything-claude-code ECC bundle (.agents/skills/everything-claude-code/SKILL.md) * feat: add everything-claude-code ECC bundle (.agents/skills/everything-claude-code/agents/openai.yaml) * feat: add everything-claude-code ECC bundle (.claude/identity.json) * feat: add everything-claude-code ECC bundle (.codex/agents/explorer.toml) * feat: add everything-claude-code ECC bundle (.codex/agents/reviewer.toml) * feat: add everything-claude-code ECC bundle (.codex/agents/docs-researcher.toml) * feat: add everything-claude-code ECC bundle (.claude/rules/everything-claude-code-guardrails.md) * feat: add everything-claude-code ECC bundle (.claude/research/everything-claude-code-research-playbook.md) * feat: add everything-claude-code ECC bundle (.claude/team/everything-claude-code-team-config.json) * feat: add everything-claude-code ECC bundle (.claude/enterprise/controls.md) * feat: add everything-claude-code ECC bundle (.claude/commands/database-migration.md) * feat: add everything-claude-code ECC bundle (.claude/commands/feature-development.md) * feat: add everything-claude-code ECC bundle (.claude/commands/add-language-rules.md) --------- Co-authored-by: ecc-tools[bot] <257055122+ecc-tools[bot]@users.noreply.github.com> * ci: retrigger --------- Co-authored-by: ecc-tools[bot] <257055122+ecc-tools[bot]@users.noreply.github.com>
73 lines
2.0 KiB
Markdown
73 lines
2.0 KiB
Markdown
---
|
|
paths:
|
|
- "**/*.cs"
|
|
- "**/*.csx"
|
|
---
|
|
# C# Coding Style
|
|
|
|
> This file extends [common/coding-style.md](../common/coding-style.md) with C#-specific content.
|
|
|
|
## Standards
|
|
|
|
- Follow current .NET conventions and enable nullable reference types
|
|
- Prefer explicit access modifiers on public and internal APIs
|
|
- Keep files aligned with the primary type they define
|
|
|
|
## Types and Models
|
|
|
|
- Prefer `record` or `record struct` for immutable value-like models
|
|
- Use `class` for entities or types with identity and lifecycle
|
|
- Use `interface` for service boundaries and abstractions
|
|
- Avoid `dynamic` in application code; prefer generics or explicit models
|
|
|
|
```csharp
|
|
public sealed record UserDto(Guid Id, string Email);
|
|
|
|
public interface IUserRepository
|
|
{
|
|
Task<UserDto?> FindByIdAsync(Guid id, CancellationToken cancellationToken);
|
|
}
|
|
```
|
|
|
|
## Immutability
|
|
|
|
- Prefer `init` setters, constructor parameters, and immutable collections for shared state
|
|
- Do not mutate input models in-place when producing updated state
|
|
|
|
```csharp
|
|
public sealed record UserProfile(string Name, string Email);
|
|
|
|
public static UserProfile Rename(UserProfile profile, string name) =>
|
|
profile with { Name = name };
|
|
```
|
|
|
|
## Async and Error Handling
|
|
|
|
- Prefer `async`/`await` over blocking calls like `.Result` or `.Wait()`
|
|
- Pass `CancellationToken` through public async APIs
|
|
- Throw specific exceptions and log with structured properties
|
|
|
|
```csharp
|
|
public async Task<Order> LoadOrderAsync(
|
|
Guid orderId,
|
|
CancellationToken cancellationToken)
|
|
{
|
|
try
|
|
{
|
|
return await repository.FindAsync(orderId, cancellationToken)
|
|
?? throw new InvalidOperationException($"Order {orderId} was not found.");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError(ex, "Failed to load order {OrderId}", orderId);
|
|
throw;
|
|
}
|
|
}
|
|
```
|
|
|
|
## Formatting
|
|
|
|
- Use `dotnet format` for formatting and analyzer fixes
|
|
- Keep `using` directives organized and remove unused imports
|
|
- Prefer expression-bodied members only when they stay readable
|