dotnet-patterns
/dotnet-patterns
Dostarcza podręcznik budowania backendu w C# i .NET: API ASP.NET Core, workery, EF Core, układ projektu, czasy życia DI, async, wzorzec opcji, kontrakt błędów i kształt testów.
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 24.09.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Dostarcza podręcznik budowania backendu w C# i .NET: API ASP.NET Core, workery, EF Core, układ projektu, czasy życia DI, async, wzorzec opcji, kontrakt błędów i kształt testów.
Oryginalny opis (EN)
Use when writing C#/.NET backend code — ASP.NET Core APIs (minimal APIs or MVC), workers, EF Core data access. Builder playbook: layout, DI lifetimes, async/cancellation, EF Core discipline, options pattern, error contract, testing shape. Complements csharp-reviewer.
Jak działa
- Layout
- DI lifetimes (the classic traps)
- Async all the way
- EF Core discipline
- Config — options pattern
- Error contract
- Testing shape
Podgląd SKILL.md
--- name: dotnet-patterns description: Use when writing C#/.NET backend code — ASP.NET Core APIs (minimal APIs or MVC), workers, EF Core data access. Builder playbook: layout, DI lifetimes, async/cancellation, EF Core discipline, options pattern, error contract, testing shape. Complements csharp-reviewer. --- # C#/.NET Backend Patterns ## Layout - Vertical slices (feature folders: endpoint + handler + models per feature) for API-shaped services; full Clean Architecture layering only when the domain genuinely warrants it — record the choice as an ADR either way. - Minimal APIs for small/medium surfaces; MVC controllers when filters/model-binding complexity earns it. ## DI lifetimes (the classic traps) - Scoped services must NEVER be captured by singletons (captive dependency — resolve via `IServiceScopeFactory` inside the singleton instead). - `HttpClient` via `IHttpClientFactory`, never `new HttpClient()` per call (socket exhaustion). - Register by interface at the boundary you intend to fake in tests; concrete elsewhere is fine. ## Async all the way - No `.Result`/`.Wait()`/`GetAwaiter().GetResult()` on async paths — deadlock and threadpool starvation fuel. - `CancellationToken` flows from the endpoint through every service and EF call: `await db.Orders.ToListAsync(ct)`. Endpoints accept it; libraries propagate it. - `ValueTask` only where profiling justifies it; default is `Task`. ## EF Core discipline - Reads: `AsNoTracking()` by default; project to DTOs with `Select` — never return entities from queries that don't update. - No lazy-loading proxies: load explicitly (`Include`) so every query's shape is visible — N+1 becomes impossible to miss. - Migrations: one migration per change, reviewed like code; destructive column changes follow expand-contract (see db-optimization skill). - Transactions explicit where multi-write consistency matters (`ExecutionStrategy` + `TransactionScope`-free patterns with `BeginTransactionAsync`). ## Config — options pattern - `IOptions<T>` with `ValidateDataAnnotations().ValidateOnStart()` — invalid config fails the boot, not the first request. - Secrets from user-secrets/KeyVault/env — never appsettings committed values. ## Error contract - `ProblemDetails` (RFC 9457) via `AddProblemDetails()`; exceptions mapped centrally (exception handler middleware), typed domain exceptions → status codes. No try/catch per controller. - Nullable reference types ON project-wide; warnings as errors for new code. ## Testing shape - xUnit; unit tests fake at the interface boundary. - `WebApplicationFactory<Program>` for integration tests over the real pipeline (routing, filters, serialization) with a test database (Testcontainers where Docker exists). - Snapshot the API surface where the contract matters (Verify/ApiApprovals) so drift is a failing test.
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · jdanigo/hydraia | 90 | MIT |
| affaan-m/ECC | 100 | MIT |
| j4flmao/agent-skills | 95 | MIT |
Migawka bazy z 28.10.2026 · wersja paczki f6b575d8b987 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100csharp-dotnet
Pomaga pisać, recenzować, testować i wydawać kod C# i .NET: API ASP.NET Core (minimal API lub kontrolery), dostęp do danych EF Core, poprawność async i układ solucji. - 100csharp-dotnet
Podaje wzorce C# i .NET: Clean Architecture, wstrzykiwanie zależności, async, wzorzec Result, Minimal API, zapytania EF Core i testy jednostkowe. - 90dotnet-minimal-apis
Buduje minimalne API ASP.NET Core z grupami endpointów, filtrami i typowanymi wynikami oraz pomaga wybrać między minimal APIs a kontrolerami MVC. - 90dotnet-backend-patterns
Dostarcza wzorce .NET i ASP.NET Core dla REST API, Entity Framework, wstrzykiwania zależności i middleware, przy pracy z plikami C# i projektami csproj. - 100neo-dotnet
Rozpoznaje kształt projektu .NET, uruchamia lub poleca polecenia .NET CLI i kieruje do właściwych skilli, takich jak Minimal APIs, Web API, MVC, EF Core i C#. - 100dotnet-core-expert
Pomaga budować aplikacje .NET Core o architekturze cloud-native, wydajne mikroserwisy, nowoczesne wzorce C# i wdrożenia wieloplatformowe z minimal APIs i funkcjami ASP.NET Core.