← ClaudeAtlas

dotnet-typeslisted

C# and .NET type system advisor. Always use this skill when working with C# nullable reference types, records, pattern matching, switch expressions, generics, value types, or sealed classes. Use when the user asks "how do I handle nulls in C#", "record vs class", "how do I use pattern matching", "CS8600 nullable warning", "how do I enable nullable reference types", "sealed class hierarchy", "switch expression in C#", "struct vs class", or "how do I constrain a generic in C#". Read this skill before answering any C# type system question.
AllThingsSmitty/agent-skills · ★ 1 · Code & Development · score 74
Install: claude install-skill AllThingsSmitty/agent-skills
# C# Types C#'s type system has grown significantly — nullable reference types, records, and pattern matching change how you model data and handle null. Use them. Code written without these features tends to be both more verbose and less safe. ## Enable nullable reference types Enable `<Nullable>enable</Nullable>` in your project file. This makes all reference types non-nullable by default — you must opt into nullability with `?`. ```xml <!-- .csproj --> <PropertyGroup> <Nullable>enable</Nullable> </PropertyGroup> ``` ```csharp // Non-nullable — compiler guarantees this is never null string name = GetName(); // Nullable — must check before use string? email = GetEmail(); if (email is not null) { Send(email); // safe } ``` Don't suppress the warnings with `!` (null-forgiving operator) unless you genuinely know more than the compiler — it's the C# equivalent of `as any`. ```csharp // Bad: suppresses the warning without checking string email = GetEmail()!; // Good: check or propagate nullability string? email = GetEmail(); string resolvedEmail = email ?? throw new InvalidOperationException("Email required"); ``` ## Records for immutable data Use `record` for immutable data transfer objects, domain value types, and anything where value equality matters. Records generate `Equals`, `GetHashCode`, `ToString`, and deconstruction automatically. ```csharp // Immutable record — value equality by default public record UserId(string Value); public record User(UserId Id,