मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग5.8k · #14648

migrate-nullable-references

यह क्या करती है

यह स्किल C# प्रोजेक्ट में नल-संभव रेफ़रेंस टाइप चालू करती है और उनसे आने वाली नल चेतावनियों पर काम करती है। यह उन टीमों के लिए है जो चाहती हैं कि कंपाइलर गायब वैल्यू को क्रैश होने से पहले पकड़ ले।

कब इस्तेमाल करें

  • ✓जब आप मौजूदा C# प्रोजेक्ट में नल-संभव रेफ़रेंस टाइप चालू करना चाहते हों।
  • ✓जब फ़ीचर चालू करने के बाद CS86xx नल चेतावनियाँ आएँ।
  • ✓जब किसी लाइब्रेरी के पब्लिक API को नल एनोटेशन चाहिए ताकि उसके उपयोगकर्ताओं को सही जानकारी मिले।

Skill का लिंक

https://github.com/dotnet/skills/blob/main/plugins/dotnet-upgrade/skills/migrate-nullable-references/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/dotnet/skills/blob/main/plugins/dotnet-upgrade/skills/migrate-nullable-references/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे C# प्रोजेक्ट में नल-संभव रेफ़रेंस टाइप चालू कीजिए और चेतावनियाँ फ़ाइल-दर-फ़ाइल ठीक कीजिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट सेटिंग चालू करता है, योजना के क्रम में चेतावनियों पर काम करता है, सही एनोटेशन जोड़ता है और ज़रूरी न होने वाले null-forgiving ऑपरेटर हटाता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Nullable Reference Migration

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.

When to Use

  • Enabling nullable reference types in an existing C# project or solution
  • Systematically resolving CS86xx nullable warnings after enabling the feature
  • Annotating a library's public API surface so consumers get accurate nullability information
  • Upgrading a dependency that has added nullable annotations and new warnings appear
  • Analyzing suppressions in a code base that has already enabled NRTs to determine whether they can be removed

When Not to Use

  • The project already has <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)
  • The user only wants to suppress warnings without fixing them (recommend against this)
  • The code targets C# 7.3 or earlier, which does not support nullable reference types

Inputs

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

Workflow

🛑 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 #nullable directives. 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.

Step 1: Evaluate readiness

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 disable directives, ! operators, and #pragma warning disable CS86xx suppressions. Use -Json for machine-readable output.

  1. Identify how the project is built and tested. Look for build scripts (e.g., 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.
  2. Run 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).
  3. Open the .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.

Stop if the language version or target framework is insufficient. If <LangVersion> is below 8.0, or the project targets a framework that defaults to C# 7.x (e.g., .NET Framework 4.x without an explicit <LangVersion>), NRTs cannot be enabled as-is. Inform the user explicitly: explain what needs to change (set <LangVersion>8.0</LangVersion> or higher, or retarget to .NET Core 3.0+ / .NET 5+), and ask whether they want to make that update and continue, or abort the

अक्सर पूछे जाने वाले सवाल

क्या मैं बस चेतावनियाँ दबा सकता हूँ?

स्किल इसकी सलाह नहीं देती। वह चेतावनियाँ ठीक करने की कोशिश करती है, ताकि कंपाइलर भरोसेमंद जानकारी दे।

क्या यह पुराने C# वर्शन पर काम करती है?

नहीं। C# 7.3 या उससे पुराने वर्शन नल-संभव रेफ़रेंस टाइप सपोर्ट नहीं करते, इसलिए ऐसा कोड इस माइग्रेशन का इस्तेमाल नहीं कर सकता।

क्या मैं एक बार में एक फ़ाइल माइग्रेट कर सकता हूँ?

हाँ। स्किल फ़ाइल-दर-फ़ाइल और पूरे प्रोजेक्ट दोनों तरह के माइग्रेशन सपोर्ट करती है।

जानकारी

लेखक का मूल विवरण

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 NRTs enabled, suppressing warnings without fixing them, C# 7.3 or earlier projects. INVOKES: Get-Nul

repo: dotnet/skills

लोकप्रियता

GitHub स्टार
5.8k
रैंकिंग में स्थान
#14648
लाइसेंस
MIT
अपडेट की गई
2/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills