Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions standard/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,8 @@ When an optional parameter is annotated with one of the caller-info attributes,

> *Example*:
>
> <!-- Example: {template:"code-in-class-lib", name:"Caller-infoAttributes"} -->
> <!-- Example: {template:"code-in-class-lib", name:"CallerInfoAttributes"} -->
> ```csharp
> ...
>
> public void Log(
> [CallerLineNumber] int line = -1,
> [CallerFilePath] string path = null,
Expand Down Expand Up @@ -852,7 +850,7 @@ For interoperation with other languages, an indexer may be implemented using ind

> *Example*: By default, an indexer’s name is `Item`. This can be overridden, as follows:
>
> <!-- Example: {template:"code-in-class-lib", name:"AttributesForInteroperation", replaceEllipsis:true, customEllipsisReplacements: ["return 0;", ""]} -->
> <!-- Example: {template:"code-in-class-lib", name:"AttributesForInteroperation", replaceEllipsis:true, customEllipsisReplacements:["return 0;",""]} -->
> ```csharp
> [System.Runtime.CompilerServices.IndexerName("TheItem")]
> public int this[int index]
Expand Down
4 changes: 2 additions & 2 deletions standard/basic-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ The behavior of the garbage collector can be controlled, to some degree, via sta

> *Example*: Since the garbage collector is allowed wide latitude in deciding when to collect objects and run finalizers, a conforming implementation might produce output that differs from that shown by the following code. The program
>
> <!-- Example: {template:"standalone-console",name:"MemoryManagement1", ignoreOutput:true} -->
> <!-- Example: {template:"standalone-console", name:"MemoryManagement1", ignoreOutput:true} -->
> <!-- Maintenance Note: The behavior of this example is implementation-defined. As such, the metadata does *not* compare test output with any ```console block. -->
> ```csharp
> class A
Expand Down Expand Up @@ -1023,7 +1023,7 @@ The behavior of the garbage collector can be controlled, to some degree, via sta
>
> In subtle cases, the distinction between “eligible for finalization” and “eligible for collection” can be important. For example,
>
> <!-- Example: {template:"standalone-console",name:"MemoryManagement2", ignoreOutput:true} -->
> <!-- Example: {template:"standalone-console", name:"MemoryManagement2", ignoreOutput:true} -->
> <!-- Maintenance Note: The behavior of this example is implementation-defined. As such, the metadata does *not* compare test output with any ```console block. -->
> ```csharp
> class A
Expand Down
22 changes: 11 additions & 11 deletions standard/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ Nested types can be declared in multiple parts by using the `partial` modifier.
>
> When the two parts above are compiled together, the resulting code behaves as if the class had been written as a single unit, as follows:
>
> <!-- Example: {template:"standalone-lib-without-using", name:"PartialDeclarations2", replaceEllipsis:true, additionalFiles:["Order.cs"], expectedWarnings:["CS0169","CS0169","CS0169","CS0649"]} -->
> <!-- Example: {template:"standalone-lib-without-using", name:"PartialDeclarations2", replaceEllipsis:true, expectedWarnings:["CS0169","CS0169","CS0169","CS0649"], additionalFiles:["Order.cs"]} -->
> ```csharp
> public class Customer
> {
Expand Down Expand Up @@ -837,7 +837,7 @@ The non-inherited members of a constructed type are obtained by substituting, fo

> *Example*: Given the generic class declaration
>
> <!-- Example: {template:"standalone-lib-without-using", name:"MembersOfConstructedTypes", replaceEllipsis:true, customEllipsisReplacements: [null, "return default;", null, "return 0;"], expectedWarnings:["CS0649"]} -->
> <!-- Example: {template:"standalone-lib-without-using", name:"MembersOfConstructedTypes", replaceEllipsis:true, customEllipsisReplacements:[null,"return default;",null,"return 0;"], expectedWarnings:["CS0649"]} -->
> ```csharp
> class Gen<T,U>
> {
Expand Down Expand Up @@ -3308,8 +3308,8 @@ Unlike public fields, properties provide a separation between an object’s inte
> this.caption = caption;
> }
>
> public int X => location.x;
> public int Y => location.y;
> public int X => location.X;
> public int Y => location.Y;
> public Point Location => location;
> public string Caption => caption;
> }
Expand Down Expand Up @@ -3774,7 +3774,7 @@ In an operation of the form `x += y` or `x –= y`, when `x` is an event the

