β All skills
Csharp Developer
Use when building applications on .NET 8+ with ASP.NET Core, Entity Framework Core, minimal APIs, and async patterns.
About this skill
Use when building applications on .NET 8+ with ASP.NET Core, Entity Framework Core, minimal APIs, and async patterns.
SKILL.md
csharp-developer.SKILL.mdPlace it in your Syntic skills folder. For Syntic Code, install in your local skills directory, review the contents and run it in a controlled environment first.
---
name: Csharp Developer
description: Use when building applications on .NET 8+ with ASP.NET Core, Entity Framework Core, minimal APIs, and async patterns.
category: Languages
version: 1.0.0
tools: []
---
# C# and .NET 8+ Development
Build applications on .NET 8+ using ASP.NET Core, Entity Framework Core, and modern C# language features.
## Core Principles
- **Latest C# features:** Primary constructors, collection expressions, `required` properties, pattern matching, raw string literals.
- **Async all the way.** Every I/O operation uses `async/await`. Never call `.Result` or `.Wait()`.
- **Nullable reference types** enabled. Treat `CS8600` warnings as errors. Design APIs to eliminate null ambiguity.
- **Dependency injection** is the backbone. Register services in `Program.cs`, inject via constructor.
## ASP.NET Core Architecture
```
Api/
Program.cs # Service registration, middleware
Endpoints/ # Minimal API endpoint groups
Filters/ # Exception filters, validation
Application/
Services/ # Business logic
DTOs/ # Request/response records
Validators/ # FluentValidation validators
Domain/
Entities/ # Domain entities with behavior
ValueObjects/ # Immutable value objects
Infrastructure/
Data/ # DbContext, migrations
ExternalServices/ # HTTP clients, message brokers
```
## Minimal APIs
- Use minimal APIs for new projects. Map endpoints in extension methods grouped by feature.
- Use `TypedResults` for compile-time response type safety: `Results<Ok<User>, NotFound, ValidationProblem>`.
- Use endpoint filters for cross-cutting concerns: validation, logging, authorization.
- Use `[AsParameters]` to bind complex query parameters from a record type.
## Entity Framework Core
- Use `DbContext` with `DbSet<T>` for each aggregate root. Configure entities with `IEntityTypeConfiguration<T>`.
- Use migrations with `dotnet ef migrations add`. Review generated SQL before applying.
- Use `AsNoTracking()` for read-only queries to reduce overhead.
- Use `ExecuteUpdateAsync` and `ExecuteDeleteAsync` for bulk operations without loading entities.
- Use split queries (`AsSplitQuery()`) for multiple `Include()` calls to avoid cartesian explosion.
- Use compiled queries (`EF.CompileAsyncQuery`) for hot-path queries executed thousands of times.
## Async Patterns
- `Task` for async operations. `ValueTask` for methods that complete synchronously most of the time.
- `IAsyncEnumerable<T>` for streaming results from databases or APIs.
- `Channel<T>` for producer-consumer patterns. `SemaphoreSlim` for async rate limiting.
- `CancellationToken` on every async method. Pass through entire call chain.
- `Parallel.ForEachAsync` for concurrent processing with controlled parallelism.
## Configuration and DI
- **Options pattern:** `builder.Services.Configure<SmtpOptions>(builder.Configuration.GetSection("Smtp"))`.
- Register with appropriate lifetimes: `Scoped` (per-request), `Singleton` (stateless), `Transient` (lightweight).
- `IHttpClientFactory` with named or typed clients. Never instantiate `HttpClient` directly.
- **Keyed services** in .NET 8 for multiple implementations of same interface.
## Testing
- xUnit with `FluentAssertions` for readable assertions.
- `WebApplicationFactory<Program>` for integration tests (full ASP.NET pipeline).
- `Testcontainers` for database integration tests against PostgreSQL or SQL Server.
- NSubstitute or Moq for unit testing with mocked dependencies.
- `Bogus` for generating realistic test data.
Install
Syntic App
- 1Create a dedicated folder for this skill in your local skills library.
- 2Place SKILL.md into that folder.
- 3Restart Syntic and invoke this skill on matching tasks.
Syntic Code (CLI)
- 1Save SKILL.md in your local Syntic Code skills directory.
- 2Keep related files in the same skill folder.
- 3Run in a safe environment and validate outputs.