ECMA-334: 9.5.7 Line directives
| C# Language Specification |
| © 2006 ECMA International |
9.5.7 Line directives
Line directives can be used to alter the line numbers and source file names that are reported by the compiler in output such as warnings and errors.
[Note: Line directives are most commonly used in meta-programming tools that generate C# source code from some other text input. end note]
- pp-line::
- whitespaceopt
#whitespaceoptlinewhitespace line-indicator pp-new-line
- whitespaceopt
- line-indicator::
- decimal-digits whitespace file-name
- decimal-digits
- identifier-or-keyword
- file-name::
"file-name-characters"
- file-name-characters::
- file-name-character
- file-name-characters file-name-character
- file-name-character::
- Any character except
"(U+0022), and new-line-character
- Any character except
When no #line directives are present, the compiler reports true line numbers and source file names in its
output. When processing a #line directive that includes a line-indicator that is not identifier-or-keyword,
the compiler treats the line after the directive as having the given line number (and file name, if specified).
A #line directive in which the line-indicator is an identifier-or-keyword whose value equals default
(using equality as specified in §9.4.2) reverses the effect of all preceding #line directives. The compiler
reports true line information for subsequent lines, precisely as if no #line directives had been processed.
The purpose of a line-indicator with an identifier-or-keyword whose value does not equal default is
implementation-defined. An implementation that does not recognize such an identifier-or-keyword in a lineindicator
shall issue a warning.
[Note: Note that a file-name differs from a regular string literal in that escape characters are not processed;
the '\' character simply designates an ordinary back-slash character within a file-name. end note]