dotnet-csharp-nullable-reference-types

Enable nullable reference types in C# .NET projects with annotation strategies.

1|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/rudironsoni/dotnet-agent-harness --skill dotnet-csharp-nullable-reference-types-rudironsoni
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dotnet-csharp-nullable-reference-types
Source: https://github.com/rudironsoni/dotnet-agent-harness/tree/main/.rulesync/skills/dotnet-csharp-nullable-reference-types
Command: npx skills add https://github.com/rudironsoni/dotnet-agent-harness --skill dotnet-csharp-nullable-reference-types-rudironsoni

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers understand and correctly implement nullable reference types (NRT) in C#, preventing null reference exceptions and improving code robustness.

Core Features & Use Cases

  • NRT Fundamentals: Explains annotation strategies, nullable context configuration, and migration.
  • Attribute Usage: Details attributes like NotNullWhen, MemberNotNull, and NotNullIfNotNull.
  • Agent Mistakes: Highlights common errors AI agents make with NRT.
  • Use Case: Migrating a legacy .NET codebase to use NRT to catch potential null reference errors at compile time.

Quick Start

Enable nullable reference types project-wide by adding <Nullable>enable</Nullable> to your .csproj file.

Frequently Asked Questions about dotnet-csharp-nullable-reference-types

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enable nullable reference types in a .NET project?

To enable nullable reference types project-wide, add the `<Nullable>enable</Nullable>` property to your .csproj file. This activates static analysis for null handling across your C# codebase to catch potential null reference errors at compile time.

What are nullable reference types in C# and when do I need them?

Nullable reference types in C# are a compile-time feature that uses static analysis to track nullability and prevent null reference exceptions. You need them when migrating legacy .NET codebases to improve type safety and code robustness.

How do I migrate a legacy .NET codebase to use nullable reference types?

Migrating a legacy .NET codebase to nullable reference types involves enabling the nullable context, applying annotation strategies to reference types, and resolving compiler warnings to catch potential null reference errors during compilation.

What C# attributes are used for nullable static analysis?

C# uses nullability attributes like `NotNullWhen`, `MemberNotNull`, and `NotNullIfNotNull` for nullable static analysis. These attributes provide the compiler with detailed context to correctly validate null handling and type safety.

Why does AI generated C# code have nullable reference type errors?

AI generated C# code often contains nullable reference type errors because agents frequently mishandle nullability annotations and skip static analysis attributes. Correct implementation requires specific annotation strategies to ensure type safety.