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
Copy file name to clipboardExpand all lines: tools/ExampleExtractor/ExtractorAndTesterUsersGuide.md
+58-9Lines changed: 58 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,12 +87,19 @@ template
87
87
: 'template' ':' template_name
88
88
;
89
89
template_name
90
-
: '"standalone-console"' // actually, a JSON_string_value with this content
91
-
| '"standalone-lib"' // actually, a JSON_string_value with this content
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
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
95
+
| '"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
93
98
;
94
99
```
95
100
101
+
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
+
96
103
The template `standalone-console` indicates that the example is an application. For example:
97
104
98
105
````
@@ -156,6 +163,42 @@ class Program
156
163
}
157
164
````
158
165
166
+
The template `code-in-class-lib` indicates that the example needs to be wrapped inside an entry-point method inside a class. For example, the example:
> Console.WriteLine((path == null) ? "No file path" : path);
179
+
> Console.WriteLine((name == null) ? "No member name" : name);
180
+
> }
181
+
> ```
182
+
````
183
+
184
+
gets transformed into the following library:
185
+
186
+
````
187
+
class Class1
188
+
{
189
+
public void Log(
190
+
[CallerLineNumber] int line = -1,
191
+
[CallerFilePath] string path = null,
192
+
[CallerMemberName] string name = null
193
+
)
194
+
{
195
+
Console.WriteLine((line < 0) ? "No line" : "Line "+ line);
196
+
Console.WriteLine((path == null) ? "No file path" : path);
197
+
Console.WriteLine((name == null) ? "No member name" : name);
198
+
}
199
+
}
200
+
````
201
+
159
202
### Example Names
160
203
161
204
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.
@@ -426,6 +469,12 @@ Consider the following example:
426
469
> ```
427
470
````
428
471
472
+
If no console block begins within the 8 lines following the end of such an example, the following error message results:
473
+
474
+
````
475
+
Example xx has InferOutput set but no ```console block shortly after it.
476
+
````
477
+
429
478
**Scenario #2:**
430
479
431
480
In those cases in which an example is *not* followed by a console block containing the expected output, the list of expected output-line strings is provided by the *expected_output* annotation directive, so the two sets of text can be compared, verbatim, for equality. This *annotation_directive* is optional. (This directive makes no provision for output written to a file.)
@@ -551,7 +600,7 @@ All templates support compilation of examples containing unsafe code.
551
600
552
601
### Examples Containing Pseudo-Code
553
602
554
-
Some examples contain C# grammar-rule names, which show a general format rather than source code that will compile. Such names are fenced using the following notation: `«rule_name»`. These examples do *not* have *example_annotation*s.
603
+
Some examples contain C# grammar-rule names, which show a general format rather than source code that will compile. Such names are fenced using the following notation: `«rule_name»`. These examples do not have *example_annotation*s.
555
604
556
605
Here’s an example:
557
606
@@ -608,31 +657,31 @@ Clearly, this code won’t compile, as is. As such, the ExampleExtractor tool re
608
657
609
658
Here are some things to consider:
610
659
611
-
Always add an *example_annotation* to a new example that is intended to be tested. If the annotations details are not completely known, use something like the following:
660
+
Always add an *example_annotation* to a new example that is intended to be tested. If the annotations details are *not* completely known, use something like the following:
0 commit comments