Библиотека промптов

Промпты: .NET

Промпты для работы с C# и ASP.NET Core: ревью асинхронного кода, проектирование эндпоинтов и миграция на актуальные версии фреймворка.

Промпты написаны на английском — языке, на котором они составлены и проверены. Описания и инструкции на этих страницах переведены.

  • csharp
  • async
  • code review
100/100 · 161 токенов

Ревью async и await в C#

Проверяет код C# на блокирующие вызовы, отсутствие отмены и ненаблюдаемые задачи.

Используйте, когда: Ревью сервиса или контроллера перед выпуском, когда есть опасения насчёт исчерпания пула потоков или взаимоблокировок.

prompt
You are a senior .NET engineer reviewing asynchronous C# code.

## Task
Review the C# code below for incorrect use of async and await.

## Requirements
- Flag every call to .Result, .Wait(), or .GetAwaiter().GetResult() on a task.
- Flag every async method that accepts no CancellationToken but calls a method that takes one.
- Flag every async void method that is not an event handler.
- Report only issues you can point to in the code.
- Give the corrected line for every issue.

## Output format
Return a markdown table with the columns Line, Issue, Why it matters, and Corrected code. If there are no issues, return the single line "No async issues found."

## Input
<code>
{{code}}
</code>

Переменные

{{code}}
Файл C# или методы для ревью.

Пример ввода

code: an OrdersController with a Get action that calls _repo.GetAsync(id).Result.

Пример вывода

| Line | Issue | Why it matters | Corrected code |
|---|---|---|---|
| 18 | `.Result` on a task | Blocks a thread-pool thread and can deadlock | `var order = await _repo.GetAsync(id, ct);` |

Иллюстрация: написан, чтобы показать ожидаемую форму, а не создан моделью.

  • aspnet core
  • api
  • csharp
100/100 · 146 токенов

Эндпоинт minimal API в ASP.NET Core

Пишет эндпоинт minimal API с валидацией, типизированными результатами и указанными вами кодами статуса.

Используйте, когда: Добавление эндпоинта в сервис ASP.NET Core, когда нужна единообразная валидация и обработка ответов.

prompt
You are a senior .NET engineer writing ASP.NET Core minimal APIs.

## Task
Write one minimal API endpoint that implements the specification below.

## Requirements
- Use TypedResults for every response.
- Validate the request body and return 400 with a ValidationProblem for invalid input.
- Accept a CancellationToken and pass it to every awaited call.
- Use only the types and services named in the specification.
- Do not add authentication, logging, or packages the specification does not mention.

## Output format
Return one C# code block containing the endpoint mapping and its request and response records, followed by a bulleted list of the status codes it returns.

## Input
<specification>
{{specification}}
</specification>

Переменные

{{specification}}
Маршрут, метод, поля запроса и ответа, вызываемый сервис и коды статуса.

Пример ввода

specification: POST /orders, body { customerId: guid, items: [{ sku, quantity }] }, calls IOrderService.CreateAsync, returns 201 with the order id, 400 on invalid input.

Пример вывода

```csharp
app.MapPost("/orders", async Task<Results<Created<OrderCreated>, ValidationProblem>> (CreateOrder request, IOrderService orders, CancellationToken ct) => { ... });
```
- 201 Created with the order id
- 400 with validation errors

Иллюстрация: написан, чтобы показать ожидаемую форму, а не создан моделью.

Сделайте его своим

Измените требования под свои стандарты, затем проверьте результат. Анализатор промптов пересчитывает оценку по мере ввода, оптимизатор убирает лишние слова, не теряя ни одного требования, а сканер безопасности помечает секреты и персональные данные до отправки модели.

Другие категории