Loading...
Loading...
Use when working with C#, F#, .NET libraries, ASP.NET Core, Blazor, Entity Framework Core, and the broader .NET ecosystem. USE FOR: .NET language features, choosing libraries and frameworks, project structure, package selection, architecture decisions DO NOT USE FOR: specific library configuration details (use the sub-skills: web, data, testing, eventing, cloud, etc.)
npx skill4agent add tyler-r-kendrick/agent-skills dotnetdotnet/
├── ai/ # ML.NET, ONNX, Azure AI, Microsoft.Extensions.AI, agents (A2A, MCP)
├── cli/ # Spectre.Console, CliWrap, command-line cheatsheet
├── cloud/ # Aspire, Azure Functions, Dapr, Orleans, service discovery
├── configuration/ # Extensions.Configuration, caching, feature flags, OpenFeature
├── data/ # EF Core, Dapper, Redis, Lucene.NET, FluentStorage
├── dependency-injection/ # Extensions.DI, Generic Host, Spring.NET
├── documentation/ # OpenAPI / Swagger
├── eventing/ # MediatR, MassTransit, NServiceBus, Rebus, Wolverine, Brighter, Akka.NET
├── functional/ # F#, Language.Ext, FParsec, Optional, pidgin
├── general/ # Humanizer, ImageSharp, NodaTime, Stateless, worker services, cheatsheet
├── localization/ # i18n, resource-based localization, MessageFormat
├── logging/ # Serilog, NLog, Extensions.Logging
├── mapping/ # AutoMapper, Mapperly
├── networking/ # gRPC, DotNetty, MimeKit, System.IO.Pipelines, Twilio
├── observability/ # OTLP logging, OpenTelemetry conventions
├── project-system/ # MSBuild/csproj, Roslyn analyzers, source generators, EditorConfig, Fody
├── reactive/ # Rx.NET, System.Threading.Channels, DynamicData, IAsyncEnumerable
├── resilience/ # Polly, Extensions.Resilience
├── security/ # ASP.NET Identity, cryptography, authorization (Topaz, Enforcer)
├── serialization/ # Protobuf-net, Bond, Hyperion, FluentSerializer
├── testing/ # Testcontainers, Moq, AutoFixture, Pact, Reqnroll, Playwright
├── ui/ # MAUI, Avalonia, Blazor, Uno Platform, Blazorise, MonoGame, Unity
├── validation/ # FluentValidation, Validot, Parse Don't Validate, CommunityToolkit.Guard
└── web/ # ASP.NET Core, SignalR, YARP, Ocelot, GraphQL, Refit, Orchard CMS| Problem | Sub-Skill | Notes |
|---|---|---|
| Build a web API or microservice | | Minimal APIs for simple endpoints, controllers for complex APIs |
| Add real-time push to a web app | | WebSocket abstraction with automatic fallback to SSE/long-polling |
| Reverse proxy or API gateway | | YARP for high-perf programmatic proxy, Ocelot for config-driven gateway |
| GraphQL API | | Hot Chocolate server with filtering, sorting, subscriptions |
| Access a relational database | | Full ORM with migrations, change tracking, LINQ queries |
| Lightweight SQL queries | | Micro-ORM, raw SQL with object mapping, best for read-heavy paths |
| Distributed cache | | Redis for shared cache, IMemoryCache/IDistributedCache for local/hybrid |
| Event-driven / CQRS architecture | | In-process mediator; combine with |
| Message bus (RabbitMQ, Kafka, Azure SB) | | Abstraction over transports with sagas, retries, and outbox pattern |
| Build a .NET Aspire app | | Orchestrate multi-project apps with built-in service discovery and telemetry |
| Serverless functions | | Isolated worker model for Azure Functions with DI and middleware |
| Resilience (retries, circuit breakers) | | Configurable policies; use |
| Structured logging | | Sinks for Console, Seq, Elasticsearch, Application Insights |
| Object mapping | | Source-generator-based mapper (zero reflection, compile-time safe) |
| Input validation | | Fluent rules with DI integration and ASP.NET Core auto-validation |
| Integration testing with real DBs | | Docker-based throwaway containers for Postgres, SQL Server, Redis |
| Mocking in unit tests | | Proxy-based mocking with LINQ setup expressions |
| Contract testing | | Consumer-driven contract tests for microservice boundaries |
| BDD / Gherkin | | SpecFlow successor — Given/When/Then with .NET 8+ support |
| Cross-platform desktop app | | XAML-based UI for Windows, macOS, Linux, iOS, Android, WebAssembly |
| Mobile + desktop from one codebase | | Microsoft's official cross-platform UI framework (.NET 8+) |
| Interactive web UI in C# | | Server-side or WebAssembly rendering with Razor components |
| Functional programming in C# | | Immutable collections, Option/Either monads, pattern matching extensions |
| F# language guidance | | Type providers, computation expressions, pipelines, domain modeling |
| AI/ML inference | | Unified abstraction for OpenAI, Azure AI, Ollama, and custom providers |
| Train ML models in .NET | | AutoML, classification, regression, anomaly detection, recommendation |
| Build a CLI tool | | Rich terminal UI with tables, trees, progress bars, prompts |
| Source generators | | Compile-time code generation with Roslyn incremental generators |
| Roslyn code analysis | | Custom analyzers and code fixes for enforcing team conventions |
| Version | Release | Support | Key Features |
|---|---|---|---|
| .NET 6 | Nov 2021 | LTS (ended Nov 2024) | Minimal APIs, hot reload, |
| .NET 7 | Nov 2022 | STS (ended May 2024) | Native AOT for console apps, rate limiting middleware, output caching |
| .NET 8 | Nov 2023 | LTS (until Nov 2026) | .NET Aspire, |
| .NET 9 | Nov 2024 | STS (until May 2026) | |
// Global usings (C# 10) — reduce boilerplate across files
global using System.Text.Json;
global using Microsoft.Extensions.Logging;
// File-scoped namespaces (C# 10)
namespace MyApp.Services;
// Records with positional syntax — immutable data types
public record OrderPlaced(Guid OrderId, string CustomerId, decimal Total, DateTime PlacedAt);
// Primary constructors (C# 12) — DI without field ceremony
public class OrderService(IOrderRepository repo, ILogger<OrderService> logger)
{
public async Task<Order> GetAsync(Guid id)
{
logger.LogInformation("Fetching order {OrderId}", id);
return await repo.FindAsync(id) ?? throw new NotFoundException(id);
}
}
// Collection expressions (C# 12)
int[] numbers = [1, 2, 3, 4, 5];
List<string> names = ["Alice", "Bob", "Charlie"];
ReadOnlySpan<byte> header = [0x48, 0x54, 0x54, 0x50];
// Pattern matching with list patterns (C# 11)
string Describe(int[] values) => values switch
{
[] => "empty",
[var single] => $"one item: {single}",
[var first, .., var last] => $"from {first} to {last}",
};
// Raw string literals (C# 11) — no escaping needed
var json = """
{
"name": "Widget",
"price": 29.99,
"tags": ["electronics", "sale"]
}
""";
// Required members (C# 11)
public class Config
{
public required string ConnectionString { get; init; }
public required int MaxRetries { get; init; }
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(30);
}
// Switch expressions with property patterns
decimal CalculateDiscount(Order order) => order switch
{
{ Total: > 1000, Customer.IsPremium: true } => order.Total * 0.15m,
{ Total: > 500 } => order.Total * 0.10m,
{ Customer.IsPremium: true } => order.Total * 0.05m,
_ => 0m,
};| Category | Go-To Packages | When to Use |
|---|---|---|
| Web Framework | ASP.NET Core (built-in) | REST APIs, Razor Pages, Blazor, gRPC |
| ORM | EF Core, Dapper | EF Core for full ORM, Dapper for raw SQL performance |
| Validation | FluentValidation, Validot | Fluent rule definitions, DI-friendly, auto-wire with ASP.NET |
| Mapping | Mapperly, AutoMapper | Mapperly for source-gen (zero reflection), AutoMapper for convention-based |
| Serialization | System.Text.Json, Protobuf-net | STJ for JSON (built-in), Protobuf for binary/gRPC |
| Logging | Serilog, NLog | Structured logging with sinks for Seq, Elastic, AppInsights |
| Testing | xUnit, Moq, AutoFixture, Testcontainers | xUnit as test framework, Moq for mocks, Testcontainers for integration |
| Resilience | Polly, Extensions.Resilience | Retry, circuit breaker, timeout, rate limiter policies |
| Messaging | MassTransit, MediatR, NServiceBus | MassTransit for bus abstraction, MediatR for in-process CQRS |
| DI | Extensions.DI (built-in) | Constructor injection, scoped/transient/singleton lifetimes |
| Caching | Extensions.Caching, StackExchange.Redis | IMemoryCache for local, IDistributedCache for Redis/SQL |
| HTTP Client | Refit, RestSharp | Refit for interface-defined clients, RestSharp for simpler REST calls |
| CLI | Spectre.Console, System.CommandLine | Rich terminal UIs, argument parsing, help generation |
| Cloud | .NET Aspire, Azure.Identity | Aspire for orchestration, Azure.Identity for managed identity auth |
<Nullable>enable</Nullable><PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>IOptions<T>public class SmtpOptions
{
public const string Section = "Smtp";
public required string Host { get; init; }
public int Port { get; init; } = 587;
public required string FromAddress { get; init; }
}
// In Program.cs
builder.Services.AddOptions<SmtpOptions>()
.BindConfiguration(SmtpOptions.Section)
.ValidateDataAnnotations()
.ValidateOnStart();record classrecord structprivate readonlyasync voidTaskValueTaskCancellationTokenapp.MapGet("/orders/{id}", async (Guid id, IOrderRepository repo, CancellationToken ct) =>
await repo.FindAsync(id, ct) is { } order
? Results.Ok(order)
: Results.NotFound());SingletonScopedTransient<ProjectReference>