> *Example*: The following example shows how event handlers are attached to instances of the `Button` class:
>
> <!-- Example: {template:"standalone-lib-without-using", name:"Events", replaceEllipsis:true, additionalFiles:["Control.cs","Graphics.cs","Rectangle.cs","Point.cs","Form.cs"], expectedWarnings:["CS0067"]} -->
> <!-- Example: {template:"standalone-lib-without-using", name:"Events", replaceEllipsis:true, expectedWarnings:["CS0067"], additionalFiles:["Control.cs","Graphics.cs","Rectangle.cs","Point.cs","Form.cs"]} -->
> ```csharp
> public delegate void EventHandler(object sender, EventArgs e);
>
Expand Down Expand Up @@ -3861,7 +3861,7 @@ When compiling a field-like event, the compiler automatically creates storage to

> *Note*: Thus, an instance event declaration of the form:
>
> <!-- Example: {template:"standalone-lib-without-using", name:"FieldlikeEvents2", additionalFiles:["D.cs"], expectedWarnings:["CS0067"]} -->
> <!-- Example: {template:"standalone-lib-without-using", name:"FieldlikeEvents2", expectedWarnings:["CS0067"], additionalFiles:["D.cs"]} -->
> ```csharp
> class X
> {
Expand All @@ -3871,7 +3871,7 @@ When compiling a field-like event, the compiler automatically creates storage to
>
> shall be compiled to something equivalent to:
>
> <!-- Example: {template:"standalone-lib-without-using", name:"FieldlikeEvents3", additionalFiles:["D.cs"], expectedWarnings:["CS0169"]} -->
> <!-- Example: {template:"standalone-lib-without-using", name:"FieldlikeEvents3", expectedWarnings:["CS0169"], additionalFiles:["D.cs"]} -->
> ```csharp
> class X
> {
Expand Down Expand Up @@ -4296,7 +4296,7 @@ The `true` and `false` unary operators require pair-wise declaration. A compile-

> *Example*: The following example shows an implementation and subsequent usage of operator++ for an integer vector class:
>
> <!-- Example: {template:"standalone-console-without-using", name:"UnaryOperators", replaceEllipsis:true, customEllipsisReplacements:[null,"get { return 0; }","get { return 0; } set {}"]} -->
> <!-- Example: {template:"standalone-console-without-using", name:"UnaryOperators", replaceEllipsis:true, customEllipsisReplacements:[null,"return 0;","return 0;",null]} -->
> ```csharp
> public class IntVector
> {
Expand Down Expand Up @@ -4393,7 +4393,7 @@ It is not possible to directly redefine a pre-defined conversion. Thus, conversi

> *Example*:
>
> <!-- Example: {template:"standalone-lib-without-using", name:"ConversionOperators2", replaceEllipsis:true, customEllipsisReplacements:["return default;", "return default;"]} -->
> <!-- Example: {template:"standalone-lib-without-using", name:"ConversionOperators2", replaceEllipsis:true, customEllipsisReplacements:["return default;","return default;"]} -->
> ```csharp
> struct Convertible<T>
> {
Expand All @@ -4417,7 +4417,7 @@ For all types but `object`, the operators declared by the `Convertible<T>` type

> *Example*:
>
> <!-- Example: {template:"standalone-console-without-using", name:"ConversionOperators3", additionalFiles:["ConvertibleT.cs"], expectedErrors:["CS0266"], expectedWarnings:["CS8321"]} -->
> <!-- Example: {template:"standalone-console-without-using", name:"ConversionOperators3", expectedErrors:["CS0266"], expectedWarnings:["CS8321"], additionalFiles:["ConvertibleT.cs"]} -->
> ```csharp
> void F(int i, Convertible<int> n)
> {
Expand All @@ -4430,7 +4430,7 @@ For all types but `object`, the operators declared by the `Convertible<T>` type
>
> However, for type `object`, pre-defined conversions hide the user-defined conversions in all cases but one:
>
> <!-- Example: {template:"standalone-console-without-using", name:"ConversionOperators4", additionalFiles:["ConvertibleT.cs"], expectedWarnings:["CS8321"]} -->
> <!-- Example: {template:"standalone-console-without-using", name:"ConversionOperators4", expectedWarnings:["CS8321"], additionalFiles:["ConvertibleT.cs"]} -->
> ```csharp
> void F(object o, Convertible<object> n)
> {
Expand Down
8 changes: 4 additions & 4 deletions standard/conversions.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ If dynamic binding of the conversion is not desired, the expression can be first
>
> The following illustrates explicit dynamic conversions:
>
> <!-- Example: {template:"standalone-console-without-using", name:"ExplicitDynamic2", additionalFiles:["CForConversions.cs"], expectedException:"InvalidCastException"} -->
> <!-- Example: {template:"standalone-console-without-using", name:"ExplicitDynamic2", expectedException:"InvalidCastException", additionalFiles:["CForConversions.cs"]} -->
> ```csharp
> object o = "1";
> dynamic d = "2";
Expand Down Expand Up @@ -808,7 +808,7 @@ Specifically, an anonymous function `F` is compatible with a delegate type `D`
>
> In the assignments
>
> <!-- Example: {template:"standalone-console-without-using", name:"AnonymousFunctionsConv3", additionalFiles:["R.cs"], expectedErrors:["CS0266","CS1662"], expectedWarnings:["CS1998"]} -->
> <!-- Example: {template:"standalone-console-without-using", name:"AnonymousFunctionsConv3", expectedErrors:["CS0266","CS1662"], expectedWarnings:["CS1998"], additionalFiles:["R.cs"]} -->
> ```csharp
> Func<int,int> f1 = x => x + 1; // Ok
> Func<int,double> f2 = x => x + 1; // Ok
Expand Down Expand Up @@ -900,7 +900,7 @@ The compile-time application of the conversion from a method group `E` to a del

> *Example*: The following demonstrates method group conversions:
>
> <!-- Example: {template:"standalone-lib-without-using", name:"MethodGroupConversions1", replaceEllipsis:true, customEllipsisReplacements: ["return null;"], expectedErrors:["CS0123","CS0123","CS0123"]} -->
> <!-- Example: {template:"standalone-lib-without-using", name:"MethodGroupConversions1", replaceEllipsis:true, customEllipsisReplacements:["return null;"], expectedErrors:["CS0123","CS0123","CS0123"]} -->
> ```csharp
> delegate string D1(object o);
> delegate object D2(string s);
Expand Down Expand Up @@ -954,7 +954,7 @@ A method group conversion can refer to a generic method, either by explicitly sp

> *Example*:
>
> <!-- Example: {template:"standalone-console-without-using", name:"MethodGroupConversions2", replaceEllipsis:true, customEllipsisReplacements: ["return default;", "return default;"], expectedErrors:["CS0411"]} -->
> <!-- Example: {template:"standalone-console-without-using", name:"MethodGroupConversions2", replaceEllipsis:true, customEllipsisReplacements:["return default;","return default;"], expectedErrors:["CS0411"]} -->
> ```csharp
> delegate int D(string s, int i);
> delegate int E();
Expand Down
4 changes: 2 additions & 2 deletions standard/delegates.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ This definition of consistency allows covariance in return type and contravarian

> *Example*:
>
> <!-- Example: {template:"standalone-lib-without-using", name:"DelegateCompatibility1", replaceEllipsis:true, customEllipsisReplacements: ["return default;", "return default;", "return;", "return default;", "return;", "return default;", "return default;"]} -->
> <!-- Example: {template:"standalone-lib-without-using", name:"DelegateCompatibility1", replaceEllipsis:true, customEllipsisReplacements:["return default;","return default;","return;","return default;","return;","return default;","return default;"]} -->
> ```csharp
> delegate int D1(int i, double d);
> delegate int D2(int c, double d);
Expand Down Expand Up @@ -122,7 +122,7 @@ This definition of consistency allows covariance in return type and contravarian
<!-- markdownlint-enable MD028 -->
> *Example*:
>
> <!-- Example: {template:"standalone-lib-without-using", name:"DelegateCompatibility2", replaceEllipsis:true, customEllipsisReplacements: ["return default;", "return default;"] } -->
> <!-- Example: {template:"standalone-lib-without-using", name:"DelegateCompatibility2", replaceEllipsis:true, customEllipsisReplacements:["return default;","return default;"]} -->
> ```csharp
> delegate bool Predicate<T>(T value);
>
Expand Down
8 changes: 4 additions & 4 deletions standard/documentation-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ This tag is used to set one or more lines of source code or program output in so

**Example:**

<!-- Example: {template:"standalone-lib-without-using", name:"TagCode", ignoredWarnings:["CS1591"], replaceEllipsis:true} -->
<!-- Example: {template:"standalone-lib-without-using", name:"TagCode", replaceEllipsis:true, ignoredWarnings:["CS1591"]} -->
```csharp
public class Point
{
Expand Down Expand Up @@ -167,7 +167,7 @@ where

**Example:**

<!-- Example: {template:"standalone-lib-without-using", name:"TagException", ignoredWarnings:["CS1591"], replaceEllipsis:true} -->
<!-- Example: {template:"standalone-lib-without-using", name:"TagException", replaceEllipsis:true, ignoredWarnings:["CS1591"]} -->
```csharp
class MasterFileFormatCorruptException : System.Exception { ... }
class MasterFileLockedOpenException : System.Exception { ... }
Expand Down Expand Up @@ -894,7 +894,7 @@ IDs:

**Properties and indexers**

<!-- Example: {template:"standalone-lib-without-using", name:"IDStringsPropertiesAndIndexers", replaceEllipsis:true, customEllipsisReplacements: ["return default;", "return;","return default;", "return;","return default;", "return;"], additionalFiles:["IProcess.cs"]} -->
<!-- Example: {template:"standalone-lib-without-using", name:"IDStringsPropertiesAndIndexers", replaceEllipsis:true, customEllipsisReplacements:["return default;","return;","return default;","return;","return default;","return;"], additionalFiles:["IProcess.cs"]} -->
```csharp
namespace Acme
{
Expand Down Expand Up @@ -936,7 +936,7 @@ IDs:

**Unary operators**

<!-- Example: {template:"standalone-lib-without-using", name:"IDStringsUnaryOps", replaceEllipsis:true, customEllipsisReplacements: ["return default;"], additionalFiles:["IProcess.cs"]} -->
<!-- Example: {template:"standalone-lib-without-using", name:"IDStringsUnaryOps", replaceEllipsis:true, customEllipsisReplacements:["return default;"], additionalFiles:["IProcess.cs"]} -->
```csharp
namespace Acme
{
Expand Down
18 changes: 9 additions & 9 deletions standard/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2201,7 +2201,7 @@ When an initializer target refers to an indexer, the arguments to the indexer sh
>
> An instance of `Rectangle` can be created and initialized as follows:
>
> <!-- Example: {template:"code-in-main-without-using", name:"ObjectInitializers2User", additionalFiles:["PointWithAutoProps.cs", "Rectangle.cs"]} -->
> <!-- Example: {template:"code-in-main-without-using", name:"ObjectInitializers2User", additionalFiles:["PointWithAutoProps.cs","Rectangle.cs"]} -->
> ```csharp
> Rectangle r = new Rectangle
> {
Expand All @@ -2212,7 +2212,7 @@ When an initializer target refers to an indexer, the arguments to the indexer sh
>
> This has the same effect as
>
> <!-- Example: {template:"code-in-main-without-using", name:"ObjectInitializers2UserB", additionalFiles:["PointWithAutoProps.cs", "Rectangle.cs"]} -->
> <!-- Example: {template:"code-in-main-without-using", name:"ObjectInitializers2UserB", additionalFiles:["PointWithAutoProps.cs","Rectangle.cs"]} -->
> ```csharp
> Rectangle __r = new Rectangle();
> Point __p1 = new Point();
Expand Down Expand Up @@ -2241,7 +2241,7 @@ When an initializer target refers to an indexer, the arguments to the indexer sh
>
> the following construct can be used to initialize the embedded `Point` instances instead of assigning new instances:
>
> <!-- Example: {template:"code-in-main-without-using", name:"ObjectInitializers3User", additionalFiles:["PointWithAutoProps.cs", "RectangleWithConstructorPointAllocation.cs"]} -->
> <!-- Example: {template:"code-in-main-without-using", name:"ObjectInitializers3User", additionalFiles:["PointWithAutoProps.cs","RectangleWithConstructorPointAllocation.cs"]} -->
> ```csharp
> Rectangle r = new Rectangle
> {
Expand All @@ -2252,7 +2252,7 @@ When an initializer target refers to an indexer, the arguments to the indexer sh
>
> This has the same effect as
>
> <!-- Example: {template:"code-in-main-without-using", name:"ObjectInitializers3UserB", additionalFiles:["PointWithAutoProps.cs", "RectangleWithConstructorPointAllocation.cs"]} -->
> <!-- Example: {template:"code-in-main-without-using", name:"ObjectInitializers3UserB", additionalFiles:["PointWithAutoProps.cs","RectangleWithConstructorPointAllocation.cs"]} -->
> ```csharp
> Rectangle __r = new Rectangle();
> __r.P1.X = 0;
Expand Down Expand Up @@ -4548,7 +4548,7 @@ Anonymous functions in an argument list participate in type inference and overlo
>
> The `Sum` methods could for example be used to compute sums from a list of detail lines in an order.
>
> <!-- Example: {template:"standalone-lib-without-using", name:"OverloadResolution2", replaceEllipsis:true, customEllipsisReplacements:["", "", "", "", "return default;"], ignoredWarnings:["CS0649"], additionalFiles:["ItemListT.cs"]} -->
> <!-- Example: {template:"standalone-lib-without-using", name:"OverloadResolution2", replaceEllipsis:true, customEllipsisReplacements:["","","","","return default;"], ignoredWarnings:["CS0649"], additionalFiles:["ItemListT.cs"]} -->
> ```csharp
> class Detail
> {
Expand Down Expand Up @@ -4708,7 +4708,7 @@ When not captured, there is no way to observe exactly how often a local variable
>
> However, when the declaration of `x` is moved outside the loop:
>
> <!-- Example: {template:"standalone-console", name:"InstantiationOfLocalVariables4", inferOutput: true} -->
> <!-- Example: {template:"standalone-console", name:"InstantiationOfLocalVariables4", inferOutput:true} -->
> ```csharp
> delegate void D();
>
Expand Down Expand Up @@ -4752,7 +4752,7 @@ If a for-loop declares an iteration variable, that variable itself is considered

> *Example*: Thus, if the example is changed to capture the iteration variable itself:
>
> <!-- Example: {template:"standalone-console", name:"InstantiationOfLocalVariables5", inferOutput: true} -->
> <!-- Example: {template:"standalone-console", name:"InstantiationOfLocalVariables5", inferOutput:true} -->
> ```csharp
> delegate void D();
>
Expand Down Expand Up @@ -4792,7 +4792,7 @@ It is possible for anonymous function delegates to share some captured variables

> *Example*: For example, if `F` is changed to
>
> <!-- Example: {template:"code-in-partial-class", name:"InstantiationOfLocalVariables6", IgnoredWarnings:["CS8321"], additionalFiles:["Caller.cs"], inferOutput: true} -->
> <!-- Example: {template:"code-in-partial-class", name:"InstantiationOfLocalVariables6", ignoredWarnings:["CS8321"], inferOutput:true, additionalFiles:["Caller.cs"]} -->
> ```csharp
> static D[] F()
> {
Expand Down Expand Up @@ -5971,7 +5971,7 @@ When a property or indexer declared in a *struct_type* is the target of an assig
>
> the assignments to `p.X`, `p.Y`, `r.A`, and `r.B` are permitted because `p` and `r` are variables. However, in the example
>
> <!-- Example: {template:"standalone-console", name:"SimpleAssignment4", additionalFiles:["PointStruct.cs","RectangleStruct.cs"], expectedErrors:["CS1612","CS1612","CS1612","CS1612"]} -->
> <!-- Example: {template:"standalone-console", name:"SimpleAssignment4", expectedErrors:["CS1612","CS1612","CS1612","CS1612"], additionalFiles:["PointStruct.cs","RectangleStruct.cs"]} -->
> ```csharp
> Rectangle r = new Rectangle();
> r.A.X = 10;
Expand Down
Loading