ECMA-334 C# Language Specification9.5.5: Diagnostic directives |
The diagnostic directives are used to explicitly generate error and warning messages that are reported in the same way as other compile-time errors and warnings.
whitespace
opt #
whitespace
opt error
pp-message
whitespace
opt #
whitespace
opt warning
pp-message
new-line
whitespace
input-characters
opt new-line
always produces a warning ("Code review needed before check-in"), and produces a compile-time error if the pre-processing identifiers Debug and Retail are both defined. Note that a
#warning Code review needed before check-in
#if Debug && Retail
#error A build can't be both debug and retail
#endif
class Test {...}
pp-message
can contain arbitrary text; specifically, it need not contain well-formed tokens, as shown by the single quote in the word can't. end example]