Csharp
C# programming for .NET, ASP.NET Core, LINQ, async patterns, and Entity Framework. Use for .cs files.From its SKILL.md
npx -y skills add G1Joshi/Agent-Skills --skill csharpAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 12 stars12 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
3.2 KB, 743 tokens by cl100k_base, as published. Nobody here has run it
C#
Modern C# development with .NET 8+, async patterns, and Entity Framework.
When to Use
- Working with
.csfiles - Building ASP.NET Core web APIs
- Unity game development
- Desktop apps with WPF/MAUI
Quick Start
public record User(string Id, string Name, string Email);
public class UserService
{
public async Task<User?> GetUserAsync(string id)
{
return await _repository.FindByIdAsync(id);
}
}
Core Concepts
Records & Nullable
// Records for immutable data
public record User(string Id, string Name, string Email)
{
public string DisplayName => Name.ToUpperInvariant();
}
// With-expressions for copies
var updated = user with { Name = "New Name" };
// Nullable reference types
public User? FindUser(string id)
{
return users.FirstOrDefault(u => u.Id == id);
}
Async/Await
public async Task<List<User>> GetUsersAsync()
{
// Parallel async operations
var tasks = ids.Select(id => GetUserAsync(id));
var users = await Task.WhenAll(tasks);
return users.ToList();
}
// Async streams
public async IAsyncEnumerable<User> StreamUsersAsync()
{
await foreach (var user in _repository.GetAllAsync())
{
yield return user;
}
}
// Cancellation
public async Task<User> GetUserAsync(string id, CancellationToken ct)
{
return await _client.GetFromJsonAsync<User>($"/users/{id}", ct);
}
Common Patterns
LINQ
// Query syntax
var adults = from user in users
where user.Age >= 18
orderby user.Name
select user;
// Method syntax (preferred)
var result = users
.Where(u => u.IsActive)
.OrderBy(u => u.Name)
.Select(u => new UserDto(u.Id, u.Name))
.ToList();
// Grouping
var byCountry = users
.GroupBy(u => u.Country)
.ToDictionary(g => g.Key, g => g.ToList());
Pattern Matching
string GetStatus(object obj) => obj switch
{
User { IsActive: true } => "Active user",
User { IsActive: false } => "Inactive user",
null => "No data",
_ => "Unknown"
};
// List patterns
if (numbers is [var first, _, var last])
{
Console.WriteLine($"First: {first}, Last: {last}");
}
Best Practices
Do:
- Use
recordfor DTOs and value objects - Enable nullable reference types
- Use async/await for I/O operations
- Use dependency injection
Don't:
- Block async code with
.Resultor.Wait() - Ignore cancellation tokens
- Use
dynamicwhen type is known - Create God classes
Troubleshooting
| Error | Cause | Solution |
|---|---|---|
NullReferenceException | Accessing null | Enable nullable, use ?. |
ObjectDisposedException | Using disposed resource | Check lifetime, use using |
TaskCanceledException | Operation cancelled | Handle or propagate |
References
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.