Skip to content

Commit b88c9ab

Browse files
committed
Review in light of new prompt
I ran the new prompts, and it caught a couple more things.
1 parent cc8ca47 commit b88c9ab

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ When you enable nullable reference types, the compiler issues warnings everywher
1919
- Add or remove a `?` or `!` annotation.
2020
- Add an attribute that describes the null contract.
2121
- Initialize variables correctly.
22-
- Configure the nullable context.
22+
- Verify the project setting.
2323

2424
This article walks through each technique with a representative example. The goal isn't to silence warnings. It's to make the code's null-handling intent explicit so the compiler reaches the same conclusions you do.
2525

@@ -113,19 +113,15 @@ You have several ways to address it. Pick the one that best matches your design
113113

114114
If a helper method initializes the member, annotate the helper with <xref:System.Diagnostics.CodeAnalysis.MemberNotNullAttribute> so the compiler can credit calls to it.
115115

116-
## Configure the nullable context
116+
## Verify the project setting
117117

118118
New C# projects enable nullable reference types by default, so most code you write or read already has the feature turned on. You generally don't need to configure anything. If you're curious whether a project has it enabled, or you need to change the setting, look for the `<Nullable>` element in the `.csproj`:
119119

120120
:::code language="xml" source="snippets/resolve-warnings/project-snippet.xml":::
121121

122-
The supported values are `enable` (the default for new projects), `disable`, `warnings`, and `annotations`. If the element is missing, the project uses whatever default the SDK and target framework set.
122+
The common supported values are `enable` (the default for new projects) and `disable`. If the element is missing, the project uses whatever default the SDK and target framework set.
123123

124-
To change the setting for part of a file without affecting the rest of the project, use a [preprocessor directive](../../language-reference/preprocessor-directives.md) (a line starting with `#` that gives instructions to the compiler instead of producing executable code):
125-
126-
:::code language="csharp" source="snippets/resolve-warnings/Program.cs" id="NullableDirective":::
127-
128-
The `warnings` and `annotations` values turn on only part of the feature, and they're primarily useful in advanced scenarios such as migrating a large existing codebase one piece at a time. For those trade-offs, see [Nullable migration strategies](../../advanced-topics/update-applications/nullable-migration-strategies.md). For everyday work, `enable` and `disable` are the two values you need.
124+
If you need to enable nullable for only part of a file with `#nullable` directives, or use the partial `warnings` and `annotations` modes when migrating an existing codebase, see [Nullable migration strategies](../../advanced-topics/update-applications/nullable-migration-strategies.md).
129125

130126
## Where to go next
131127

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ dotnet new console -n NullableIntroduction
4646
cd NullableIntroduction
4747
```
4848

49-
Open `NullableIntroduction.csproj` and confirm the `<Nullable>enable</Nullable>` element is set in the `PropertyGroup`. Templates from .NET 6 onward include it by default. If it's missing, add it manually:
49+
Open `NullableIntroduction.csproj`. New console projects from .NET 6 onward set `<Nullable>enable</Nullable>` in the `PropertyGroup`; if it's missing, add it manually:
5050

5151
:::code language="xml" source="snippets/NullableIntroduction/NullableIntroduction.csproj":::
5252

0 commit comments

Comments
 (0)