--- applyTo: "**/*.cs" --- # C# Coding Standards ## Language & Target - All code must be written in C# targeting **.NET 10**. - The original Fuchs intranet was VB.NET; any remaining VB must be converted to C# during migration. Original VB reference lives at `D:\My Programming\PWProjects\Fuchs\Fuchs\Areas\Intranet`. ## Style - Follow standard C# naming: **PascalCase** for classes and methods, **camelCase** for locals and parameters, `_camelCase` for private fields. - `ImplicitUsings` and `Nullable` are enabled in the Fuchs project — honor nullable annotations and avoid redundant `using` directives. - Prefer modern, performance-oriented features: `async`/`await` for I/O, LINQ for data manipulation, dependency injection for testability, `switch` expressions, target-typed `new`, and collection initializers. - Only add comments when they match the existing style or explain non-obvious logic. Do not over-comment. ## File Size - Keep files to a soft limit of **400** lines (hard max **600**). - Proactively refactor larger files into smaller, focused classes/partials — this is why `IntranetController` is split into domain partials. ## Dependency Injection - Inject dependencies via constructor (`ILogger`, `IConfiguration`, services). Do not use service-locator or static singletons in new class-level code. - Library classes accept optional loggers (`ILogger?`) defaulting to `NullLogger.Instance` — see `logging.instructions.md`. ## Packages - Do not upgrade `Spire.PDF` beyond `8.10.5`. - For builds failing because `SixLabors.ImageSharp` (v4.0.0+) requires a license, see `imagesharp.instructions.md` before downgrading. - Keep `MailKit`/`MimeKit` versions aligned with OCORE's referenced versions to avoid `NU1605` package-downgrade-as-error. - Only add or update packages when necessary; prefer existing/OCORE libraries.