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: standard/arrays.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,7 @@ Elements of arrays created by *array_creation_expression*s are always initialize
114
114
115
115
Array elements are accessed using the *array access* variant of *element_access* expressions ([§12.8.12.2](expressions.md#128122-array-access)) of the form `A[I₁, I₂, ..., Iₓ]`, where `A` is an expression of an array type and each `Iₑ` is an expression of type `int`, `uint`, `nint`, `nuint`, `long`, `ulong`, or can be implicitly converted to one or more of these types. The result of an array access is a variable reference ([§9.5](variables.md#95-variable-references)) to the array element selected by the indices.
116
116
117
-
Array elements of single-dimensional arrays can also be accessed using an array access expression where the sole index, `I₁`, is an expression of type `Index`, `Range`, or can be implicitly converted to one or both of these types. If `I₁` is of type `Index`, or has been implicitly converted to that type, then the result of the array access is a variable reference to the array element selected by the index value. If `I₁` is of type `Range`, or has been implicitly converted to that type, then the result of the element access is a new array formed from a shallow copy of the array elements with indices in the `Range`, maintaining the element order.
117
+
Array elements of single-dimensional arrays can also be accessed using an array access expression where the sole index, `I₁`, is an expression of type `Index`, `Range`, or can be implicitly converted to one or both of these types. If `I₁` is of type `Index`, or has been implicitly converted to that type, then the result of the array access is a variable reference to the array element selected by the index value. If `I₁` is of type `Range`, or has been implicitly converted to that type, then the result of the array access is a new array formed from a shallow copy of the array elements with indices in the `Range`, maintaining the element order.
118
118
119
119
The elements of an array can be enumerated using a `foreach` statement ([§13.9.5](statements.md#1395-the-foreach-statement)).
Copy file name to clipboardExpand all lines: standard/attributes.md
+50-11Lines changed: 50 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -156,7 +156,7 @@ The types of positional and named parameters for an attribute class are limited
156
156
157
157
## 23.3 Attribute specification
158
158
159
-
Application of a previously defined attribute to a program entity is called ***attribute specification***. An attribute is a piece of additional declarative information that is specified for a program entity. Attributes can be specified at global scope (tospecifyattributesonthecontainingassemblyormodule) andfor *type_declaration*s ([§14.7](namespaces.md#147-type-declarations)), *class_member_declaration*s ([§15.3](classes.md#153-class-members)), *interface_member_declaration*s ([§19.4](interfaces.md#194-interface-members)), *struct_member_declaration*s ([§16.3](structs.md#163-struct-members)), *enum_member_declaration*s ([§20.2](enums.md#202-enum-declarations)), *accessor_declaration*s ([§15.7.3](classes.md#1573-accessors)), *event_accessor_declaration*s ([§15.8](classes.md#158-events)), elementsof*parameter_list*s ([§15.6.2](classes.md#1562-method-parameters)), andelementsof*type_parameter_list*s ([§15.2.3](classes.md#1523-type-parameters)).
159
+
Application of a previously defined attribute to a program entity is called ***attribute specification***. An attribute is a piece of additional declarative information that is specified for a program entity. Attributes can be specified at global scope (to specify attributes on the containing assembly or module) and for *type_declaration*s ([§14.7](namespaces.md#147-type-declarations)), *class_member_declaration*s ([§15.3](classes.md#153-class-members)), *interface_member_declaration*s ([§19.4](interfaces.md#194-interface-members)), *struct_member_declaration*s ([§16.3](structs.md#163-struct-members)), *enum_member_declaration*s ([§20.2](enums.md#202-enum-declarations)), *accessor_declaration*s ([§15.7.3](classes.md#1573-accessors)), *event_accessor_declaration*s ([§15.8](classes.md#158-events)), *local_function_declaration*s ([§13.6.4](statements.md#1364-local-function-declarations)), elements of *parameter_list*s ([§15.6.2](classes.md#1562-method-parameters)), elements of *type_parameter_list*s ([§15.2.3](classes.md#1523-type-parameters)), *lambda_expression*s ([§12.22.1](expressions.md#12221-general)), and elements of *explicit_anonymous_function_parameter*s and *implicit_anonymous_function_parameter*s ([§12.22.1](expressions.md#12221-general)).
160
160
161
161
Attributes are specified in ***attribute section***s. An attribute section consists of a pair of square brackets, which surround a comma-separated list of one or more attributes. The order in which attributes are specified in such a list, and the order in which sections attached to the same program entity are arranged, is not significant. For instance, the attribute specifications `[A][B]`, `[B][A]`, `[A, B]`, and `[B, A]` are equivalent.
162
162
@@ -252,10 +252,10 @@ The standardized *attribute_target* names are `event`, `field`, `method`, `param
252
252
253
253
-`event` — an event.
254
254
-`field` — a field. A field-like event (i.e., one without accessors) ([§15.8.2](classes.md#1582-field-like-events)) and an automatically implemented property ([§15.7.4](classes.md#1574-automatically-implemented-properties)) can also have an attribute with this target.
255
-
-`method` — a constructor; finalizer; method; operator; property get, set, and init accessors; indexer get, set, and init accessors; and event add and remove accessors. A field-like event (i.e., one without accessors) can also have an attribute with this target.
256
-
-`param` — property set and init accessors, indexer set and init accessors, event add and remove accessors, and a parameter in a constructor, method, and operator.
255
+
-`method` — a constructor; finalizer; method; operator; local function, property get, set, and init accessors; indexer get, set, and init accessors; event add and remove accessors; and lambda expressions. A field-like event (i.e., one without accessors) can also have an attribute with this target.
256
+
-`param` — property set and init accessors, indexer set and init accessors, event add and remove accessors, and a parameter in a constructor, method, local fuction, and operator.
257
257
-`property` — a property and an indexer.
258
-
-`return` — a delegate, method, operator, property get accessor, and indexer get accessor.
258
+
-`return` — a delegate, method, local function, operator, property get accessor, indexer get accessor, and lambda expression.
259
259
-`type` — a delegate, class, struct, enum, and interface.
260
260
-`typevar` — a type parameter.
261
261
@@ -267,6 +267,9 @@ Certain contexts permit the specification of an attribute on more than one targe
267
267
- For an attribute on a method declaration the default target is the method. Otherwise when the *attribute_target* is equal to:
268
268
-`method` — the target is the method
269
269
-`return` — the target is the return value
270
+
- For an attribute on a local function declaration the default target is the local function. Otherwise when the *attribute_target* is equal to:
271
+
-`method` — the target is the local function
272
+
-`return` — the target is the return value
270
273
- For an attribute on an operator declaration the default target is the operator. Otherwise when the *attribute_target* is equal to:
271
274
-`method` — the target is the operator
272
275
-`return` — the target is the return value
@@ -285,6 +288,9 @@ Certain contexts permit the specification of an attribute on more than one targe
285
288
- In the case of an event declaration that does not omit *event_accessor_declarations* the default target is the method.
286
289
-`method` — the target is the associated method
287
290
-`param` — the target is the lone parameter
291
+
- For an attribute on a *lambda_expression* the default target is the method. Otherwise when the *attribute_target* is equal to:
292
+
-`method` — the target is the method
293
+
-`return` — the target is the return value
288
294
289
295
In all other contexts, inclusion of an *attribute_target_specifier* is permitted but unnecessary.
290
296
@@ -671,9 +677,9 @@ The use of conditional methods in an inheritance chain can be confusing. Calls m
671
677
672
678
#### 23.5.3.3 Conditional local functions
673
679
674
-
A local function may be made conditional in the same sense as a conditional method ([§23.5.3.2](attributes.md#23532-conditional-methods)).
680
+
A static local function may be made conditional in the same sense as a conditional method ([§23.5.3.2](attributes.md#23532-conditional-methods)).
675
681
676
-
A conditional local function shall have the modifier `static`.
682
+
A compile time error occurs if a non-static local function is made conditional.
677
683
678
684
#### 23.5.3.4 Conditional attribute classes
679
685
@@ -798,13 +804,13 @@ Caller information is only substituted when a function is explicitly invoked in
798
804
799
805
One exception is query expressions. These are considered syntactic expansions, and if the calls they expand to omit optional parameters with caller-info attributes, caller information will be substituted. The location used is the location of the query clause which the call was generated from.
800
806
801
-
If more than one caller-info attribute is specified on a given parameter, they are recognized in the following order: `CallerLineNumber`, `CallerFilePath`, `CallerMemberName`. Consider the following parameter declaration:
807
+
If more than one caller-info attribute is specified on a given parameter, they are recognized in the following order: `CallerLineNumber`, `CallerFilePath`, `CallerMemberName`, `CallerArgumentExpression`. Consider the following parameter declaration:
802
808
803
809
```csharp
804
810
[CallerMemberName, CallerFilePath, CallerLineNumber] object p = ...
805
811
```
806
812
807
-
`CallerLineNumber` takes precedence, and the other two attributes are ignored. If `CallerLineNumber` were omitted, `CallerFilePath` would take precedence, and `CallerMemberName` would be ignored. The lexical ordering of these attributes is irrelevant.
813
+
`CallerLineNumber` takes precedence, and the other three attributes are ignored. If `CallerLineNumber` were omitted, `CallerFilePath` would take precedence, and `CallerMemberName` and `CallerArgumentExpression` would be ignored. The lexical ordering of these attributes is irrelevant.
808
814
809
815
#### 23.5.6.2 The CallerLineNumber attribute
810
816
@@ -844,11 +850,44 @@ For invocations that occur within field or event initializers, the member name u
844
850
845
851
For invocations that occur within declarations of instance constructors, static constructors, finalizers and operators the member name used is implementation-dependent.
846
852
847
-
For an invocation that occurs within a local function, the name of the method that calls that local function is used. Consider the following: if method `M` calls local function `F1`, which in turn calls local function `F2`, and `F2` has a parameter marked with this attribute, the method name passed to `F2` is `M`, because a local function is *not* a function member!
853
+
For an invocation that occurs within a local function or an anonymous function, the name of the member method that calls that function is used.
> This attribute supplies the name of the calling function member, which for local function `F1` is the method `Main`. And even though `F2` is called by `F1`, a local function is *not* a function member, so the reported caller of `F2` is also `Main`. *end example*
848
887
849
888
#### 23.5.6.5 The CallerArgumentExpression attribute
850
889
851
-
The attribute `System.Runtime.CompilerServices.CallerArgumentExpression` is applied to a *target parameter*, and can result in the capture of the source-code text of a sibling parameter's argument as a string, referred to here as the *captured string*.
890
+
The attribute `System.Runtime.CompilerServices.CallerArgumentExpressionAttribute` is applied to a *target parameter*, and can result in the capture of the source-code text of a sibling parameter's argument as a string, referred to here as the *captured string*.
852
891
853
892
Except when it is the first parameter in an extension method, the target parameter shall have a *default_argument*.
854
893
@@ -1192,7 +1231,7 @@ It is an error if the `System.Runtime.CompilerServices.EnumeratorCancellation` a
0 commit comments