Skip to content

Commit 13e5b40

Browse files
committed
Move nullable-migration-strategies to advanced-topics/update-applications
Relocate the migration article out of fundamentals/null-safety into a new Advanced topics > Update existing apps subsection. Rename to nullable-migration-strategies.md, repath snippets, update inbound links from sibling articles and language-reference, repoint redirects, and add a redirect from the vacated path.
1 parent 04dadbc commit 13e5b40

12 files changed

Lines changed: 35 additions & 25 deletions

File tree

.openpublishing.redirection.csharp.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
22
"redirections": [
3+
{
4+
"source_path_from_root": "/docs/csharp/fundamentals/null-safety/migration-strategies.md",
5+
"redirect_url": "/dotnet/csharp/advanced-topics/update-applications/nullable-migration-strategies"
6+
},
37
{
48
"source_path_from_root": "/docs/csharp/fundamentals/types/anonymous-types.md",
59
"redirect_url": "/dotnet/csharp/fundamentals/types/tuples"
@@ -508,6 +512,10 @@
508512
"source_path_from_root": "/docs/csharp/features.md",
509513
"redirect_url": "/dotnet/csharp/programming-guide/concepts"
510514
},
515+
{
516+
"source_path_from_root": "/docs/csharp/fundamentals/null-safety/migration-strategies.md",
517+
"redirect_url": "/dotnet/csharp/advanced-topics/update-applications/nullable-migration-strategies"
518+
},
511519
{
512520
"source_path_from_root": "/docs/csharp/fundamentals/types/anonymous-types.md",
513521
"redirect_url": "/dotnet/csharp/fundamentals/types/tuples"
@@ -3447,11 +3455,11 @@
34473455
},
34483456
{
34493457
"source_path_from_root": "/docs/csharp/nullable-attributes.md",
3450-
"redirect_url": "/dotnet/csharp/fundamentals/null-safety/migration-strategies"
3458+
"redirect_url": "/dotnet/csharp/advanced-topics/update-applications/nullable-migration-strategies"
34513459
},
34523460
{
34533461
"source_path_from_root": "/docs/csharp/nullable-migration-strategies.md",
3454-
"redirect_url": "/dotnet/csharp/fundamentals/null-safety/migration-strategies"
3462+
"redirect_url": "/dotnet/csharp/advanced-topics/update-applications/nullable-migration-strategies"
34553463
},
34563464
{
34573465
"source_path_from_root": "/docs/csharp/nullable-references.md",
@@ -5698,7 +5706,7 @@
56985706
},
56995707
{
57005708
"source_path_from_root": "/docs/csharp/tutorials/upgrade-to-nullable-references.md",
5701-
"redirect_url": "/dotnet/csharp/fundamentals/null-safety/migration-strategies"
5709+
"redirect_url": "/dotnet/csharp/advanced-topics/update-applications/nullable-migration-strategies"
57025710
},
57035711
{
57045712
"source_path_from_root": "/docs/csharp/type-system.md",
@@ -5800,7 +5808,7 @@
58005808
},
58015809
{
58025810
"source_path_from_root": "/docs/csharp/whats-new/tutorials/upgrade-to-nullable-references.md",
5803-
"redirect_url": "/dotnet/csharp/fundamentals/null-safety/migration-strategies"
5811+
"redirect_url": "/dotnet/csharp/advanced-topics/update-applications/nullable-migration-strategies"
58045812
},
58055813
{
58065814
"source_path_from_root": "/docs/csharp/write-safe-efficient-code.md",

docs/csharp/fundamentals/null-safety/migration-strategies.md renamed to docs/csharp/advanced-topics/update-applications/nullable-migration-strategies.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ ai-usage: ai-assisted
99
# Nullable migration strategies
1010

1111
> [!TIP]
12-
> **Starting a new project?** New projects created from .NET 6 or later templates already have `<Nullable>enable</Nullable>` set. You don't need a migration strategy—skip to [Resolve nullable warnings](resolve-warnings.md).
12+
> **Starting a new project?** New projects created from .NET 6 or later templates already have `<Nullable>enable</Nullable>` set. You don't need a migration strategy—skip to [Resolve nullable warnings](../../fundamentals/null-safety/resolve-warnings.md).
1313
>
14-
> **Maintaining an existing codebase?** Read [Nullable reference types](nullable-reference-types.md) first to understand contexts, annotations, and null-state. This article assumes you're familiar with those concepts and ready to plan a rollout.
14+
> **Maintaining an existing codebase?** Read [Nullable reference types](../../fundamentals/null-safety/nullable-reference-types.md) first to understand contexts, annotations, and null-state. This article assumes you're familiar with those concepts and ready to plan a rollout.
1515
1616
When you turn on nullable reference types on a large project that started before nullable reference types were introduced, the compiler produces many warnings at once. Migration is about *sequencing* the work: choosing a default context, exposing warnings file by file or section by section, and converging on `<Nullable>enable</Nullable>` for the whole project. The right sequence depends on how active the codebase is and how much risk you can take in a single pass.
1717

@@ -37,17 +37,17 @@ Pick the strategy that makes the next file you create do the right thing automat
3737

3838
Your project file controls the global default. The `#nullable` preprocessor directives override it locally:
3939

40-
:::code language="xml" source="snippets/migration-strategies/project-snippet.xml":::
40+
:::code language="xml" source="snippets/nullable-migration-strategies/project-snippet.xml":::
4141

42-
:::code language="csharp" source="snippets/migration-strategies/Program.cs" id="DirectiveOverrides":::
42+
:::code language="csharp" source="snippets/nullable-migration-strategies/Program.cs" id="DirectiveOverrides":::
4343

4444
## Migrate file by file
4545

4646
The most predictable way to migrate a large project is to enable warnings or annotations file by file. The pattern is the same regardless of which default you pick:
4747

4848
1. Pick a file. Start with the deepest leaf types in your dependency graph, then move outward. Annotating a type causes new warnings in its callers, so working bottom-up minimizes rework.
4949
1. Add the `#nullable` directive that opts the file into the new behavior. Use `#nullable enable` if you want both flags. Use `#nullable enable warnings` for warning-only.
50-
1. Address the warnings in the file using the techniques in [Resolve nullable warnings](resolve-warnings.md).
50+
1. Address the warnings in the file using the techniques in [Resolve nullable warnings](../../fundamentals/null-safety/resolve-warnings.md).
5151
1. Repeat for the next file.
5252
1. When every file in the project has its directive, remove the directives and set `<Nullable>enable</Nullable>` at the project level.
5353

@@ -69,7 +69,7 @@ Lead with warnings when fixing latent <xref:System.NullReferenceException?displa
6969
Lead with annotations when stabilizing the public API surface is the priority. This sequence suits libraries: you can ship annotated signatures so consumers see the right contracts, then close out the internal warnings on your own schedule.
7070

7171
1. **Phase 1 — Add annotations.** Set the project default to `annotations`. Reference types become non-nullable by default, but the compiler doesn't emit warnings, so the noise stays out of your way. Walk the public API and add `?` to every member that may legitimately return or accept `null`. Tighten the signatures that shouldn't. Because warnings are off, you can settle the API shape in focused commits without untangling the implementation at the same time.
72-
1. **Phase 2 — Address warnings.** Switch the project default to `enable`. The annotations you added in phase 1 now feed null-state analysis, so the warnings the compiler emits are higher quality from the start—each one points at code whose behavior doesn't match the contract you already published. Resolve them with the techniques in [Resolve nullable warnings](resolve-warnings.md).
72+
1. **Phase 2 — Address warnings.** Switch the project default to `enable`. The annotations you added in phase 1 now feed null-state analysis, so the warnings the compiler emits are higher quality from the start—each one points at code whose behavior doesn't match the contract you already published. Resolve them with the techniques in [Resolve nullable warnings](../../fundamentals/null-safety/resolve-warnings.md).
7373

7474
### Choosing between the orderings
7575

@@ -94,11 +94,11 @@ After every file participates in the project default and the `<Nullable>enable</
9494
- Remove `null!` and `default!` initializers that you added only to silence warnings during migration. Replace them with proper initialization, or change the member type to nullable.
9595
- Spot-check the public API. Every member that returns or accepts `null` should be annotated with `?`. The annotations are part of your contract once the package ships.
9696

97-
You're now in the same state as new projects: nullable reference types are part of the type system, and any new warnings reflect a real mismatch between declarations and code. Use [Resolve nullable warnings](resolve-warnings.md) to address them as they come up.
97+
You're now in the same state as new projects: nullable reference types are part of the type system, and any new warnings reflect a real mismatch between declarations and code. Use [Resolve nullable warnings](../../fundamentals/null-safety/resolve-warnings.md) to address them as they come up.
9898

9999
## Related content
100100

101-
- [Nullable reference types](nullable-reference-types.md)
102-
- [Resolve nullable warnings](resolve-warnings.md)
101+
- [Nullable reference types](../../fundamentals/null-safety/nullable-reference-types.md)
102+
- [Resolve nullable warnings](../../fundamentals/null-safety/resolve-warnings.md)
103103
- [Nullable static analysis attributes](../../language-reference/attributes/nullable-analysis.md)
104104
- [Working with nullable reference types in EF Core](/ef/core/miscellaneous/nullable-reference-types)

docs/csharp/fundamentals/null-safety/snippets/migration-strategies/Program.cs renamed to docs/csharp/advanced-topics/update-applications/snippets/nullable-migration-strategies/Program.cs

File renamed without changes.

docs/csharp/fundamentals/null-safety/snippets/migration-strategies/migration-strategies.csproj renamed to docs/csharp/advanced-topics/update-applications/snippets/nullable-migration-strategies/nullable-migration-strategies.csproj

File renamed without changes.

docs/csharp/fundamentals/null-safety/snippets/migration-strategies/project-snippet.xml renamed to docs/csharp/advanced-topics/update-applications/snippets/nullable-migration-strategies/project-snippet.xml

File renamed without changes.

docs/csharp/fundamentals/null-safety/nullable-reference-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ For new projects targeting .NET 6 or later, the project template includes the `<
2929

3030
:::code language="xml" source="snippets/nullable-reference-types/project-snippet.xml":::
3131

32-
For migration approaches that enable the feature gradually, file by file or warning-only first. For more information on migration, see [Nullable migration strategies](migration-strategies.md).
32+
For migration approaches that enable the feature gradually, file by file or warning-only first. For more information on migration, see [Nullable migration strategies](../../advanced-topics/update-applications/nullable-migration-strategies.md).
3333

3434
## Express intent with annotations
3535

@@ -123,6 +123,6 @@ Initialize array elements as part of creating the array. [Collection expressions
123123

124124
- [Tutorial: Express your design intent with nullable and non-nullable reference types](../tutorials/nullable-reference-types.md)
125125
- [Resolve nullable warnings](resolve-warnings.md)
126-
- [Nullable migration strategies](migration-strategies.md)
126+
- [Nullable migration strategies](../../advanced-topics/update-applications/nullable-migration-strategies.md)
127127
- [Nullable static analysis attributes](../../language-reference/attributes/nullable-analysis.md)
128128
- [Resolve nullable warnings (compiler reference)](../../language-reference/compiler-messages/nullable-warnings.md)

docs/csharp/fundamentals/null-safety/resolve-warnings.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Or scope it to part of a file with a [preprocessor directive](../../language-ref
3939

4040
:::code language="csharp" source="snippets/resolve-warnings/Program.cs" id="NullableDirective":::
4141

42-
The context has two independent flags. The *annotation* flag controls whether `?` and `!` are meaningful in declarations. The *warning* flag controls whether the compiler emits diagnostics. You can enable each independently. Enabling warnings while leaving annotations off lets you address null-handling bugs before you take on annotating types. Enabling annotations while leaving warnings off lets you express your design intent in the API surface without producing diagnostics in implementation code that isn't ready yet. Either combination can be the right choice for a project at a given stage. For the migration trade-offs, see [Nullable migration strategies](migration-strategies.md).
42+
The context has two independent flags. The *annotation* flag controls whether `?` and `!` are meaningful in declarations. The *warning* flag controls whether the compiler emits diagnostics. You can enable each independently. Enabling warnings while leaving annotations off lets you address null-handling bugs before you take on annotating types. Enabling annotations while leaving warnings off lets you express your design intent in the API surface without producing diagnostics in implementation code that isn't ready yet. Either combination can be the right choice for a project at a given stage. For the migration trade-offs, see [Nullable migration strategies](../../advanced-topics/update-applications/nullable-migration-strategies.md).
4343

4444
## Add a null check
4545

@@ -126,12 +126,12 @@ If a helper method initializes the member, annotate the helper with <xref:System
126126

127127
When a warning doesn't fit any of these patterns, the [Resolve nullable warnings](../../language-reference/compiler-messages/nullable-warnings.md) reference article lists the technique for every CS86xx warning the compiler emits.
128128

129-
To plan a migration that progressively enables nullable reference types in an existing codebase, see [Nullable migration strategies](migration-strategies.md).
129+
To plan a migration that progressively enables nullable reference types in an existing codebase, see [Nullable migration strategies](../../advanced-topics/update-applications/nullable-migration-strategies.md).
130130

131131
## Related content
132132

133133
- [Nullable reference types](nullable-reference-types.md)
134134
- [Null operators](null-operators.md)
135-
- [Nullable migration strategies](migration-strategies.md)
135+
- [Nullable migration strategies](../../advanced-topics/update-applications/nullable-migration-strategies.md)
136136
- [Nullable static analysis attributes](../../language-reference/attributes/nullable-analysis.md)
137137
- [Resolve nullable warnings (compiler reference)](../../language-reference/compiler-messages/nullable-warnings.md)

docs/csharp/fundamentals/tutorials/nullable-reference-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ The finished sample is in the [csharp/NullableIntroduction](https://github.com/d
170170

171171
- [Nullable reference types](../null-safety/nullable-reference-types.md)
172172
- [Resolve nullable warnings](../null-safety/resolve-warnings.md)
173-
- [Nullable migration strategies](../null-safety/migration-strategies.md)
173+
- [Nullable migration strategies](../../advanced-topics/update-applications/nullable-migration-strategies.md)
174174
- [Working with nullable reference types in EF Core](/ef/core/miscellaneous/nullable-reference-types)

docs/csharp/language-reference/builtin-types/nullable-reference-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The preceding examples demonstrate how compiler's static analysis determines the
7070

7171
## Setting the nullable context
7272

73-
You can control the nullable context in two ways. At the project level, add the `<Nullable>enable</Nullable>` project setting. In a single C# source file, add the `#nullable enable` pragma to enable the nullable context. See the article on [setting a nullable strategy](../../fundamentals/null-safety/migration-strategies.md). Before .NET 6, new projects use the default, `<Nullable>disable</Nullable>`. Beginning with .NET 6, new projects include the `<Nullable>enable</Nullable>` element in the project file.
73+
You can control the nullable context in two ways. At the project level, add the `<Nullable>enable</Nullable>` project setting. In a single C# source file, add the `#nullable enable` pragma to enable the nullable context. See the article on [setting a nullable strategy](../../advanced-topics/update-applications/nullable-migration-strategies.md). Before .NET 6, new projects use the default, `<Nullable>disable</Nullable>`. Beginning with .NET 6, new projects include the `<Nullable>enable</Nullable>` element in the project file.
7474

7575
## C# language specification
7676

docs/csharp/language-reference/compiler-messages/nullable-warnings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ You address almost all warnings using one of five techniques:
206206
- Adding attributes that describe null semantics.
207207
- Initializing variables correctly.
208208

209-
If you're new to using nullable reference types, the [overview of nullable reference types](../../fundamentals/null-safety/nullable-reference-types.md) provides a background on what nullable reference types solve and how they work to provide warnings to possible mistakes in your code. You can also check the guidance on [migrating to nullable reference types](../../fundamentals/null-safety/migration-strategies.md) to learn more about enabling nullable reference types in an existing project.
209+
If you're new to using nullable reference types, the [overview of nullable reference types](../../fundamentals/null-safety/nullable-reference-types.md) provides a background on what nullable reference types solve and how they work to provide warnings to possible mistakes in your code. You can also check the guidance on [migrating to nullable reference types](../../advanced-topics/update-applications/nullable-migration-strategies.md) to learn more about enabling nullable reference types in an existing project.
210210

211211
## Configure nullable context
212212

@@ -241,7 +241,7 @@ The nullable context has two independent flags that control different aspects:
241241
For detailed information about nullable contexts and migration strategies, see:
242242

243243
- [Nullable reference types overview](../../fundamentals/null-safety/nullable-reference-types.md#nullable-context)
244-
- [Update a codebase with nullable reference types](../../fundamentals/null-safety/migration-strategies.md)
244+
- [Update a codebase with nullable reference types](../../advanced-topics/update-applications/nullable-migration-strategies.md)
245245

246246
## Incorrect annotation syntax
247247

0 commit comments

Comments
 (0)