File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
docs/csharp/language-reference/compiler-messages Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,32 @@ The following warnings indicate that you haven't set the nullable context correc
215
215
- ** CS8636** - * Invalid option for ` /nullable ` ; must be ` disable ` , ` enable ` , ` warnings ` or ` annotations ` *
216
216
- ** CS8637** - * Expected ` enable ` , ` disable ` , or ` restore ` *
217
217
218
+ To set the nullable context correctly, you have two options:
219
+
220
+ 1 . ** Project-level configuration** : Add the [ ` <Nullable> ` ] ( ../compiler-options/language.md#nullable ) element to your project file:
221
+
222
+ ``` xml
223
+ <PropertyGroup >
224
+ <Nullable >enable</Nullable >
225
+ </PropertyGroup >
226
+ ```
227
+
228
+ 2 . ** File-level configuration** : Use [ ` #nullable ` ] ( ../preprocessor-directives.md#nullable-context ) preprocessor directives in your source code:
229
+
230
+ ``` csharp
231
+ #nullable enable
232
+ ```
233
+
234
+ The nullable context has two independent flags that control different aspects:
235
+
236
+ - ** Annotation flag** : Controls whether you can use ` ? ` to declare nullable reference types and ` ! ` to surpress individual warnings.
237
+ - ** Warning flag** : Controls whether the compiler emits nullability warnings
238
+
239
+ For detailed information about nullable contexts and migration strategies, see:
240
+
241
+ - [ Nullable reference types overview] ( ../../nullable-references.md#nullable-context )
242
+ - [ Update a codebase with nullable reference types] ( ../../nullable-migration-strategies.md )
243
+
218
244
## Incorrect annotation syntax
219
245
220
246
These errors and warnings indicate that usage of the ` ! ` or ` ? ` annotation is incorrect.
You can’t perform that action at this time.
0 commit comments