You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first commit ports in the text from dotnet#700 substantially without change. The only editorial change is to move the clause on "Nullable directives" in lexical-structure before the clause on Pragma directives.
fix build warnings
This will likely cause new failures, as I turned on nullable annotations and warnings in one of the templates.
Update code samples for the template in use to remove nullable warnings.
I did this as we plan to have nullable annotations on by default in this version of the spec.
Revert "fix build warnings"
This reverts commit dcb3731.
test for nullable annotations
If the samples compile cleanly in this mode, I can continue in this PR without breaking all the samples.
revert changes for type system.
Copy file name to clipboardExpand all lines: standard/attributes.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -490,7 +490,7 @@ The attribute instance represented by `T`, `C`, `P`, and `N`, and associated wi
490
490
<!-- markdownlint-enable MD028 -->
491
491
> *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:
Copy file name to clipboardExpand all lines: standard/lexical-structure.md
+38-2Lines changed: 38 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1025,7 +1025,7 @@ right_shift_assignment
1025
1025
1026
1026
### 6.5.1 General
1027
1027
1028
-
The pre-processing directives provide the ability to conditionally skip sections of compilation units, to report error and warning conditions, and to delineate distinct regions of source code.
1028
+
The pre-processing directives provide the ability to conditionally skip sections of compilation units, to report error and warning conditions, to delineate distinct regions of source code, and to set the nullable context.
1029
1029
1030
1030
> *Note*: The term “pre-processing directives” is used only for consistency with the C and C++ programming languages. In C#, there is no separate pre-processing step; pre-processing directives are processed as part of the lexical analysis phase. *end note*
1031
1031
@@ -1041,6 +1041,7 @@ fragment PP_Kind
1041
1041
| PP_Diagnostic
1042
1042
| PP_Region
1043
1043
| PP_Pragma
1044
+
| PP_Nullable
1044
1045
;
1045
1046
1046
1047
// Only recognised at the beginning of a line
@@ -1077,10 +1078,11 @@ The following pre-processing directives are available:
1077
1078
-`#error`, which is used to issue errors ([§6.5.6](lexical-structure.md#656-diagnostic-directives)).
1078
1079
-`#region` and `#endregion`, which are used to explicitly mark sections of source code ([§6.5.7](lexical-structure.md#657-region-directives)).
1079
1080
-`#pragma`, which is used to specify optional contextual information to a compiler ([§6.5.9](lexical-structure.md#659-pragma-directives)).
1081
+
-`#nullable`, which is used to specify the nullable context (§Nullable-Directives).
1080
1082
1081
1083
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.
1082
1084
1083
-
A source line containing a `#define`, `#undef`, `#if`, `#elif`, `#else`, `#endif`, `#line`, or `#endregion` directive can end with a single-line comment. Delimited comments (the `/* */` style of comments) are not permitted on source lines containing pre-processing directives.
1085
+
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.
1084
1086
1085
1087
Pre-processing directives are not part of the syntactic grammar of C#. However, pre-processing directives can be used to include or exclude sequences of tokens and can in that way affect the meaning of a C# program.
1086
1088
@@ -1506,6 +1508,40 @@ A `#line hidden` directive has no effect on the compilation unit and line number
Anullabledirectivesetsthedenotednullablecontext(s) for subsequent lines of code, until another nullable directive overrides it, or until the end of the source code is reached. The effect of each form of nullable directive is, as follows:
1532
+
1533
+
- `#nullable disable`: Sets both nullable contexts to “disabled”
1534
+
- `#nullable enable`: Sets both nullable contexts to “enabled”
1535
+
- `#nullable restore`: Restores both nullable contexts to the states specified by the external mechanism, if any
1536
+
- `#nullable disable annotations`: Sets the nullable annotation context to “disabled”
1537
+
- `#nullable enable annotations`: Sets the nullable annotation context to “enabled”
1538
+
- `#nullable restore annotations`: Restores the nullable annotation context to the state specified by the external mechanism, if any
1539
+
- `#nullable disable warnings`: Sets the nullable warning context to “disabled”
1540
+
- `#nullable enable warnings`: Sets the nullable warning context to “enabled”
1541
+
- `#nullable restore warnings`: Restores the nullable warning context to the state specified by the external mechanism, if any
1542
+
1543
+
Disabling a nullable context that is already disabled has no effect. Likewise, enabling a nullable context that is already enabled has no effect.
1544
+
1509
1545
### 6.5.9 Pragma directives
1510
1546
1511
1547
The `#pragma` preprocessing directive is used to specify contextual information to a compiler.
0 commit comments