Install any skill in seconds. Free to start, no credit card required.
Get Started Free →dotnet/migrate-nullable-references
Enable nullable reference types in a C# project and systematically resolve all warnings. USE FOR: adopting NRTs in existing codebases, file-by-file or project-wide migration, fixing CS8602/CS8618/CS86xx warnings, annotating APIs for nullability, cleaning up null-forgiving operators, upgrading dependencies with new nullable annotations. DO NOT USE FOR: projects already fully migrated with zero warnings (unless auditing suppressions), fixing a handful of nullable warnings in code that already has
Passed 17 of 20 test cases with the skill, and 10 of 20 without it.
and 5 more in the full report
7 fixed12 passed either way4 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 7 test cases the skill fixed. Same model, same prompt, with and without the skill.
In `/src/OrderService.cs`, the compiler reports CS8602 (dereference of a possibly null reference) at line 45 on `customer.Address.City`. `customer.Address` is verified non-null by an earlier `Debug.Assert(customer.Address != null)` that the flow analyzer isn't picking up across the partial class boundary. Fix the warning without altering IL runtime execution flow or adding `?.` operators.
| Checked | Without skill | With skill |
|---|---|---|
| Avoids replacing the dereference with null-conditional operator | Passed | Passed |
| Includes a comment justifying why the value is non-null | Missed | Passed |
The instructions your model reads when the skill loads.
Enable C# nullable reference types (NRTs) in an existing codebase and systematically resolve all warnings. The outcome is a project (or solution) with <Nullable>enable</Nullable>, zero nullable warnings, and accurately annotated public API surfaces — giving both the compiler and consumers reliable nullability information.
<Nullable>enable</Nullable> and zero warnings — the migration is done unless the user wants to re-examine suppressions with a view to removing unnecessary ones (see Step 6)| Input | Required | Description |
|---|---|---|
| Project or solution path | Yes | The .csproj, .sln, or build entry point to migrate |
| Migration scope | No | project-wide (default) or file-by-file — controls the rollout strategy |
| Build command | No | How to build the project (e.g., dotnet build, msbuild, or a repo-specific build script). Detect from the repo if not provided |
| Test command | No | How to run tests (e.g., dotnet test, or a repo-specific test script). Detect from the repo if not provided |
🛑 Zero runtime behavior changes. NRT migration is strictly a metadata and annotation exercise. The generated IL must not change — no new branches, no new null checks, no changed control flow, no added or removed method calls. The only acceptable changes are nullable annotations (
?), nullable attributes ([NotNullWhen], etc.),!operators (metadata-only), and#nullabledirectives. If you discover a missing runtime null guard or a latent bug during migration, do not fix it inline. Instead, offer to insert a// TODO: Consider adding ArgumentNullException.ThrowIfNull(param)comment at the site so the user can address it as a separate change. Never mix behavioral fixes into an annotation commit.
Commit strategy: Commit at each logical boundary — after enabling
<Nullable>(Step 2), after fixing dereference warnings (Step 3), after annotating declarations (Step 4), after applying nullable attributes (Step 5), and after cleaning up suppressions (Step 6). This keeps each commit focused and reviewable, and prevents losing work if a later step reveals a design issue that requires rethinking. For file-by-file migrations, commit each file or batch of related files individually.
Optional: Run
scripts/Get-NullableReadiness.ps1 -Path <project-or-solution>to automate the checks below. The script reports<Nullable>,<LangVersion>,<TargetFramework>,<WarningsAsErrors>settings and counts#nullable disabledirectives,!operators, and#pragma warning disable CS86xxsuppressions. Use-Jsonfor machine-readable output.
build.cmd, build.sh, Makefile), a .sln file, or individual .csproj files. If the repo uses a custom build script, use it instead of dotnet build throughout this workflow.dotnet --version to confirm the SDK is installed. Nullable reference types (NRTs) require C# 8.0+ (.NET Core 3.0 / .NET Standard 2.1 or later)..csproj (or Directory.Build.props if properties are set at the repo level) and check the <LangVersion> and <TargetFramework>. If the project multi-targets, note all TFMs.test cases passed, vs 10 / 20 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.