> For the complete documentation index, see [llms.txt](https://framework.aic.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://framework.aic.io/technical-guidelines-code-standards-and-tech-stack/c-code-standards/formatting-and-style-standards.md).

# Formatting and Style Standards

## Purpose

Formatting must not be a matter of personal preference inside a project. It should be automated, consistent and enforced before code review.

## AIC Standard

* Use `.editorconfig` at repository root.
* Use file-scoped namespaces for new code unless project style differs.
* Use four spaces for indentation.
* Use braces for all multi-line control blocks.
* Prefer explicit access modifiers.
* Prefer one public type per file.
* Keep files focused and cohesive.
* Remove unused usings.
* Sort usings consistently.
* Use expression-bodied members only when they improve clarity.

## Example Style

```csharp
namespace Aic.Cases.Application.Assignments;

public sealed class CaseAssignmentService : ICaseAssignmentService
{
    private readonly ICaseRepository _caseRepository;
    private readonly IClock _clock;

    public CaseAssignmentService(ICaseRepository caseRepository, IClock clock)
    {
        _caseRepository = caseRepository;
        _clock = clock;
    }

    public async Task AssignAsync(
        CaseId caseId,
        UserId userId,
        CancellationToken cancellationToken)
    {
        var caseRecord = await _caseRepository.GetAsync(caseId, cancellationToken);

        if (caseRecord is null)
        {
            throw new CaseNotFoundException(caseId);
        }

        caseRecord.AssignTo(userId, _clock.UtcNow);

        await _caseRepository.SaveAsync(caseRecord, cancellationToken);
    }
}
```

## Line Length

AIC does not enforce a rigid line length where it harms readability, but code should generally remain readable on standard review screens.

Use line breaks for:

* long parameter lists
* fluent chains
* LINQ queries
* object initializers
* attribute lists

## Formatting Gate

Before merge:

```bash
dotnet format --verify-no-changes
```

Where ReSharper cleanup is part of the project gate, run the agreed cleanup profile before PR submission.
