Skip to content
Back to skills

Csharp Antipatterns

ASecurity

Forbidden C# patterns — SQL injection, BinaryFormatter, weak random, async void, exception swallowing. Applies when editing C# files.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 21, 2026
ai-agentsc#sql

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned October 21, 2026

npx -y skills add emgiezet/aisdlc --skill csharp-antipatterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Csharp Antipatterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Csharp Antipatterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/emgiezet-csharp-antipatterns/badge)](https://www.skillsdirectory.com/skills/emgiezet-csharp-antipatterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: csharp-antipatterns
description: Forbidden C# patterns — SQL injection, BinaryFormatter, weak random, async void, exception swallowing. Applies when editing C# files.
paths: ["**/*.cs"]
user-invocable: false
---

# C# anti-patterns — do not write these

Checks run automatically after each edit. Findings reference the IDs below.

## Blockers
- AP-CS-SEC-001 — Use `SqlCommand` parameters or EF parameterized queries; never interpolate into `CommandText`.
- AP-CS-SEC-002 — Replace `BinaryFormatter`/`NetDataContractSerializer` with `System.Text.Json` or MessagePack.
- AP-CS-SEC-003 — Set `ProcessStartInfo.Arguments` separately; never embed user input in the FileName.
- AP-CS-SEC-004 — Use `RandomNumberGenerator.GetBytes` for tokens; `System.Random` is for simulations only.

## Errors
- AP-CS-PERF-001 — Use `async Task` (not `async void`) for all async methods except event handlers.
- AP-CS-MAINT-001 — Catch the specific exception type; log and rethrow; never swallow `Exception` silently.

## Warnings
- AP-CS-SEC-005 — Add `NWebsec` or a custom middleware to set CSP, X-Frame-Options, and HSTS.
- AP-CS-MAINT-002 — Use `StringBuilder` or `string.Join` to concatenate strings in loops.

Details for any ID: `reference/<ID>.md`

Files in this skill

  • SKILL.md1.2 KB
  • reference/AP-CS-MAINT-001.md670 B
  • reference/AP-CS-MAINT-002.md629 B
  • reference/AP-CS-PERF-001.md527 B
  • reference/AP-CS-SEC-001.md762 B
  • reference/AP-CS-SEC-002.md801 B
  • reference/AP-CS-SEC-003.md770 B
  • reference/AP-CS-SEC-004.md653 B
  • reference/AP-CS-SEC-005.md647 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.