docs(rules): add MAUI and Blazor rules, close C# gaps

New C# topic rules for .NET MAUI and Blazor, both centered on
performance and cross-platform reuse. MAUI covers compilation strategy
per platform (ReadyToRun, NativeAOT), trim and AOT safety, lean startup,
CollectionView and flat layouts, and per-platform conventions. Blazor
covers render mode cost, WebAssembly payload size and AOT trade-offs,
prerender state, rendering cost, and Razor class libraries shared across
web, WebAssembly, and Hybrid hosts. The C# index and global routing now
name both.

The existing C# rules gain the net11.0 default of C# 15, async void only
for event handlers, explicit StringComparison, invariant culture for
machine data, UTC or DateTimeOffset for stored times, ProblemDetails,
and ValidateOnStart. Duplicate authorization and raw SQL guidance in the
architecture rule is merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian LechnerandClaude Opus 5.5 committed 2026-11-18 09:57:17 +01:00
1 parent b74357b586
commit ff33ea1327
9 files changed
+67 -6

No files matched your search

@@ -2,11 +2,11 @@
Apply these rules when designing public APIs, service boundaries, or application architecture.
* Give APIs explicit, strongly typed contracts. On trusted internal paths, do not repeat format or argument validation the boundary already performed. Authorization, resource ownership, and tenant scoping are never "already done": enforce them at the operation that accesses the data.
* Give APIs explicit, strongly typed contracts. On trusted internal paths, do not repeat format or argument validation the boundary already performed.
* Separate request models from persistence and domain models. Bind only fields the caller may set, and project only fields the caller may read.
* Authenticate and authorize before accessing protected resources. Keep the decision close to the protected operation, enforce resource ownership and tenant scope in the data access path, not only in the UI or route layer, and fail closed when identity, ownership, or policy evaluation is unavailable.
* Authenticate and authorize before accessing protected resources. Authorization, resource ownership, and tenant scoping are never "already done": keep the decision close to the protected operation, enforce ownership and tenant scope in the data access path, not only in the UI or route layer, and fail closed when identity, ownership, or policy evaluation is unavailable.
* Use explicit, bounded pagination for potentially large collections.
* Treat EF Core `DbContext` as a short-lived, non-thread-safe unit of work: scoped per request in web apps, created through `IDbContextFactory<T>` per operation in desktop apps and background services, never shared across threads or held as a singleton. Use `AsNoTracking` for read-only queries, and use `FromSql` or `FromSqlInterpolated` instead of concatenating into `FromSqlRaw`.
* Treat EF Core `DbContext` as a short-lived, non-thread-safe unit of work: scoped per request in web apps, created through `IDbContextFactory<T>` per operation in desktop apps and background services, never shared across threads or held as a singleton. Use `AsNoTracking` for read-only queries; raw SQL follows the C# security rules.
* Keep application, domain, and infrastructure concerns separate. Avoid cross-layer coupling and service-locator patterns.
* Use dependency injection when substitution or lifecycle management is needed. Keep dependencies explicit and avoid excessive constructor dependencies.
* Preserve established project and public API conventions unless a concrete compatibility or correctness issue requires a change.