Skip to content

Commit 017a1b7

Browse files
authored
revise example metadata (#713)
1 parent c536a34 commit 017a1b7

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

standard/structs.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ A variable of a struct type directly contains the data of the struct, whereas a
138138

139139
> *Example*:
140140
>
141-
> <!-- Example: {template:"standalone-lib", name:"ValueSemantics1", expectedErrors:["CS0523"], ignoredWarnings:["CS0169"]} -->
141+
> <!-- Example: {template:"standalone-lib-without-using", name:"ValueSemantics1", expectedErrors:["CS0523"], ignoredWarnings:["CS0169"]} -->
142142
> ```csharp
143143
> struct Node
144144
> {
@@ -149,7 +149,7 @@ A variable of a struct type directly contains the data of the struct, whereas a
149149
>
150150
> is an error because `Node` contains an instance field of its own type. Another example
151151
>
152-
> <!-- Example: {template:"standalone-lib", name:"ValueSemantics2", expectedErrors:["CS0523","CS0523","CS0523"], ignoredWarnings:["CS0169"]} -->
152+
> <!-- Example: {template:"standalone-lib-without-using", name:"ValueSemantics2", expectedErrors:["CS0523","CS0523","CS0523"], ignoredWarnings:["CS0169"]} -->
153153
> ```csharp
154154
> struct A { B b; }
155155
> struct B { C c; }
@@ -188,7 +188,7 @@ With classes, it is possible for two variables to reference the same object, and
188188
> Point a = new Point(10, 10);
189189
> Point b = a;
190190
> a.x = 100;
191-
> System.Console.WriteLine(b.x);
191+
> Console.WriteLine(b.x);
192192
> }
193193
> }
194194
> ```
@@ -221,7 +221,7 @@ As described in [§9.3](variables.md#93-default-values), several kinds of variab
221221

222222
> *Example*: Referring to the `Point` struct declared above, the example
223223
>
224-
> <!-- IncompleteExample: {template:"standalone-lib", name:"DefaultValues1", expectedErrors:["x","x"], expectedWarnings:["x","x"]} -->
224+
> <!-- Example: {template:"code-in-main-without-using", name:"DefaultValues1", additionalFiles:["Point.cs"]} -->
225225
> ```csharp
226226
> Point[] a = new Point[100];
227227
> ```
@@ -236,7 +236,6 @@ The default value of a struct corresponds to the value returned by the default c
236236
>
237237
> <!-- Example: {template:"standalone-lib", name:"DefaultValues2", ignoredWarnings:["CS0649"]} -->
238238
> ```csharp
239-
> using System;
240239
> struct KeyValuePair
241240
> {
242241
> string key;
@@ -277,7 +276,6 @@ The meaning of `this` in a struct differs from the meaning of `this` in a class,
277276
>
278277
> <!-- Example: {template:"standalone-console", name:"MeaningOfThis1", inferOutput:true} -->
279278
> ```csharp
280-
> using System;
281279
> struct Counter
282280
> {
283281
> int value;
@@ -320,8 +318,6 @@ Similarly, boxing never implicitly occurs when accessing a member on a constrain
320318
>
321319
> <!-- Example: {template:"standalone-console", name:"MeaningOfThis2", inferOutput:true} -->
322320
> ```csharp
323-
> using System;
324-
>
325321
> interface ICounter
326322
> {
327323
> void Increment();
@@ -368,7 +364,7 @@ As described in [§15.4.5](structs.md#1545-default-values), the default value of
368364

369365
> *Example*: The following
370366
>
371-
> <!-- Example: {template:"standalone-lib", name:"FieldInitializers", expectedErrors:["CS8983"], ignoredWarnings:["CS0649"]} -->
367+
> <!-- Example: {template:"standalone-lib-without-using", name:"FieldInitializers", expectedErrors:["CS8983"], ignoredWarnings:["CS0649"]} -->
372368
> ```csharp
373369
> struct Point
374370
> {
@@ -387,7 +383,7 @@ Unlike a class, a struct is not permitted to declare a parameterless instance co
387383

388384
> *Example*: Given the following
389385
>
390-
> <!-- Example: {template:"standalone-console", name:"Constructors1", ignoredWarnings:["CS0219"]} -->
386+
> <!-- Example: {template:"standalone-console-without-using", name:"Constructors1", ignoredWarnings:["CS0219"]} -->
391387
> ```csharp
392388
> struct Point
393389
> {
@@ -422,7 +418,7 @@ If the struct instance constructor specifies a constructor initializer, that ini
422418

423419
> *Example*: Consider the instance constructor implementation below:
424420
>
425-
> <!-- Example: {template:"standalone-lib", name:"Constructors2", expectedErrors:["CS0188"]} -->
421+
> <!-- Example: {template:"standalone-lib-without-using", name:"Constructors2", expectedErrors:["CS0188"]} -->
426422
> ```csharp
427423
> struct Point
428424
> {
@@ -449,7 +445,7 @@ If the struct instance constructor specifies a constructor initializer, that ini
449445
> No instance function member (including the set accessors for the properties `X` and `Y`) can be called until all fields of the struct being constructed have been definitely assigned. Note, however, that if `Point` were a class instead of a struct, the instance constructor implementation would be permitted.
450446
> There is one exception to this, and that involves automatically implemented properties ([§14.7.4](classes.md#1474-automatically-implemented-properties)). The definite assignment rules ([§11.19.2](expressions.md#11192-simple-assignment)) specifically exempt assignment to an auto-property of a struct type within an instance constructor of that struct type: such an assignment is considered a definite assignment of the hidden backing field of the auto-property. Thus, the following is allowed:
451447
>
452-
> <!-- Example: {template:"standalone-lib", name:"Constructors3"} -->
448+
> <!-- Example: {template:"standalone-lib-without-using", name:"Constructors3"} -->
453449
> ```csharp
454450
> struct Point
455451
> {

0 commit comments

Comments
 (0)