skillfed

Csharp Idioms

Learn idiomatic C# patterns that leverage type safety, LINQ expressiveness, and async-first design. This skill covers modern features like nullable reference types, records, and pattern matching, plus practical guidance on error handling, dependency injection, and testing with xUnit.

Csharp Idioms teaches modern C# best practices including nullable types, records, pattern matching, and async-first design for clean, type-safe code.

AI-generated summary based on this skill's SKILL.md

150 48 MIT updated by irahardianto

Install

irahardianto/awesome-agv/csharp-idioms · repository language: JavaScript

git clone https://github.com/irahardianto/awesome-agv
cp -r awesome-agv/.agents/skills/csharp-idioms ~/.claude/skills/csharp-idioms
npx skillfed install irahardianto/awesome-agv/csharp-idioms

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

What are modern C# 10 patterns and idioms I should know?

Csharp Idioms teaches contemporary C# patterns including nullable reference types for compile-time null safety, records for immutable data modeling, and pattern matching with switch expressions. These idioms emphasize type safety and expressiveness, helping you write cleaner, more maintainable code that leverages C#'s modern type system and functional features.

How should I set up C# nullable reference types?

Csharp Idioms covers nullable reference type setup as a foundational practice for type-safe code. Enabling this feature in your project file activates compile-time warnings for potential null reference issues, guiding you toward safer code patterns and reducing runtime null-reference exceptions through static analysis.

What C# async await guidelines does this skill cover?

Csharp Idioms provides comprehensive async/await patterns and cancellation token usage guidance. You'll learn async-first design principles, proper cancellation token propagation through async methods, and how to avoid blocking patterns like Result or Wait, ensuring responsive applications and correct resource cleanup.

How do Csharp Idioms address dependency injection and error handling?

Csharp Idioms teaches constructor injection patterns with DI containers and domain-driven error handling using the Result pattern. These principles help you build loosely coupled, testable code with explicit error handling that avoids exceptions for control flow, improving code clarity and maintainability.

What testing and code quality tools does Csharp Idioms recommend?

Csharp Idioms covers xUnit testing with FluentAssertions for expressive assertions, parameterized tests for comprehensive coverage, dotnet format for consistent code formatting, and Roslyn analyzers for static analysis. These tools enforce idioms and catch issues early in development.

How do LINQ, records, and pattern matching fit into idiomatic C#?

Csharp Idioms emphasizes LINQ best practices for data transformation, records for immutable domain models, and pattern matching with switch expressions for type-safe control flow. Together, these features enable functional, expressive code that reduces boilerplate and improves readability.

SKILL.md

rendered from the published skill — quoted content, verbatim

C# Idioms and Patterns

C# rewards type safety, LINQ expressiveness, and async-first design. Modern C# (10+/.NET 6+) favors records, nullable reference types, and minimal APIs. Idiomatic C# = clean, async-aware, framework-integrated.

> Scope: C# coding idioms. Test naming: .agents/rules/testing-strategy.md. Logging: @.agents/skills/logging-implementation/SKILL.md.

Modern C# Features (10+)

  1. Nullable reference types — always enabled: ```csharp // ✅ Explicit nullability public Task? FindById(string id) { ... } public Task GetById(string id) { ... } // never returns null — throws

// In .csproj: <Nullable>enable</Nullable> ```

  1. Records for immutable data: csharp public record CreateTaskRequest(string Title, Priority Priority); public record TaskResponse(string Id, string Title, DateTime CreatedAt);

  2. Pattern matching: csharp return result switch { Success(var task) =&gt; Ok(task), NotFound(var id) =&gt; NotFound($"Task {id} not found"), ValidationError(var errors) =&gt; BadRequest(errors), _ =&gt; StatusCode(500) };

  3. **required and init for

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
.agents/skills/csharp-idioms/SKILL.md

Related skills

Tags

type-safety-first async-aware-design immutable-data-structures null-safety-enforcement functional-patterns dependency-graph-management test-driven-idioms framework-integration code-quality-tooling modern-dotnet-ecosystem