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
* Add small improvements
* Add new template
* add new templates and options
* add new template and option
* Support passing of command-line arguments
* add support for multi-file examples
-[Using Chevron-Quotes for Emphasis](#using-chevron-quotes-for-emphasis)
20
23
-[Tips for Creating New Testable Examples](#tips-for-creating-new-testable-examples)
21
24
@@ -45,8 +48,11 @@ annotation_directive
45
48
| ignored_warnings
46
49
| expected_output
47
50
| infer_output
51
+
| ignore_output
48
52
| expected_exception
49
53
| additional_files
54
+
| extern_alias_support
55
+
| execution_arguments
50
56
;
51
57
```
52
58
@@ -80,27 +86,33 @@ In this case, the *example_annotation* is preceded by `> ` to match the example
80
86
81
87
### Templates
82
88
89
+
#### General
90
+
83
91
An annotation’s *template* is used to select certain compiler options, and to provide supporting machinery, as needed. This *annotation_directive* is required.
84
92
85
93
```ANTLR
86
94
template
87
95
: 'template' ':' template_name
88
96
;
89
97
template_name
90
-
: '"code-in-class-lib"' // actually, a JSON_string_value with this content
91
-
| '"code-in-class-lib-without-using"' // actually, a JSON_string_value with this content
92
-
| '"code-in-main"' // actually, a JSON_string_value with this content
93
-
| '"code-in-main-without-using"' // actually, a JSON_string_value with this content
94
-
| '"standalone-console"' // actually, a JSON_string_value with this content
98
+
: '"code-in-class-lib"' // actually, a JSON_string_value with this content
99
+
| '"code-in-class-lib-without-using"' // actually, a JSON_string_value with this content
100
+
| '"code-in-main"' // actually, a JSON_string_value with this content
101
+
| '"code-in-main-without-using"' // actually, a JSON_string_value with this content
102
+
| '"code-in-partial-class"' // actually, a JSON_string_value with this content
103
+
| '"extern-lib"' // actually, a JSON_string_value with this content
104
+
| '"standalone-console"' // actually, a JSON_string_value with this content
95
105
| '"standalone-console-without-using"' // actually, a JSON_string_value with this content
96
-
| '"standalone-lib"' // actually, a JSON_string_value with this content
97
-
| '"standalone-lib-without-using"' // actually, a JSON_string_value with this content
106
+
| '"standalone-lib"' // actually, a JSON_string_value with this content
107
+
| '"standalone-lib-without-using"' // actually, a JSON_string_value with this content
98
108
;
99
109
```
100
110
101
111
The unsuffixed and suffixed versions are identical, *except* that the unsuffixed ones have using directioves for all namespaces used by examples, while the suffixed ones do not. The unsuffixed versions are used by those few examples that begin with `#undef` or `#define`, which *must* precede using directives, and which might then have explicit using directives.
102
112
103
-
The template `standalone-console` indicates that the example is an application. For example:
113
+
#### standalone-console
114
+
115
+
This template indicates that the example is an application. For example:
The template causes the example code to be compiled without change, along with definition of, and mapping to, the necessary support files for the referenced external aliases, `X` and `Y` via the file `ExampleProject.csproj` in the `extern-lib` template folder.
286
+
202
287
### Example Names
203
288
204
289
An annotation’s *name* is the name of the resulting test file directory, **which must be unique across the whole C# spec**. This *annotation_directive* is required. *name* should be a valid C# idenifier.
@@ -428,7 +513,9 @@ Here’s an *example_annotation* showing both expected and ignored warnings:
428
513
429
514
### Expected Runtime Output
430
515
431
-
During execution, some test applications are expected to write one or more lines of output to the console.
516
+
During execution, some test applications to write one or more lines of output to the console.
517
+
518
+
> **The tool trims all whitespace from the end of each output string *before* comparing it against any expected or console-block string. As such, make sure an example does *not* generate output lines containing trailing whitespace.**
432
519
433
520
**Scenario #1:**
434
521
@@ -511,6 +598,15 @@ Consider the following example, which writes two lines to the console:
511
598
> ```
512
599
````
513
600
601
+
**Scenario #3:**
602
+
603
+
In those cases in which the output is nondeterministic, we can ignore that output by using the following *annotation_directive*, which is optional.
604
+
605
+
```ANTLR
606
+
ignore_output
607
+
: 'ignoreOutput' ':' ('true' | 'false')
608
+
```
609
+
514
610
### Expected Exception
515
611
516
612
An expected exception can be identified and checked for. This *annotation_directive* is optional.
@@ -552,7 +648,7 @@ Consider the following example:
552
648
553
649
### Including Support Files
554
650
555
-
When an example relies on external support information (such as a type declaration or document-comment include file), one or more files containing that information can be copied to the output directory from the `additional-files` directory within the `template` directory. The *annotation_directive*`additionalFiles` achieves this, and is optional.
651
+
When an example relies on external support information (such as a type declaration, a document-comment include file, or an extension method), one or more files containing that information can be copied to the output directory from the `additional-files` directory within the `template` directory. The *annotation_directive*`additionalFiles` achieves this, and is optional.
556
652
557
653
```ANTLR
558
654
additional_files
@@ -592,6 +688,36 @@ namespace Acme
592
688
}
593
689
````
594
690
691
+
Regarding extension methods, these are all defined in the file Extensions.cs in the additional-files folder.
692
+
693
+
### Supporting External Aliases
694
+
695
+
```ANTLR
696
+
extern_alias_support
697
+
: 'project' ':' filename
698
+
;
699
+
filename
700
+
: JSON_string_value
701
+
;
702
+
```
703
+
704
+
This *annotation_directive* supports the template [`extern-lib`](#extern-lib)).
Each *cmdlinearg* corresponds to a command-line argument to be passed to the program's entry point at execution, in the order specified, where the first occurence is array element 0.
718
+
719
+
This *annotation_directive* supports all templates that create an executable.
Althoughtheexampleiswrittenasasinglemarkdowncodeblock, line-orientedcommentsoftheform `// File `*filename* are used to delineate the source files. For example,
0 commit comments