-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example Extractor and Tester Tools Status #646
Comments
Complete ExampleMetadata: The metadata is correct and complete. The code compiles (and optionally executes), as is. No further action is needed. |
Incomplete ExampleMetadata: Example needs support infrastructure such as declarations or an enclosing type. As this is the single biggest group of currently excluded examples, this is the one worth investing some time to see if it can be addressed, at least for most examples.
The remaining such examples are stay incomplete, and might never be completed. This will not be a barrier to closing this issue. |
Implementation-Defined BehaviorMetadata: A few examples produce multiple output tokens whose order might vary from one conforming implementation to another, in which case, what to say for Each such example has an HTML comment saying "<!-- Maintenance Note: The behavior of this example is implementation-defined. As such, the metadata does not compare test output with any ```console block." No further action needed. |
Detecting Intended ExceptionsMetadata: How to detect and check it’s the expected exception? 2022-10-26: Problem solved by PR #648, by adding a new metadata string/value pair, |
Multifile ExamplesMetadata: Two or more source files need to be compiled together. Some parts of some examples contain preprocessor directives, which must come before declarations, so they can’t be compiled as a single file. 2023-12-14: Jon resolved part of this problem in PR #735, by adding support for multi-file examples in a single project. Reclassified as Incomplete$Example. No further action needed. |
Example Needing ReviewMetadata: The compilation or execution resulted in unexpected behavior, but which Rex didn’t understand. |
Chevron Delimiters Used for EmphasisMetadata: In the Expressions chapter, we use «…» notation for emphasis, as follows:
Clearly, this code won’t compile. We can either the example omit from the extraction process or remove the delimiters (and the explanation of their usage). 2022-10-26: Problem solved by PR #649, by having the extractor remove all chevron delimiters. Also made the example complete by handling the "not returning a value" in an ellipses context. |
Undefined BehaviorMetadata: We can’t say what, if any, output might result; the program could even abort! Each such example has an HTML comment saying "<!-- Maintenance Note: The behavior of this example is undefined." No further action needed. |
Including Support Files (formerly Documentation Comment Include File)Metadata: The documentation comments tag 2022-11-01: Jon addressed this as part of the more general issue of providing supporting types (and such) in separate files. See PR #662. |
Unsafe CodeSuch examples require csc option Metadata: Three unsafe examples also have another aspect to consider, as shown above. 2022-10-27: The general problem was solved by PR #650, by enabling unsafe mode for all examples. What remains are: Metadata: which will be handled under their respective categories. |
This will allow for examples which are just statements. (Also adds example in 16.1 Arrays to show how to use it.) Towards dotnet#646
Namespace AccessThis applies to both Complete and Incomplete examples. We currently use three different approaches:
Approaches 1 and 2 differ in style; however, both work, but we could/should be consistent! However, to complete the examples in Approach 3, we need to choose Approach 1 or 2, or get the equivalent to Approach 1 by having such text be implicitly included as a preamble. This has been resolved! There are two versions of each template, called xxx and xxx-without-using (as in standalone-console, and standalone-console-without-using). The former contains using directives for all the namespaces needed by examples in the spec. The latter contains none of them! The latter set is used whenever no names need be imported. It is also used by those few examples that begin with |
Ignoring Certain WarningsNot all warnings are relevant to the purpose of the tester tool. Can/should such warnings be ignored? For an example in basic-concepts.md, we have the following: <!-- Example: {template:"standalone-lib", name:"Declarations2",expectedErrors:["CS0136","CS0136"],expectedWarnings:["CS0219","CS0219","CS0219","CS0219","CS0219","CS0219"]} --> However, the repeated CS0219 is a message having the form, “The variable 'i' is assigned but its value is never used”. As this is not useful to see or to check for in this context, this kind of warning clutters up the process. The One approach we might use to support this is to provide new metadata, something like the following: <!-- Example: { … ,excludedWarnings:["CS0219", …] … } --> which gets turned into the corresponding Jon: rather than using 2022-10-27: Problem solved by PR #651, by the addition of The following warnings have been ignored in all metadata as of 2022-10-27: CS0168 -- The variable 'var' is declared but never used |
Problem with Ellipses ReplacementThe metadata class Gen<T,U>
{
public T[,] a;
public void G(int i, T t, Gen<U,T> gt) {/*...*/} // OK, void method
public U Prop { get {/*...*/} set {/*...*/} } // CS0161, getter; setter OK
public int H(double d) {/*...*/} // CS0161, non-void method
} The metadata for such examples is marked Separately, one example contained the following: [Help("http://www.mycompany.com/.../Class1.htm")] The ellipses was changed to something like “xxx”. 2022-11-09: Jon resolved this in PR #665. |
Example Containing Chevron QuotesWe use chevron-quotes («…») to allow grammar-rule (and other) names inside a code block. For example: {
ResourceType resource = «expression»;
IDisposable d = resource;
try
{
«statement»;
}
finally
{
if (d != null)
{
d.Dispose();
}
}
} Obviously, these examples won’t compile. As such, they do not currently have any metadata. As a result of #646 (comment), chevron delimiters are now removed from extracted source. For the examples in question, each grammar-rule name is a well-formed identifier, which the compiler will see as being undeclared. As such, these examples are not intended to be compiled. No action needed. |
Passing Command-Line Arguments to MainSeveral examples process command-line argument strings, if they exist. However, one example (Indexers2 in classes.md) expects such an array of at least one element, and throws an exception when that is not passed. 2023-12-14: Jon resolved this in PR #736. |
Errors Hiding Other ErrorsExample UsingAliasDirectives13 in namespaces.md contains the following lines (where 9-15 are the corresponding source line numbers): namespace N1
{
class A<T>
{
class B {}
}
}
9 namespace N2
10{
11 using W = N1.A; // Error, cannot name unbound generic type
12 using X = N1.A.B; // Error, cannot name unbound generic type
13 using Y = N1.A<int>; // Ok, can name closed constructed type
14 using Z<T> = N1.A<T>; // Error, using alias cannot have type parameters
15} When compiled, we get Library.cs(14,16): error CS1002: ; expected
Library.cs(14,24): error CS0116: A namespace cannot directly contain members such as fields, methods or statements
Library.cs(14,16): error CS1022: Type or namespace definition, or end-of-file expected
Library.cs(14,25): error CS1022: Type or namespace definition, or end-of-file expected However, when the offending line 14 is commented-out, we get Library.cs(11,18): error CS0305: Using the generic type 'A<T>' requires 1 type arguments
Library.cs(12,18): error CS0305: Using the generic type 'A<T>' requires 1 type arguments So, the error on line 14 hides the detection/reporting of the errors on lines 11 and 12. This means, we’d need to state the first 4 errors in No action needed! |
Expected Documentation Comments Generated XMLThe csc option |
Examples Not Marked for ExtractionThese examples are mostly isolated code fragments, contain superscripts or subscripts, or for some other reason, did not warrant trying to make them complete. No action required. |
Only the name (without the namespace) is specified; the FQN could be quite long-winded in the metadata. Towards dotnet#646.
This will allow for examples which are just statements. (Also adds example in 16.1 Arrays to show how to use it.) Towards #646
Using Program Console Output in SpecThe output from some examples is shown in the spec using the following construct:
It would be better to use that for checking instead of having an 2022-11-01: Jon added this capability via the |
External ReferenceMetadata: The example contains I got a version to work outside the test framework. For example, for test "UsingAliasDirectives3" in namepsaces.md
2023-01-16: Notes from Jon: We don't compile using csc directly, but with project files, so we'd need to work out what these look like in project files. Extern aliases are more complex than I thought, though given that:
This is going to be tricky - and possibly even more complex than is worthwhile. 2023-01: Jon resolved this by adding the template |
Update 2024-03-27:
I'll create a PR to see what I can do with these. |
We're now down to 6 instances of Incomplete$Example, all of which would be really fiddly to fix. I propose we standard on a single comment format, e.g. "UntestedExample: (reason)", update all the remaining ones, and close this issue. |
@jon I agree that we can/should close this issue even though not all issues have been resolved. Here are the results of my research earlier today:
|
4 - that's what #1062 is about. 5 - no, they can't be resolved easily. I'm happy for them to be changed to Incomplete$Example. |
(I note that I had originally written a larger explanation of the remaining incomplete examples etc - somehow I managed to lose that comment.) |
@jon I just updated this issue to reflect that we are done with it, and I have ticked all the remaining boxes. Now, I'll create a PR with the corresponding edits to the examples, and once you have approved/merged that, you can close this issue. |
To add your input to the discussion of any category in this issue, do NOT create a new comment; instead, locate the discussion thread comment for that category and add your contribution to the end using the “edit” option.
The ExampleExtractor tool extracts source code for individual examples based on the metadata in an HTML comment that precedes each example’s code block. (If an example has no such comment, or the initial comment metadata is not recognized, that example’s code is not extracted.)
While most examples have metadata that allows them to be extracted, compiled, and optionally executed, without error, some cannot yet be handled completely by the extraction and testing tools. This issue tracks the status of the different categories of support currently provided by, or needed from, the tool. Once support for a category has been provided, that category’s checkbox should be checked.
Issues relating to specific metadata categories are addressed under Categories. General issues are addressed under General Issues and Observations.
Categories
Each category shows the number of occurrences of examples of that category in all md files as of February 14, 2023.
General Issues and Observations
Some issues transcend categories:
Main
The text was updated successfully, but these errors were encountered: