receiving-code-review
OBobra/superpowers298k2,631 new stars in the last 7 days
Perform structured code reviews of C# source code covering naming conventions, performance, security, readability, and .NET best practices. Trigger phrases include "review this C# code", "check my C# for best practices", "analyze this C# class", "find issues in my C# code".
Perform a structured code review of C# source code. Identify issues related to naming conventions, performance, security, readability, and .NET best practices. Produce a prioritized report with actionable suggestions.
Before reviewing, determine:
all (default) — full review across all categoriesnaming — naming conventions onlyperformance — performance and memory onlysecurity — security vulnerabilities onlyreadability — clarity, structure, and maintainability only<TargetFramework> in .csproj if accessible.all (default), warnings-and-above, or critical-only.If context is missing: Default to all focus, .NET 8, and all severities. Don't block the review to ask — just state your assumptions at the top of the report. Only ask if you genuinely have no code to review.
# Code Review: {FileName or ClassName}
> Target: .NET {version} | Focus: {focus} | Reviewed: {date}
## Summary
{One-paragraph overview. Lead with the most important finding. State the total issue count by severity.}
## Issues
| # | Severity | Location | Issue | Why It Matters | Suggestion |
|---|----------|----------|-------|----------------|------------|
| 1 | Critical | `Class.Method:L12` | {issue} | {impact} | {fix} |
| 2 | Warning | `Class.Property` | {issue} | {impact} | {fix} |
| 3 | Info | `Class.Method:L25` | {issue} | {impact} | {fix} |
## What's Done Well
- {Positive pattern — be specific, not generic}
## Recommendations
1. **[Critical]** {Highest-impact change}
2. **[Warning]** {Next priority}
3. ...
Severity levels:
using directivesnew used where DI should be?sealed on classes not designed for inheritanceVerify against C# Coding Conventions:
| Element | Convention | Example |
|---|---|---|
| Classes, records, structs | PascalCase | UserManager |
| Interfaces | I + PascalCase | IUserRepository |
| Methods | PascalCase | GetUserById |
| Properties | PascalCase | FirstName |
| Public constants/statics | PascalCase | MaxRetryCount |
| Private fields | _camelCase | _userCount |
| Local variables, parameters | camelCase | userId |
| Enum types and values | PascalCase | OrderStatus.Pending |
| Type parameters | T + PascalCase | TEntity, TKey |
| Async methods | PascalCase + Async suffix | GetUserAsync |
| Booleans | Is/Has/Can/Should prefix | IsActive, HasPermission |
| Event handlers | PascalCase + EventArgs | OnUserCreated |
Check for:
StringBuilder or string.JoinToList(), new in hot pathsasync void → should be async Task (except event handlers)Task.Result or Task.Wait() → deadlock risk, use await insteadConfigureAwait(false) in library codeTask.Run(() => AsyncMethod().Result))IEnumerable multiple enumeration → materialize with ToList() or use IReadOnlyListCount() > 0 → Any(), .Count() on ICollection → .CountIDisposable / using / await using for disposable resourcesTask.Run on already-async codestruct types being copied repeatedly (consider ref or class)Check for:
BinaryFormatter, TypeNameHandling.All in JSON → use safe serializersHttpClient misuse — creating new instances per request → use IHttpClientFactoryCheck for:
is, switch expressions)var usage consistencyrequired properties (.NET 7+)Do:
.NET 8 features for a .NET 6 projectDon't:
Input:
public class userManager
{
string connStr = "Server=prod;Password=admin123";
public void deleteUser(int id)
{
var sql = "DELETE FROM Users WHERE Id = " + id;
// execute sql
}
public List<string> GetNames(List<User> users)
{
List<string> result = new List<string>();
for (int i = 0; i < users.Count; i++)
{
result.Add(users[i].FirstName + " " + users[i].LastName);
}
return result;
}
}
Output:
Target: .NET 8 (assumed) | Focus: all | Reviewed: 2026-02-18
This class has 2 critical security issues that need immediate attention: hardcoded credentials and a SQL injection vulnerability. There are also naming convention violations and missed opportunities for modern C# patterns. 6 issues total (2 Critical, 3 Warning, 1 Info).
| # | Severity | Location | Issue | Why It Matters | Suggestion |
|---|---|---|---|---|---|
| 1 | Critical | userManager.connStr | Hardcoded connection string with plaintext password | Credentials in source code end up in version control and are trivially extractable | Move to appsettings.json + secrets management (e.g., Azure Key Vault, User Secrets for dev) |
| 2 | Critical | userManager.deleteUser:L6 | SQL injection via string concatenation | Attacker-controlled input can execute arbitrary SQL | Use parameterized queries or an ORM (e.g., Entity Framework, Dapper with parameters) |
| 3 | Warning | Class declaration | userManager violates PascalCase convention | Inconsistent naming makes the codebase harder to navigate | Rename to UserManager |
| 4 | Warning | deleteUser method | Method name violates PascalCase convention | Same as above | Rename to DeleteUser |
| 5 | Warning | connStr field | Private field missing _ prefix and access modifier | Implicit private is less readable; missing prefix breaks convention | Rename to _connectionString with explicit private |
| 6 | Info | GetNames method | Manual loop with string concatenation where LINQ would be clearer | LINQ expresses intent more directly and reduces boilerplate | users.Select(u => $"{u.FirstName} {u.LastName}").ToList() |
GetNames returns a clearly typed List<string> — good use of explicit return typesdeleteUser, GetNames)GetNames with LINQ and string interpolationBefore finalizing the report, verify:
OBobra/superpowers298k2,631 new stars in the last 7 days
OBobra/superpowers298k2,631 new stars in the last 7 days
OBobra/superpowers298k2,631 new stars in the last 7 days
MAmattpocock/skills288k10,178 new stars in the last 7 days
MAmattpocock/skills288k10,178 new stars in the last 7 days
MAmattpocock/skills288k10,178 new stars in the last 7 days