@@ -138,8 +138,7 @@ An error occurs if a program declares an extern alias for which no external defi
138
138
139
139
> *Example *: The following program declares and uses two extern aliases , `X ` and `Y `, each of which represent the root of a distinct namespace hierarchy :
140
140
>
141
- > <!-- ExternalRef $Example : {template:"standalone-lib-without-using ", name :"ExternAliasDirectives ", expectedErrors :["x ","x "], expectedWarnings :["x ","x "]} -->
142
- > <!-- FIX : I got this to work outside the test framework . 1. The external definitions are in files ExternAliasX .cs and ExternAliasY .cs in the additional -files folder . 2. We need a DLL for each of these compiled using csc ExternAliasX .cs -t :library and csc ExternAliasY .cs -t :library 3. The Library .cs file needs to be compiled using csc Library .cs -t :library -r :X = ExternAliasX .dll -r :Y = ExternAliasY .dll , where the two references must include the path to the DLLs . -->
141
+ > <!-- Example : {template:"extern -lib", name:"ExternAliasDirectives", project:"ExampleProject"} -->
143
142
> ```csharp
144
143
> extern alias X;
145
144
> extern alias Y;
@@ -224,9 +223,7 @@ Within using directives, global attributes and member declarations in a compilat
224
223
225
224
> *Example *: For example :
226
225
>
227
- > <!-- ExternalRef $Example : {template :"standalone -lib -without -using ", name :"UsingAliasDirectives3 ", expectedErrors :["x ","x "], expectedWarnings :["x ","x "]} -->
228
- > <!-- FIX : I got this to work outside the test framework . 1. The external definition is in file ExternAliasN2 .cs in the additional -files folder . 2. We need a DLL for this compiled using csc ExternAliasN2 .cs -t :library 3. The Library .cs file needs to be compiled using csc Library .cs -t :library -r :X = ExternAliasN2 .dll , where the reference must include the path to the DLL . -->
229
- > <!-- IncompleteExample : {template :"standalone -lib ", name :"UsingAliasDirectives3 ", expectedErrors :["x ","x "], expectedWarnings :["x ","x "]} -->
226
+ > <!-- Example : {template :"extern -lib ", name :"UsingAliasDirectives3 ", project :"ExampleProject "} -->
230
227
> ```csharp
231
228
> namespace N1
232
229
> {
@@ -238,8 +235,7 @@ Within using directives, global attributes and member declarations in a compilat
238
235
>
239
236
> Above , within member declarations in the `N1 ` namespace , `N2 ` is an alias for some namespace whose definition is external to the source code of the program . Class `N1 .B ` derives from class `N2 .A `. The same effect can be obtained by creating an alias `A ` for `N2 .A ` and then referencing `A `:
240
237
>
241
- > <!-- ExternalRef $Example : {template:"standalone-lib-without-using ", name :"UsingAliasDirectives4 ", expectedErrors :["x ","x "], expectedWarnings :["x ","x "]} -->
242
- > <!-- FIX : I got this to work outside the test framework . 1. The external definition is in file ExternAliasN2 .cs in the additional -files folder . 2. We need a DLL for this compiled using csc ExternAliasN2 .cs -t :library 3. The Library .cs file needs to be compiled using csc Library .cs -t :library -r :X = ExternAliasN2 .dll , where the reference must include the path to the DLL . -->
238
+ > < ! -- Example : {template : " extern-lib" , name : " UsingAliasDirectives4" , project : " ExampleProject" } -- >
243
239
> ```csharp
244
240
> namespace N1
245
241
> {
@@ -257,8 +253,7 @@ An *extern_alias_directive* or *using_alias_directive* makes an alias available
257
253
258
254
> *Example *: In the following code
259
255
>
260
- > <!-- ExternalRef $Example : {template:"standalone-lib-without-using ", name :"UsingAliasDirectives5 ", expectedErrors :["x ","x "], expectedWarnings :["x ","x "]} -->
261
- > <!-- FIX : I got this to work outside the test framework . 1. The external definition is in file ExternAliasR1 .cs in the additional -files folder . 2. We need a DLL for this compiled using csc ExternAliasR1 .cs -t :library 3. The Library .cs file needs to be compiled using csc Library .cs N1N2 .cs -t :library -r :X = ExternAliasR1 .dll , where the reference must include the path to the DLL . -->
256
+ > <!-- Example : {template:"extern -lib", name:"UsingAliasDirectives5", project:"ExampleProject", expectedErrors:["CS0246 ","CS0432 "], additionalFiles:["N1N2 .cs "]} -- >
262
257
> ```csharp
263
258
> namespace N3
264
259
> {
@@ -275,8 +270,7 @@ An *extern_alias_directive* or *using_alias_directive* makes an alias available
275
270
>
276
271
> the scopes of the alias directives that introduce `R1 ` and `R2 ` only extend to member declarations in the namespace body in which they are contained , so `R1 ` and `R2 ` are unknown in the second namespace declaration . However , placing the alias directives in the containing compilation unit causes the alias to become available within both namespace declarations :
277
272
>
278
- > <!-- ExternalRef $Example : {template:"standalone-lib-without-using ", name :"UsingAliasDirectives6 ", expectedErrors :["x ","x "], expectedWarnings :["x ","x "]} -->
279
- > <!-- FIX : I got this to work outside the test framework . 1. The external definition is in file ExternAliasR1 .cs in the additional -files folder . 2. We need a DLL for this compiled using csc ExternAliasR1 .cs -t :library 3. The Library .cs file needs to be compiled using csc Library .cs N1N2 .cs -t :library -r :X = ExternAliasR1 .dll , where the reference must include the path to the DLL . -->
273
+ > <!-- Example : {template:"extern -lib", name:"UsingAliasDirectives6", project:"ExampleProject", additionalFiles:["N1N2 .cs "]} -- >
280
274
> ```csharp
281
275
> extern alias R1 ;
282
276
>
@@ -299,18 +293,17 @@ Each *extern_alias_directive* or *using_alias_directive* in a *compilation_unit*
299
293
300
294
> * Example * :
301
295
>
302
- > <!-- ExternalRef$Example: {template:"standalone-lib-without-using ", name :"UsingAliasDirectives7 ", expectedErrors :["x ","x "], expectedWarnings :["x ","x "]} -->
303
- > <!-- FIX : I got this to work outside the test framework . 1. The external definitions are in files ExternAliasA .cs and ExternAliasB .cs in the additional -files folder . 2. We need a DLL for each of these compiled using csc ExternAliasA .cs -t :library and csc ExternAliasB .cs -t :library 3. The Library .cs file needs to be compiled using csc Library .cs N1N2 .cs -t :library -r :X = ExternAliasA .dll -r :Y = ExternAliasB .dll , where the two references must include the path to the DLLs . -->
296
+ > < ! -- Example : {template : " extern-lib" , name : " UsingAliasDirectives7" , project : " ExampleProject" , expectedErrors : [" CS1537" ], additionalFiles : [" N1N2.cs" ]} -- >
304
297
> ```csharp
305
- > extern alias A ;
306
- > extern alias B ;
298
+ > extern alias X ;
299
+ > extern alias Y ;
307
300
>
308
- > using A = N1 .N2 ; // Error: alias A already exists
301
+ > using X = N1 .N2 ; // Error: alias X already exists
309
302
>
310
- > class B {} // Ok
303
+ > class Y {} // Ok
311
304
> ```
312
305
>
313
- > The using alias named `A ` causes an error since there is already an alias named `A ` in the same compilation unit . The class named `B ` does not conflict with the extern alias named `B ` since these names are added to distinct declaration spaces . The former is added to the global declaration space and the latter is added to the alias declaration space for this compilation unit .
306
+ > The using alias named `X ` causes an error since there is already an alias named `X ` in the same compilation unit . The class named `Y ` does not conflict with the extern alias named `Y ` since these names are added to distinct declaration spaces . The former is added to the global declaration space and the latter is added to the alias declaration space for this compilation unit .
314
307
>
315
308
> When an alias name matches the name of a member of a namespace , usage of either must be appropriately qualified :
316
309
>
@@ -366,23 +359,22 @@ The order in which *extern_alias_directive*s are written has no significance. Li
366
359
367
360
> *Example *: In the following code
368
361
>
369
- > <!-- ExternalRef $Example : {template:"standalone-lib-without-using ", name :"UsingAliasDirectives10 ", expectedErrors :["x ","x "], expectedWarnings :["x ","x "]} -->
370
- > <!-- FIX : I got this to work outside the test framework . 1. The external definition is in file ExternAliasE .cs in the additional -files folder . 2. We need a DLL for this compiled using csc ExternAliasE .cs -t :library 3. The Library .cs file needs to be compiled using csc Library .cs -t :library -r :E = ExternAliasE .dll , where the reference must include the path to the DLL . -->
362
+ > <!-- Example : {template:"extern -lib", name:"UsingAliasDirectives10", project:"ExampleProject", expectedErrors:["CS0246 "]} -- >
371
363
> ```csharp
372
364
> namespace N1 .N2 {}
373
365
>
374
366
> namespace N3
375
367
> {
376
- > extern alias E ;
368
+ > extern alias X ;
377
369
>
378
- > using R1 = E ::N ; // OK
370
+ > using R1 = X ::N ; // OK
379
371
> using R2 = N1 ; // OK
380
372
> using R3 = N1 .N2 ; // OK
381
373
> using R4 = R2 .N2 ; // Error, R2 unknown
382
374
> }
383
375
> ```
384
376
>
385
- > the last *using_alias_directive* results in a compile-time error because it is not affected by the previous *using_alias_directive*. The first *using_alias_directive* does not result in an error since the scope of the extern alias E includes the *using_alias_directive*.
377
+ > the last * using_alias_directive * results in a compile - time error because it is not affected by the previous *using_alias_directive *. The first *using_alias_directive * does not result in an error since the scope of the extern alias X includes the *using_alias_directive *.
386
378
>
387
379
> *end example *
388
380
0 commit comments