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
+44-8Lines changed: 44 additions & 8 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)), and elements of *type_parameter_list*s ([§15.2.3](classes.md#1523-type-parameters)).
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, local function, 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, local function, 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, and indexer get accessor.
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
@@ -670,9 +673,9 @@ The use of conditional methods in an inheritance chain can be confusing. Calls m
670
673
671
674
#### 23.5.3.3 Conditional local functions
672
675
673
-
A local function may be made conditional in the same sense as a conditional method ([§23.5.3.2](attributes.md#23532-conditional-methods)).
676
+
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)).
674
677
675
-
A conditional local function shall have the modifier `static`.
678
+
A compile time error occurs if a non-static local function is made conditional.
676
679
677
680
#### 23.5.3.4 Conditional attribute classes
678
681
@@ -843,7 +846,40 @@ For invocations that occur within field or event initializers, the member name u
843
846
844
847
For invocations that occur within declarations of instance constructors, static constructors, finalizers and operators the member name used is implementation-dependent.
845
848
846
-
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!
849
+
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*
847
883
848
884
### 23.5.7 Code analysis attributes
849
885
@@ -1118,7 +1154,7 @@ It is an error if the `System.Runtime.CompilerServices.EnumeratorCancellation` a
0 commit comments