Skip to content

Commit

Permalink
test for nullable annotations
Browse files Browse the repository at this point in the history
If the samples compile cleanly in this mode, I can continue in this PR without breaking all the samples.
  • Loading branch information
BillWagner committed May 9, 2024
1 parent e2d4446 commit f84f365
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion standard/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ The attribute instance represented by `T`, `C`, `P`, and `N`, and associated wi
<!-- markdownlint-enable MD028 -->
> *Example*: In an implementation of the CLI, the `Help` attribute instances in the assembly created by compiling the example program in [§22.2.3](attributes.md#2223-positional-and-named-parameters) can be retrieved with the following program:
>
> <!-- Example: {template:"standalone-console", name:"RuntimeAttributeInstanceRetrieval", expectedOutput:["Type : HelpAttribute","Type : InterrogateHelpUrls"], additionalFiles:["HelpAttribute.cs"], executionArgs:["RuntimeAttributeInstanceRetrieval"]} -->
> <!-- Example: {template:"standalone-console", name:"RuntimeAttributeInstanceRetrieval", expectedOutput:["Type : Microsoft.CodeAnalysis.EmbeddedAttribute", "Type : System.Runtime.CompilerServices.NullableAttribute", "Type : System.Runtime.CompilerServices.NullableContextAttribute", "Type : HelpAttribute","Type : InterrogateHelpUrls"], additionalFiles:["HelpAttribute.cs"], executionArgs:["RuntimeAttributeInstanceRetrieval"]} -->
> ```csharp
> public sealed class InterrogateHelpUrls
> {
Expand Down
2 changes: 1 addition & 1 deletion standard/lexical-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ The following pre-processing directives are available:
- `#region` and `#endregion`, which are used to explicitly mark sections of source code ([§6.5.7](lexical-structure.md#657-region-directives)).
- `#pragma`, which is used to specify optional contextual information to a compiler ([§6.5.9](lexical-structure.md#659-pragma-directives)).
- `#nullable`, which is used to specify the nullable context (§Nullable-Directives).
-

A pre-processing directive always occupies a separate line of source code and always begins with a `#` character and a pre-processing directive name. White space may occur before the `#` character and between the `#` character and the directive name.

A source line containing a `#define`, `#undef`, `#if`, `#elif`, `#else`, `#endif`, `#line`, `#endregion`, or `#nullable` directive can end with a single-line comment. Delimited comments (the `/* */` style of comments) are not permitted on source lines containing pre-processing directives.
Expand Down
4 changes: 2 additions & 2 deletions standard/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ When the nullable annotation context is disabled
- No warning shall be generated when a variable of a reference type that possibly has the null value, is dereferenced.
- For any reference type `T`, the annotation `?` in `T?` is ignored, as `T` is already a nullable type. An informational message shall be generated to that effect.
> *Note*: This message is characterized as “informational” rather than “warning,” so as not to confuse it with the state of the nullable warning context, which is unrelated. *end note*
- The null-forgiving operator `!` (§Null-Forgiving-Expressions) is ignored.
- The null-forgiving operator `!` is ignored.

> *Example*:
>
Expand All @@ -765,7 +765,7 @@ When the nullable annotation context is enabled
- For any reference type `T`, the annotation `?` in `T?` makes `T?` a nullable type, whereas the unannotated `T` is non-nullable.
- A warning shall be generated when a variable of an unannotated reference type is initialized with, or assigned a value of, `null`.
- A warning shall be generated when a variable of a nullable or non-nullable reference type, whose value might be `null`, is dereferenced; otherwise, that variable may be dereferenced safely.
- The null-forgiving operator `!` Null-Forgiving-Expressions) suppresses warnings about dereferencing a possible null reference.
- The null-forgiving operator `!` suppresses warnings about dereferencing a possible null reference.
> *Example*:
>
Expand Down
2 changes: 1 addition & 1 deletion tools/example-templates/standalone-console/Project.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<Nullable>annotations</Nullable>
<AssemblyName>$example-name</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down

0 comments on commit f84f365

Please sign in to comment.