AgentStack
SKILL verified MIT Self-run

C# Language Patterns

skill-ngxtm-devkit-language · by ngxtm

Modern C# standards for type safety, performance, and maintainability.

No reviews yet
0 installs
13 views
0.0% view→install

Install

$ agentstack add skill-ngxtm-devkit-language

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of C# Language Patterns? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

C# Language Patterns

Priority: P0 (CRITICAL)

Modern C# standards for type-safe, performant, maintainable code.

Implementation Guidelines

  • Nullable Reference Types: Enable enable. Use ? for nullable, avoid ! except when compiler can't infer.
  • Records: record for immutable DTOs, record struct for stack-allocated value types.
  • Pattern Matching: is patterns, switch expressions, property/positional patterns.
  • Async/Await: Always use CancellationToken. ValueTask for hot paths. ConfigureAwait(false) in libraries.
  • LINQ: Prefer method syntax. Avoid multiple enumerations (ToList() once). Use AsNoTracking() for read-only EF queries.
  • Generics: Constraints (where T : class, new()), covariance (out T), contravariance (in T).
  • Spans: Span, ReadOnlySpan for zero-allocation slicing.
  • Primary Constructors: C# 12+ class Foo(int x) for concise DI.
  • Collection Expressions: C# 12+ [1, 2, 3] syntax.
  • Raw String Literals: """multi-line""" for SQL, JSON templates.

Anti-Patterns

  • No async void: Use async Task. Exception: event handlers.
  • No Task.Result/.Wait(): Deadlock risk. Always await.
  • No DateTime.Now: Use DateTimeOffset.UtcNow for timezone safety.
  • No string concat in loops: Use StringBuilder or string.Join.
  • No ! abuse: Prefer null checks or ?? over null-forgiving.

Code

// Record with primary constructor
public record UserDto(string Name, string Email);

// Pattern matching with switch expression
string GetStatus(Order order) => order switch
{
    { Status: OrderStatus.Pending } => "Waiting",
    { Status: OrderStatus.Shipped, TrackingNumber: not null } => "In Transit",
    { IsCancelled: true } => "Cancelled",
    _ => "Unknown"
};

// Async with cancellation token
async Task GetUserAsync(int id, CancellationToken ct = default)
{
    return await _db.Users
        .AsNoTracking()
        .FirstOrDefaultAsync(u => u.Id == id, ct);
}

// Span for zero-allocation parsing
ReadOnlySpan GetFirstWord(ReadOnlySpan text)
{
    int idx = text.IndexOf(' ');
    return idx  logger)
{
    public async Task GetAsync(int id) => await repo.GetByIdAsync(id);
}

Reference & Examples

For advanced patterns, spans, and nullable annotations: See [references/REFERENCE.md](references/REFERENCE.md).

Related Topics

best-practices | security | tooling

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.