[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EGSS9GSWD77WCSPXD3N2QD":3,"skill-same:01M7EGSS9GSWD77WCSPXD3N2QD":79},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":35,"commitSha":36,"skillDirectory":37,"forksCount":38,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":6,"ownerDescription":41,"updatedAt":42,"install":43,"resources":56},"01M7EGSS9GSWD77WCSPXD3N2QD","csharp-dotnet",null,"Use when writing, reviewing, testing, or shipping C# \u002F .NET code — ASP.NET Core APIs (minimal APIs vs controllers), EF Core data access, async correctness, solution layout in .cs\u002F.csproj\u002F.sln. NOT a Java\u002FSpring backend (that is spring-boot), NOT a Node\u002FTypeScript backend (that is nestjs), NOT framework-neutral REST naming (that is api-design).","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fcsharp-dotnet\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: csharp-dotnet\ndescription: \"Use when writing, reviewing, testing, or shipping C# \u002F .NET code — ASP.NET Core APIs (minimal APIs vs controllers), EF Core data access, async correctness, solution layout in .cs\u002F.csproj\u002F.sln. NOT a Java\u002FSpring backend (that is spring-boot), NOT a Node\u002FTypeScript backend (that is nestjs), NOT framework-neutral REST naming (that is api-design).\"\ntags: [csharp, dotnet, aspnetcore, efcore, async]\nrecommends: [postgresdb, secure-coding, deployment]\norigin: risco\n---\n\n# Modern C# and .NET services\n\nYou write and review C#, ASP.NET Core APIs, and EF Core data access. You own the\n.NET idioms, the HTTP-contract patterns *as expressed in .NET*, async correctness,\nand the .NET-specific quality\u002Fsecurity gates. You delegate everything language-\nagnostic to the right sibling.\n\n**Target: .NET 10 (LTS, released 2025-11-11, supported 3 years) with C# 14, EF Core\n10, ASP.NET Core 10.** .NET 9 \u002F C# 13 is the immediate STS predecessor — still in\nsupport but shorter-lived. Features gate on the target framework moniker (TFM): a\n`net10.0` project gets C# 14 by default; a `net9.0` project caps at C# 13. When you\nuse a C# 14 feature (`field`, extension members, null-conditional assignment), say\nwhich TFM it requires.\n\n## When NOT to use — delegate\n\n| Situation | Route to |\n|---|---|\n| Java \u002F Spring Boot backend | `spring-boot` |\n| Node \u002F NestJS TypeScript backend | `nestjs` |\n| Language-agnostic threat modeling, OWASP authz\u002Fabuse review | `..\u002Fsecure-coding\u002FSKILL.md` |\n| Raw Postgres schema\u002Findex\u002Fquery tuning | `..\u002Fpostgresdb\u002FSKILL.md` |\n| Framework-neutral REST resource taxonomy | `api-design` |\n| Dockerfile \u002F CI pipeline \u002F deploy target | `..\u002Fdeployment\u002FSKILL.md` |\n| Recording per-project conventions in the workspace wiki | `..\u002Fharness\u002FSKILL.md` |\n\nThe .NET *expression* of an API contract and async correctness live HERE. Resource\nnaming theory lives in `api-design`; the JVM and Node counterparts are `spring-boot`\nand `nestjs`.\n\n## Project & solution layout + dotnet CLI\n\n```bash\ndotnet new sln -n Shop                         # solution\ndotnet new webapi -n Shop.Api                  # minimal API (default in .NET 10)\ndotnet new webapi -n Shop.Api --use-controllers # opt into MVC controllers instead\ndotnet new xunit -n Shop.Api.Tests             # test project\ndotnet sln add Shop.Api Shop.Api.Tests         # wire into the solution\ndotnet add Shop.Api package Npgsql.EntityFrameworkCore.PostgreSQL\ndotnet ef migrations add Initial -p Shop.Api   # create a migration\ndotnet ef database update -p Shop.Api          # apply migrations\ndotnet build -warnaserror                      # compile; analyzers + NRT as errors\ndotnet test                                    # run tests\ndotnet format                                  # apply style; --verify-no-changes in CI\ndotnet publish -c Release                       # produce deployable output\n```\n\nRecommended shape:\n\n```text\nShop.sln\nDirectory.Packages.props    # central package management: \u003CPackageVersion> here, no versions in csproj\nDirectory.Build.props       # shared \u003CNullable>enable\u003C\u002FNullable>, \u003CTreatWarningsAsErrors>, LangVersion\nsrc\u002FShop.Api\u002F               # endpoints grouped by feature module (Products\u002F, Orders\u002F)\nsrc\u002FShop.Domain\u002F            # entities, value objects (no EF\u002FASP.NET dependency)\ntests\u002FShop.Api.Tests\u002F\n```\n\nCentral package management: turn it on with `\u003CManagePackageVersionsCentrally>true\u003C\u002FManagePackageVersionsCentrally>`\nand list versions once in `Directory.Packages.props`. Why: one source of truth, no\nversion drift across projects.\n\nNRT on for every project — `\u003CNullable>enable\u003C\u002FNullable>` in `Directory.Build.props`.\nWhy: the compiler turns whole classes of `NullReferenceException` into build-time\nwarnings. Never disable it to silence a warning — fix the nullability.\n\n## Modern C# idioms (C# 14 \u002F .NET 10)\n\nDTO as a record, not a class:\n\n```csharp\n\u002F\u002F Bad: mutable class, no value equality, hand-written boilerplate\npublic class ProductDto { public int Id { get; set; } public string Name { get; set; } }\n\n\u002F\u002F Good: immutable record DTO\npublic record ProductDto(int Id, string Name, decimal Price);\n```\n\nWhy: value equality, `with` expressions, no boilerplate — and never reuse an EF entity\nas the wire DTO (see anti-patterns).\n\nPattern matching over if-chains:\n\n```csharp\n\u002F\u002F Bad\nif (shape is Circle) { var c = (Circle)shape; return Math.PI * c.R * c.R; }\n\n\u002F\u002F Good\nreturn shape switch\n{\n    Circle c      => Math.PI * c.R * c.R,\n    Rectangle r   => r.W * r.H,\n    _             => throw new ArgumentOutOfRangeException(nameof(shape)),\n};\n```\n\n`field` keyword — field-backed property without a hand-written backing field\n(**requires C# 14 \u002F net10.0**):\n\n```csharp\n\u002F\u002F Bad: explicit backing field just to trim a string\nprivate string _name = \"\";\npublic string Name { get => _name; set => _name = value.Trim(); }\n\n\u002F\u002F Good (C# 14)\npublic string Name { get; set => field = value.Trim(); }\n```\n\nPrimary constructors, `required`\u002F`init`, collection expressions:\n\n```csharp\npublic class OrderService(IOrderRepository repo, ILogger\u003COrderService> log)  \u002F\u002F primary ctor: DI in one line\n{\n    public required string Region { get; init; }                            \u002F\u002F must be set at construction, then immutable\n    private static readonly int[] DefaultTiers = [1, 2, 3];                  \u002F\u002F collection expression\n}\n```\n\nPrefer NRT annotations over defensive null checks: declare `string? note` when null is\nvalid and let the compiler force callers to handle it, instead of `if (x == null)`\nguards scattered everywhere.\n\nDispose deterministically: `using` \u002F `await using` (or `using` declarations) for\nanything `IDisposable`\u002F`IAsyncDisposable`. Why: leaked connections and handles.\n\n## async\u002Fawait correctness\n\nThis is the highest-leverage area to get right. Core rules in body; the full catalog\n(ConfigureAwait, ValueTask, IAsyncEnumerable, Channels, parallelism, deadlock cases)\nis in **references\u002Fasync.md** — read it before any non-trivial async review.\n\n- **No `async void`** except top-level event handlers. Why: exceptions escape onto the\n  thread pool and crash the process; the caller cannot `await` or catch it. Use `async Task`.\n- **Never `.Result` \u002F `.Wait()` \u002F `GetAwaiter().GetResult()` on the request path.** This\n  is the classic deadlock and the answer to \"my endpoint hangs under load\":\n\n```csharp\n\u002F\u002F Bad: blocks the thread on an async call -> thread-pool starvation \u002F deadlock under load\npublic IActionResult Get() => Ok(_svc.LoadAsync().Result);\n\n\u002F\u002F Good: await all the way up\npublic async Task\u003CIActionResult> Get(CancellationToken ct) => Ok(await _svc.LoadAsync(ct));\n```\n\n- **Flow `CancellationToken`** from the endpoint down into every async call —\n  `SaveChangesAsync`, queries, outbound HTTP. Why: a dropped token means the request\n  keeps running after the client gives up.\n- **`ValueTask` only for hot paths** that usually complete synchronously; default to\n  `Task`. Never `await` a `ValueTask` twice.\n- **`IAsyncEnumerable\u003CT>` for streaming** results instead of materializing a huge list.\n\n## ASP.NET Core APIs\n\nDecision: **minimal API** for new services; **controllers** only when you need MVC\nmachinery (model binding conventions, action filters at scale, views). Both can coexist.\nWhy minimal by default: less ceremony, first-class in .NET 10.\n\nProduction minimal API shape — route group + DataAnnotations validation (built in for\nminimal API parameters in .NET 10) + ProblemDetails + OpenAPI 3.1:\n\n```csharp\nvar builder = WebApplication.CreateBuilder(args);\nbuilder.Services.AddOpenApi();                 \u002F\u002F OpenAPI 3.1, JSON Schema 2020-12\nbuilder.Services.AddProblemDetails();          \u002F\u002F RFC 9457 error bodies\nbuilder.Services.AddDbContext\u003CShopDb>(o => o.UseNpgsql(builder.Configuration.GetConnectionString(\"Shop\")));\n\nvar app = builder.Build();\napp.MapOpenApi();                              \u002F\u002F serves the OpenAPI document\napp.UseExceptionHandler();                     \u002F\u002F emits ProblemDetails on unhandled errors\n\nvar products = app.MapGroup(\"\u002Fproducts\").WithTags(\"Products\");\nproducts.MapGet(\"\u002F{id:int}\", async (int id, ShopDb db, CancellationToken ct) =>\n    await db.Products.AsNoTracking()\n        .Where(p => p.Id == id)\n        .Select(p => new ProductDto(p.Id, p.Name, p.Price))   \u002F\u002F project to DTO, no entity leak\n        .FirstOrDefaultAsync(ct) is { } dto\n        ? Results.Ok(dto)\n        : Results.NotFound());\nproducts.MapPost(\"\u002F\", async (CreateProduct req, ShopDb db, CancellationToken ct) =>\n{   \u002F\u002F DataAnnotations on CreateProduct are validated automatically in .NET 10\n    var entity = new Product { Name = req.Name, Price = req.Price };\n    db.Products.Add(entity);\n    await db.SaveChangesAsync(ct);\n    return Results.Created($\"\u002Fproducts\u002F{entity.Id}\", new ProductDto(entity.Id, entity.Name, entity.Price));\n});\napp.Run();\n```\n\nDI lifetimes: `Singleton` (one for the app), `Scoped` (one per request — `DbContext`\nlives here; it is not thread-safe, so sharing one across requests corrupts change\ntracking), `Transient` (new each resolve). Never inject a `Scoped` service into a\n`Singleton` (captive dependency — see anti-patterns). Middleware ordering, endpoint\nfilters, the options pattern, and auth defaults are in **references\u002Faspnetcore.md**.\n\n## EF Core 10\n\n```csharp\n\u002F\u002F Bad: tracking + N+1 — loads orders, then one query per order's customer\nvar orders = await db.Orders.ToListAsync(ct);\nforeach (var o in orders) { var name = o.Customer.Name; \u002F* lazy\u002Fround-trip per row *\u002F }\n\n\u002F\u002F Good: no-tracking read + single query via projection\nvar rows = await db.Orders.AsNoTracking()\n    .Select(o => new OrderRow(o.Id, o.Customer.Name))   \u002F\u002F EF translates to one JOIN\n    .ToListAsync(ct);\n```\n\n- `AsNoTracking()` on every read-only query — skips change-tracking overhead.\n- Kill N+1 with projection (`Select`) or `Include`\u002F`ThenInclude`; use `AsSplitQuery()`\n  when an `Include` cartesian explosion hurts.\n- Migrations: `dotnet ef migrations add \u003CName>` then review the generated `Up`\u002F`Down`\n  before `database update`. Never hand-edit applied migrations.\n- EF Core 10 highlights: native `json` column type, `vector` type + `VECTOR_DISTANCE()`\n  for embeddings\u002FRAG, `LeftJoin`\u002F`RightJoin` LINQ operators, and named query filters\n  (multiple filters per entity, selectively disabled).\n\nRaw SQL only via parameterized `FromSql`\u002F`ExecuteSql` interpolated strings (EF\nparameterizes the holes). Query patterns, migration workflow, the EF Core 10 features,\nand raw-SQL safety in full are in **references\u002Fefcore.md**. Schema\u002Findex tuning is\n`..\u002Fpostgresdb\u002FSKILL.md`.\n\n## .NET security controls\n\nKeep only the .NET-specific controls here; threat modeling and OWASP review go to\n`..\u002Fsecure-coding\u002FSKILL.md`.\n\n- **Parameterized data access** — EF LINQ \u002F parameterized `FromSql` \u002F ADO.NET\n  `SqlParameter`. Never concatenate user input into SQL. Why: SQL injection.\n- **Secrets** — `dotnet user-secrets` in dev, Key Vault \u002F environment in prod. Never in\n  `appsettings.json` or source.\n- **Antiforgery** for cookie-auth browser POSTs; **Data Protection** for cookies\u002Ftokens\n  (configure a persisted key ring across instances).\n- **Auth defaults** — authenticate then authorize via middleware; prefer policy-based\n  authorization; ASP.NET Core 10 is secure-by-default but still verify HTTPS redirection\n  and HSTS in production.\n\n## Testing\n\n- **xUnit** is the default. Unit-test domain logic with no framework dependency.\n- **Integration tests** via `WebApplicationFactory\u003CProgram>` — boots the real pipeline\n  in-memory and lets you `HttpClient` your endpoints.\n- **Testcontainers** to run a real Postgres in a container for EF integration tests\n  instead of the in-memory provider (which lies about relational behavior).\n- Gate everything with `scripts\u002Fverify.sh` (format + build-warnaserror + test + vuln scan).\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n|---|---|---|\n| `async void` (non-event-handler) | Exceptions crash the process; uncatchable by caller | `async Task` |\n| `.Result` \u002F `.Wait()` on request path | Deadlock \u002F thread-pool starvation under load | `await` all the way |\n| Scoped service injected into a Singleton | Captive dependency: stale\u002F`DbContext` reused across requests | Inject `IServiceScopeFactory`, or make the consumer scoped |\n| Reusing an EF entity as the wire DTO | Over-posting, serialization cycles, leaked columns | Separate `record` DTO + mapping |\n| Tracking queries on read-only reads | Wasted memory\u002FCPU on change tracking | `AsNoTracking()` |\n| Lazy navigation in a loop | N+1 round-trips | Projection or `Include` |\n| Missing `CancellationToken` | Work continues after client disconnects | Flow the token to all I\u002FO |\n| `catch (Exception) { }` swallow | Hides failures; corrupt state continues | Handle specifically or let `UseExceptionHandler` map it |\n| `\u003CNullable>disable\u003C\u002FNullable>` to mute a warning | Re-opens the NRE class of bugs | Keep NRT on; fix the nullability |\n\n## Project grounding\n\nRecord per-project conventions (target TFM, package manager, lint rules, deploy\ntarget) in the workspace wiki via `..\u002Fharness\u002FSKILL.md`, not inline assumptions. Before\ncalling a C# change done, run `scripts\u002Fverify.sh` from the solution\u002Fproject root.\n","# Modern C# and .NET services\n\nYou write and review C#, ASP.NET Core APIs, and EF Core data access. You own the\n.NET idioms, the HTTP-contract patterns *as expressed in .NET*, async correctness,\nand the .NET-specific quality\u002Fsecurity gates. You delegate everything language-\nagnostic to the right sibling.\n\n**Target: .NET 10 (LTS, released 2025-11-11, supported 3 years) with C# 14, EF Core\n10, ASP.NET Core 10.** .NET 9 \u002F C# 13 is the immediate STS predecessor — still in\nsupport but shorter-lived. Features gate on the target framework moniker (TFM): a\n`net10.0` project gets C# 14 by default; a `net9.0` project caps at C# 13. When you\nuse a C# 14 feature (`field`, extension members, null-conditional assignment), say\nwhich TFM it requires.\n\n## When NOT to use — delegate\n\n| Situation | Route to |\n|---|---|\n| Java \u002F Spring Boot backend | `spring-boot` |\n| Node \u002F NestJS TypeScript backend | `nestjs` |\n| Language-agnostic threat modeling, OWASP authz\u002Fabuse review | `..\u002Fsecure-coding\u002FSKILL.md` |\n| Raw Postgres schema\u002Findex\u002Fquery tuning | `..\u002Fpostgresdb\u002FSKILL.md` |\n| Framework-neutral REST resource taxonomy | `api-design` |\n| Dockerfile \u002F CI pipeline \u002F deploy target | `..\u002Fdeployment\u002FSKILL.md` |\n| Recording per-project conventions in the workspace wiki | `..\u002Fharness\u002FSKILL.md` |\n\nThe .NET *expression* of an API contract and async correctness live HERE. Resource\nnaming theory lives in `api-design`; the JVM and Node counterparts are `spring-boot`\nand `nestjs`.\n\n## Project & solution layout + dotnet CLI\n\n```bash\ndotnet new sln -n Shop                         # solution\ndotnet new webapi -n Shop.Api                  # minimal API (default in .NET 10)\ndotnet new webapi -n Shop.Api --use-controllers # opt into MVC controllers instead\ndotnet new xunit -n Shop.Api.Tests             # test project\ndotnet sln add Shop.Api Shop.Api.Tests         # wire into the solution\ndotnet add Shop.Api package Npgsql.EntityFrameworkCore.PostgreSQL\ndotnet ef migrations add Initial -p Shop.Api   # create a migration\ndotnet ef database update -p Shop.Api          # apply migrations\ndotnet build -warnaserror                      # compile; analyzers + NRT as errors\ndotnet test                                    # run tests\ndotnet format                                  # apply style; --verify-no-changes in CI\ndotnet publish -c Release                       # produce deployable output\n```\n\nRecommended shape:\n\n```text\nShop.sln\nDirectory.Packages.props    # central package management: \u003CPackageVersion> here, no versions in csproj\nDirectory.Build.props       # shared \u003CNullable>enable\u003C\u002FNullable>, \u003CTreatWarningsAsErrors>, LangVersion\nsrc\u002FShop.Api\u002F               # endpoints grouped by feature module (Products\u002F, Orders\u002F)\nsrc\u002FShop.Domain\u002F            # entities, value objects (no EF\u002FASP.NET dependency)\ntests\u002FShop.Api.Tests\u002F\n```\n\nCentral package management: turn it on with `\u003CManagePackageVersionsCentrally>true\u003C\u002FManagePackageVersionsCentrally>`\nand list versions once in `Directory.Packages.props`. Why: one source of truth, no\nversion drift across projects.\n\nNRT on for every project — `\u003CNullable>enable\u003C\u002FNullable>` in `Directory.Build.props`.\nWhy: the compiler turns whole classes of `NullReferenceException` into build-time\nwarnings. Never disable it to silence a warning — fix the nullability.\n\n## Modern C# idioms (C# 14 \u002F .NET 10)\n\nDTO as a record, not a class:\n\n```csharp\n\u002F\u002F Bad: mutable class, no value equality, hand-written boilerplate\npublic class ProductDto { public int Id { get; set; } public string Name { get; set; } }\n\n\u002F\u002F Good: immutable record DTO\npublic record ProductDto(int Id, string Name, decimal Price);\n```\n\nWhy: value equality, `with` expressions, no boilerplate — and never reuse an EF entity\nas the wire DTO (see anti-patterns).\n\nPattern matching over if-chains:\n\n```csharp\n\u002F\u002F Bad\nif (shape is Circle) { var c = (Circle)shape; return Math.PI * c.R * c.R; }\n\n\u002F\u002F Good\nreturn shape switch\n{\n    Circle c      => Math.PI * c.R * c.R,\n    Rectangle r   => r.W * r.H,\n    _             => throw new ArgumentOutOfRangeException(nameof(shape)),\n};\n```\n\n`field` keyword — field-backed property without a hand-written backing field\n(**requires C# 14 \u002F net10.0**):\n\n```csharp\n\u002F\u002F Bad: explicit backing field just to trim a string\nprivate string _name = \"\";\npublic string Name { get => _name; set => _name = value.Trim(); }\n\n\u002F\u002F Good (C# 14)\npublic string Name { get; set => field = value.Trim(); }\n```\n\nPrimary constructors, `required`\u002F`init`, collection expressions:\n\n```csharp\npublic class OrderService(IOrderRepository repo, ILogger\u003COrderService> log)  \u002F\u002F primary ctor: DI in one line\n{\n    public required string Region { get; init; }                            \u002F\u002F must be set at construction, then immutable\n    private static readonly int[] DefaultTiers = [1, 2, 3];                  \u002F\u002F collection expression\n}\n```\n\nPrefer NRT annotations over defensive null checks: declare `string? note` when null is\nvalid and let the compiler force callers to handle it, instead of `if (x == null)`\nguards scattered everywhere.\n\nDispose deterministically: `using` \u002F `await using` (or `using` declarations) for\nanything `IDisposable`\u002F`IAsyncDisposable`. Why: leaked connections and handles.\n\n## async\u002Fawait correctness\n\nThis is the highest-leverage area to get right. Core rules in body; the full catalog\n(ConfigureAwait, ValueTask, IAsyncEnumerable, Channels, parallelism, deadlock cases)\nis in **references\u002Fasync.md** — read it before any non-trivial async review.\n\n- **No `async void`** except top-level event handlers. Why: exceptions escape onto the\n  thread pool and crash the process; the caller cannot `await` or catch it. Use `async Task`.\n- **Never `.Result` \u002F `.Wait()` \u002F `GetAwaiter().GetResult()` on the request path.** This\n  is the classic deadlock and the answer to \"my endpoint hangs under load\":\n\n```csharp\n\u002F\u002F Bad: blocks the thread on an async call -> thread-pool starvation \u002F deadlock under load\npublic IActionResult Get() => Ok(_svc.LoadAsync().Result);\n\n\u002F\u002F Good: await all the way up\npublic async Task\u003CIActionResult> Get(CancellationToken ct) => Ok(await _svc.LoadAsync(ct));\n```\n\n- **Flow `CancellationToken`** from the endpoint down into every async call —\n  `SaveChangesAsync`, queries, outbound HTTP. Why: a dropped token means the request\n  keeps running after the client gives up.\n- **`ValueTask` only for hot paths** that usually complete synchronously; default to\n  `Task`. Never `await` a `ValueTask` twice.\n- **`IAsyncEnumerable\u003CT>` for streaming** results instead of materializing a huge list.\n\n## ASP.NET Core APIs\n\nDecision: **minimal API** for new services; **controllers** only when you need MVC\nmachinery (model binding conventions, action filters at scale, views). Both can coexist.\nWhy minimal by default: less ceremony, first-class in .NET 10.\n\nProduction minimal API shape — route group + DataAnnotations validation (built in for\nminimal API parameters in .NET 10) + ProblemDetails + OpenAPI 3.1:\n\n```csharp\nvar builder = WebApplication.CreateBuilder(args);\nbuilder.Services.AddOpenApi();                 \u002F\u002F OpenAPI 3.1, JSON Schema 2020-12\nbuilder.Services.AddProblemDetails();          \u002F\u002F RFC 9457 error bodies\nbuilder.Services.AddDbContext\u003CShopDb>(o => o.UseNpgsql(builder.Configuration.GetConnectionString(\"Shop\")));\n\nvar app = builder.Build();\napp.MapOpenApi();                              \u002F\u002F serves the OpenAPI document\napp.UseExceptionHandler();                     \u002F\u002F emits ProblemDetails on unhandled errors\n\nvar products = app.MapGroup(\"\u002Fproducts\").WithTags(\"Products\");\nproducts.MapGet(\"\u002F{id:int}\", async (int id, ShopDb db, CancellationToken ct) =>\n    await db.Products.AsNoTracking()\n        .Where(p => p.Id == id)\n        .Select(p => new ProductDto(p.Id, p.Name, p.Price))   \u002F\u002F project to DTO, no entity leak\n        .FirstOrDefaultAsync(ct) is { } dto\n        ? Results.Ok(dto)\n        : Results.NotFound());\nproducts.MapPost(\"\u002F\", async (CreateProduct req, ShopDb db, CancellationToken ct) =>\n{   \u002F\u002F DataAnnotations on CreateProduct are validated automatically in .NET 10\n    var entity = new Product { Name = req.Name, Price = req.Price };\n    db.Products.Add(entity);\n    await db.SaveChangesAsync(ct);\n    return Results.Created($\"\u002Fproducts\u002F{entity.Id}\", new ProductDto(entity.Id, entity.Name, entity.Price));\n});\napp.Run();\n```\n\nDI lifetimes: `Singleton` (one for the app), `Scoped` (one per request — `DbContext`\nlives here; it is not thread-safe, so sharing one across requests corrupts change\ntracking), `Transient` (new each resolve). Never inject a `Scoped` service into a\n`Singleton` (captive dependency — see anti-patterns). Middleware ordering, endpoint\nfilters, the options pattern, and auth defaults are in **references\u002Faspnetcore.md**.\n\n## EF Core 10\n\n```csharp\n\u002F\u002F Bad: tracking + N+1 — loads orders, then one query per order's customer\nvar orders = await db.Orders.ToListAsync(ct);\nforeach (var o in orders) { var name = o.Customer.Name; \u002F* lazy\u002Fround-trip per row *\u002F }\n\n\u002F\u002F Good: no-tracking read + single query via projection\nvar rows = await db.Orders.AsNoTracking()\n    .Select(o => new OrderRow(o.Id, o.Customer.Name))   \u002F\u002F EF translates to one JOIN\n    .ToListAsync(ct);\n```\n\n- `AsNoTracking()` on every read-only query — skips change-tracking overhead.\n- Kill N+1 with projection (`Select`) or `Include`\u002F`ThenInclude`; use `AsSplitQuery()`\n  when an `Include` cartesian explosion hurts.\n- Migrations: `dotnet ef migrations add \u003CName>` then review the generated `Up`\u002F`Down`\n  before `database update`. Never hand-edit applied migrations.\n- EF Core 10 highlights: native `json` column type, `vector` type + `VECTOR_DISTANCE()`\n  for embeddings\u002FRAG, `LeftJoin`\u002F`RightJoin` LINQ operators, and named query filters\n  (multiple filters per entity, selectively disabled).\n\nRaw SQL only via parameterized `FromSql`\u002F`ExecuteSql` interpolated strings (EF\nparameterizes the holes). Query patterns, migration workflow, the EF Core 10 features,\nand raw-SQL safety in full are in **references\u002Fefcore.md**. Schema\u002Findex tuning is\n`..\u002Fpostgresdb\u002FSKILL.md`.\n\n## .NET security controls\n\nKeep only the .NET-specific controls here; threat modeling and OWASP review go to\n`..\u002Fsecure-coding\u002FSKILL.md`.\n\n- **Parameterized data access** — EF LINQ \u002F parameterized `FromSql` \u002F ADO.NET\n  `SqlParameter`. Never concatenate user input into SQL. Why: SQL injection.\n- **Secrets** — `dotnet user-secrets` in dev, Key Vault \u002F environment in prod. Never in\n  `appsettings.json` or source.\n- **Antiforgery** for cookie-auth browser POSTs; **Data Protection** for cookies\u002Ftokens\n  (configure a persisted key ring across instances).\n- **Auth defaults** — authenticate then authorize via middleware; prefer policy-based\n  authorization; ASP.NET Core 10 is secure-by-default but still verify HTTPS redirection\n  and HSTS in production.\n\n## Testing\n\n- **xUnit** is the default. Unit-test domain logic with no framework dependency.\n- **Integration tests** via `WebApplicationFactory\u003CProgram>` — boots the real pipeline\n  in-memory and lets you `HttpClient` your endpoints.\n- **Testcontainers** to run a real Postgres in a container for EF integration tests\n  instead of the in-memory provider (which lies about relational behavior).\n- Gate everything with `scripts\u002Fverify.sh` (format + build-warnaserror + test + vuln scan).\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n|---|---|---|\n| `async void` (non-event-handler) | Exceptions crash the process; uncatchable by caller | `async Task` |\n| `.Result` \u002F `.Wait()` on request path | Deadlock \u002F thread-pool starvation under load | `await` all the way |\n| Scoped service injected into a Singleton | Captive dependency: stale\u002F`DbContext` reused across requests | Inject `IServiceScopeFactory`, or make the consumer scoped |\n| Reusing an EF entity as the wire DTO | Over-posting, serialization cycles, leaked columns | Separate `record` DTO + mapping |\n| Tracking queries on read-only reads | Wasted memory\u002FCPU on change tracking | `AsNoTracking()` |\n| Lazy navigation in a loop | N+1 round-trips | Projection or `Include` |\n| Missing `CancellationToken` | Work continues after client disconnects | Flow the token to all I\u002FO |\n| `catch (Exception) { }` swallow | Hides failures; corrupt state continues | Handle specifically or let `UseExceptionHandler` map it |\n| `\u003CNullable>disable\u003C\u002FNullable>` to mute a warning | Re-opens the NRE class of bugs | Keep NRT on; fix the nullability |\n\n## Project grounding\n\nRecord per-project conventions (target TFM, package manager, lint rules, deploy\ntarget) in the workspace wiki via `..\u002Fharness\u002FSKILL.md`, not inline assumptions. Before\ncalling a C# change done, run `scripts\u002Fverify.sh` from the solution\u002Fproject root.\n",{"name":5,"tags":24,"origin":30,"recommends":31,"description":7},[25,26,27,28,29],"csharp","dotnet","aspnetcore","efcore","async","risco",[32,33,34],"postgresdb","secure-coding","deployment","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Fcsharp-dotnet",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":44,"prompt":54,"zipAvailable":55},[45,48,51],{"tool":46,"command":47},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill csharp-dotnet",{"tool":49,"command":50},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill csharp-dotnet",{"tool":52,"command":53},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill csharp-dotnet","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fcsharp-dotnet\u002FSKILL.md",true,[57,63,67,71,75],{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"evals\u002Fcases.yaml","REFERENCE","参考文档",3271,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fcsharp-dotnet\u002Fevals\u002Fcases.yaml",{"path":64,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":65,"sourceHtmlUrl":66},"evals\u002FREADME.md",815,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fcsharp-dotnet\u002Fevals\u002FREADME.md",{"path":68,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":69,"sourceHtmlUrl":70},"references\u002Faspnetcore.md",4621,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fcsharp-dotnet\u002Freferences\u002Faspnetcore.md",{"path":72,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Fasync.md",3534,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fcsharp-dotnet\u002Freferences\u002Fasync.md",{"path":76,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Fefcore.md",3965,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fcsharp-dotnet\u002Freferences\u002Fefcore.md",[80,88,93,100,107,114],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":87},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":89,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":87},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":87},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":87},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":87},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":87},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]