1---2name: dotnet-code-review3description: Review .NET changes for bugs, regressions, architectural drift, missing tests, incorrect async or disposal behavior, and platform-specific pitfalls before you approve or merge them.4---56# .NET Code Review78## Trigger On910- reviewing a pull request or patch in a .NET repository11- checking for behavioral regressions, API misuse, or missing tests12- auditing architectural or framework-specific correctness1314## References1516- [checklist.md](references/checklist.md) - comprehensive code review checklist organized by risk priority17- [patterns.md](references/patterns.md) - common patterns and anti-patterns for async, disposal, and security1819## Workflow20211. Prioritize correctness, data loss, concurrency, security, lifecycle, and platform-compatibility issues before style concerns. Use the [checklist](references/checklist.md) P0-P2 categories first.222. Check async flows, cancellation propagation, exception handling, disposal, and transient versus singleton lifetime mistakes. Refer to [patterns.md](references/patterns.md) for common pitfalls.233. Verify tests cover the changed behavior, not only the happy path or refactored implementation details.244. Inspect framework-specific boundaries such as EF query translation, ASP.NET middleware order, Blazor render state, or MAUI UI-thread access.255. Call out missing observability, migration risk, or runtime configuration drift when those are part of the change.266. Keep findings concrete, reproducible, and tied to specific files or behavior.2728## Key Review Patterns2930### Async Code31- Async must propagate through the entire call chain; never use `.Result`, `.Wait()`, or `.GetAwaiter().GetResult()` in async contexts32- Always propagate `CancellationToken` parameters33- Use `ConfigureAwait(false)` in library code34- Never use `async void` except for event handlers3536### Resource Disposal37- Use `using` declarations or statements for all `IDisposable` resources38- Use `await using` for `IAsyncDisposable` resources39- Use `IHttpClientFactory` instead of creating `HttpClient` directly40- Unsubscribe event handlers to prevent memory leaks41- Validate DI service lifetimes to prevent captured dependencies4243### Security44- Use parameterized queries or EF to prevent SQL injection45- Validate all user input at system boundaries46- Prevent path traversal by validating resolved paths stay within allowed directories47- Never hardcode secrets; use configuration and secret management48- Enforce authorization checks before accessing protected resources4950## Deliver5152- ranked review findings with file references53- clear residual risks and test gaps54- brief summary of what changed only after findings5556## Validate5758- findings describe user-visible or maintainability-impacting risk59- assumptions are stated when repo context is incomplete60- no trivial style nit hides a more serious issue