csharp-pro

Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.

Author

Install

Hot:27

Download and extract to your skills directory

Copy command and send to OpenClaw for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=sickn33-skills-csharp-pro&locale=en&source=copy

C# Pro - Modern C# Development Expert Assistant

Skills Overview

C# Pro is an AI assistant focused on modern C# and .NET development, helping developers write high-quality C# code, optimize application performance, and implement enterprise-grade architecture patterns.

Applicable Scenarios

1. C# Code Refactoring and Modernization

When you need to upgrade legacy C# code to modern language features, C# Pro can proactively identify improvement opportunities. For example, converting traditional classes to records, using pattern matching instead of long if-else chains, or introducing nullable reference types to improve code safety.

2. .NET Application Performance Optimization

When facing performance bottlenecks, C# Pro provides professional optimization strategies, including using Span and Memory to reduce memory allocations, choosing appropriate value types, and applying correct async/await patterns to avoid thread-pool starvation.

3. Enterprise Application Architecture Design

When building complex .NET systems, C# Pro assists with implementing SOLID principles, microservice architectures, and domain-driven design. It also provides comprehensive unit testing strategies using xUnit, NUnit, and FluentAssertions to ensure code quality.

Core Features

Application of Modern C# Language Features

Make full use of C# 9+ features to write concise code. Use records to define immutable data structures, simplify conditional logic with pattern matching, and enable nullable reference types to catch null-reference errors at compile time.

Performance and Concurrent Programming

Provide guidance on asynchronous programming based on the TPL (Task Parallel Library), avoiding common async/await pitfalls. Use BenchmarkDotNet for performance benchmarking to identify hotspots and optimize accordingly.

Comprehensive Testing and Code Quality

Build a complete testing system, including unit tests, integration tests, and mock object management. Configure EditorConfig and static analysis tools to maintain consistent coding style and quality standards.

Frequently Asked Questions

What is the difference between C# records and classes?

Records are a reference type introduced in C# 9, designed specifically for immutable data models. They automatically provide value-based equality comparison, concise syntax, and a built-in with-expression for creating modified copies. Compared to classes, records are better suited as DTOs, value objects, and data transfer scenarios, significantly reducing boilerplate code.

How should async/await be used correctly in C#?

Always use async/await instead of .Result or .Wait() to avoid deadlocks. Use Task instead of Task when no result is needed. Use ConfigureAwait(false) to avoid unnecessary context captures. Return a Task rather than using async Task when a method can directly return a known task.

How to optimize C# code performance?

Prioritize reducing memory allocations and use Span and Memory for data handling. Choose struct over class for small data structures. Be mindful of LINQ's deferred execution. Compile in Release mode. Use BenchmarkDotNet to measure actual performance and avoid premature optimization.