Master 1Password: vaults, Watchtower, passkeys, SSH agent, CLI, and family/team administration. Use when getting full value from 1Password personally or administering it for others.
中文简介正在准备中。当前显示原文说明。
.NET guidance — ASP.NET Core APIs, Entity Framework Core, DI, configuration, testing, and container deployment.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
.NET (formerly .NET Core) is Microsoft's cross-platform runtime for C#, F#, and VB.NET, and ASP.NET Core is its high-performance web framework. The modern stack is opinionated in the right places: built-in dependency injection, strongly-typed configuration, Entity Framework Core for data access, and first-class container support. This skill covers building .NET services idiomatically — minimal APIs vs controllers, EF Core without N+1s, and production configuration.
app.MapGet(...)) suit small services and microservices with less ceremony; controllers suit large APIs needing filters, versioning, and conventions. Both run on the same pipeline — pick per service size, not per trend.Program.cs. Rules that matter: never inject a scoped service into a singleton (use IServiceScopeFactory), prefer constructor injection, and keep registration near composition root.appsettings.json → appsettings.{Environment}.json → environment variables → secret stores. Bind to strongly-typed options classes with validation (ValidateDataAnnotations); secrets never live in json files committed to git.dotnet ef migrations add). Query pitfalls mirror every ORM: N+1 via lazy loading (use .Include() / projections with .Select()), change tracking overhead on read-only queries (use .AsNoTracking()), and client-side evaluation surprises.app.Use... ordering matters: exception handling → HSTS/HTTPS → static files → routing → auth → endpoints. Write custom middleware for cross-cutting concerns (correlation IDs, request logging).ILogger<T> with structured templates (LogInformation("Order {OrderId} created", id)); OpenTelemetry packages for traces/metrics; health checks via AddHealthChecks() wired to your orchestrator.IHostedService/BackgroundService for background work inside the API process (queue consumers, schedulers); for heavy or critical workloads, prefer a separate worker process or external queue.ValidateDataAnnotations() + ValidateOnStart() fail fast on bad config at startup — much better than a null-reference at 3am.Results.Problem() / ProblemDetails for RFC-compliant error responses; consistent shape across the API via a global exception handler.System.Threading.Channels for in-process producer/consumer pipelines — the right primitive for background work without standing up external queue infrastructure.Scaffold. dotnet new webapi -n Shop (or web for minimal API); target the latest LTS; keep the SDK version pinned with global.json.
Structure. Controllers/endpoints thin → application services (business logic) → repositories or direct DbContext → DTOs/records at the boundary; entities never serialized directly.
app.MapPost("/orders", async (CreateOrderRequest req, IOrderService svc) => {
var order = await svc.PlaceOrderAsync(req);
return Results.Created($"/orders/{order.Id}", order);
});
Configure. Options pattern for settings; appsettings.Production.json for non-secret overrides; secrets via environment or Azure Key Vault / similar; validate required settings at startup so misconfiguration fails fast.
Data access. EF Core migrations in source control; .AsNoTracking() for reads; project to DTOs with .Select() instead of returning entities; index FK and filtered columns; use explicit transactions for multi-write operations.
await using var tx = await db.Database.BeginTransactionAsync();
// ... writes via db ...
await tx.CommitAsync();
Harden the API. Authentication (JWT bearer / OIDC), authorization policies (not just [Authorize] — check resource ownership), rate limiting middleware, input validation (FluentValidation or data annotations), and problem-details error responses.
Test. xUnit + WebApplicationFactory for integration tests against the real pipeline; unit-test services with mocked dependencies; Testcontainers for database-backed tests.
Add background work. BackgroundService for in-process workers; separate worker project for anything critical; ensure graceful shutdown via the host's lifetime events.
Ship. Multi-stage Dockerfile with the SDK image for build and the ASP.NET runtime image for run; DOTNET_ENVIRONMENT=Production; health check endpoints; readiness/liveness probes pointing at them.
builder.Services.AddOptions<ShopSettings>()
.BindConfiguration("Shop")
.ValidateDataAnnotations()
.ValidateOnStart();
builder.Services.AddHealthChecks()
.AddNpgSql(builder.Configuration.GetConnectionString("Default"));
DbContext injected into a singleton service; it silently shares one context across requests until it breaks..Include() or project with .Select()..AsNoTracking() by default for reads..Result / .Wait()) — deadlocks under load; async all the way.EnsureCreated() in production instead of migrations; schema drifts and data loss follow.DOTNET_GCHeapHardLimitPercent or container-aware defaults so the runtime respects cgroup limits.ValidateOnStart — bad config discovered at first request instead of at boot; validate eagerly.HttpClient without timeouts hanging threads; configure HttpClientFactory with Polly policies.IHttpClientFactory — new HttpClient() per request causes socket exhaustion; register typed or named clients once.CancellationToken — endpoints that can't be cancelled hold threads after clients disconnect; thread the token through to async calls.dynamic — kills compile-time safety and JIT performance; use records and DTOs instead.还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Master 1Password: vaults, Watchtower, passkeys, SSH agent, CLI, and family/team administration. Use when getting full value from 1Password personally or administering it for others.
中文简介正在准备中。当前显示原文说明。
Create 3D visuals with modeling, texturing, lighting, rendering, and optimization for web and product.
中文简介正在准备中。当前显示原文说明。
Create 3D web experiences: scene setup, models, materials, lighting, animation, scroll-driven scenes, and performance budgets. Use when adding 3D to websites beyond basic demos.
中文简介正在准备中。当前显示原文说明。
Writing abstracts that get papers read — structured content, the 5-sentence core, and journal-specific constraints.
中文简介正在准备中。当前显示原文说明。
Learn effectively from courses and academies: choosing programs, studying actively, and converting courses into skills. Use when investing time/money in structured learning.
中文简介正在准备中。当前显示原文说明。
Audit designs for accessibility with WCAG checklists covering color, type, focus, motion, and content.
中文简介正在准备中。当前显示原文说明。