nullable-enablement

Migrate NuGet.Client files from `#nullable disable` to annotated C# nullable reference types.

819|757|Updated Apr 30, 2014
One-click install
npx skills add https://github.com/NuGet/NuGet.Client --skill nullable-enablement
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nullable-enablement
Source: https://github.com/NuGet/NuGet.Client/tree/main/.copilot/skills/nullable-enablement
Command: npx skills add https://github.com/NuGet/NuGet.Client --skill nullable-enablement

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you modernize the NuGet.Client codebase by removing #nullable disable directives and correctly annotating nullability so C# nullable reference types can catch real bugs instead of hiding them.

Core Features & Use Cases

  • Migrate files from #nullable disable to annotated nullability: Remove the directive, add correct ?/non-null types, and fix cascading warnings in dependent code.
  • Keep API correctness with PublicAPI updates: Update PublicAPI.Shipped.txt by replacing ~ (oblivious) entries in all targeted TFMs.
  • Follow a non-null bias and preserve behavior: Prefer making things non-null through required, constructor initialization, null-checks, and safe patterns, using ? only when values are genuinely optional or absent.
  • Use incremental batching for safety: Migrate in small groups of related files, build to validate, and repeat.

Quick Start

Use the nullable-enablement skill on the specific NuGet.Client files that still contain #nullable disable, then iteratively annotate nullability, update PublicAPI.Shipped.txt for each affected TFM, and run msbuild until zero warnings remain.

Frequently Asked Questions about nullable-enablement

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

FAQPage Schema
How do I enable nullable reference types in C# files that use #nullable disable?▼

To enable nullable reference types, remove the `#nullable disable` directive, apply a non-null bias with correct `?` annotations for optional values, and iterate with msbuild until all nullable warnings are eliminated.

Why do I need to update PublicAPI.Shipped.txt when enabling nullable reference types?▼

Updating `PublicAPI.Shipped.txt` is required when enabling nullable reference types to replace `~` (oblivious) entries with correct nullability annotations consistently across all targeted TFMs.

What is the best way to migrate a large codebase to C# nullable reference types safely?▼

The best way to migrate to C# nullable reference types safely is using incremental batching: migrate small groups of related files, build to validate warnings, update PublicAPI files, and repeat.

When should I use the nullable annotation `?` versus making a property required in C#?▼

Use the nullable annotation `?` only when values are genuinely optional or absent; otherwise, apply a non-null bias using `required`, constructor initialization, and null-checks to preserve behavior.

How do I fix cascading nullable warnings in dependent code after removing #nullable disable?▼

Fix cascading nullable warnings by iteratively annotating nullability in dependent files, aligning contracts, and running msbuild builds until zero nullable diagnostics remain.

Can I use incremental batching for code migration to nullable reference types in NuGet.Client?▼

Yes, you can use incremental batching for NuGet.Client code migration by targeting small groups of related files, running msbuild to validate, and updating PublicAPI.Shipped.txt for each TFM.