microsoft-extensions
Microsoft.Extensions for .NET
Trigger On
- wiring dependency injection, configuration, logging, or options
- introducing Generic Host patterns into non-web .NET apps
- cleaning up service registration, typed HTTP clients, or shared infrastructure code
Workflow
- Prefer the Generic Host for apps that need configuration, DI, logging, hosted services, or coordinated startup.
- Keep service registration predictable: composition at the edge, concrete implementations hidden behind interfaces only where that abstraction buys flexibility.
- Use options binding for structured configuration and validate configuration at startup when bad settings would fail later at runtime.
- Prefer
IHttpClientFactoryand typed or named clients for outbound HTTP instead of ad-hoc singleton or per-callHttpClientusage. - Use logging categories and config-driven log levels rather than scattered ad-hoc logging behavior.
- Avoid building mini-frameworks over Microsoft.Extensions unless the repo genuinely needs reusable composition primitives.
Deliver
- clean host wiring and service registration
- configuration and logging that are observable and testable
- infrastructure code that fits naturally with the .NET stack
Validate
- service lifetimes are correct
- configuration is strongly typed where it matters
- host setup remains easy to debug and reason about
References
- patterns.md - DI patterns, Configuration patterns, Options pattern, Logging patterns, HttpClientFactory patterns, Hosted Service patterns
- anti-patterns.md - Common mistakes with DI, configuration, options, logging, HttpClient, and hosted services
More from managedcode/dotnet-skills
dotnet-aspnet-core
Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on current .NET.
13dotnet-entity-framework-core
Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications.
12dotnet-code-review
Review .NET changes for bugs, regressions, architectural drift, missing tests, incorrect async or disposal behavior, and platform-specific pitfalls before you approve or merge them.
11dotnet-architecture
Design or review .NET solution architecture across modular monoliths, clean architecture, vertical slices, microservices, DDD, CQRS, and cloud-native boundaries without over-engineering.
11dotnet-signalr
Implement or review SignalR hubs, streaming, reconnection, transport, and real-time delivery patterns in ASP.NET Core applications.
10dotnet-modern-csharp
Write modern, version-aware C# for .NET repositories. Use when choosing language features across C# versions, especially C# 13 and C# 14, while staying compatible with the repo's target framework and `LangVersion`.
10