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/classes.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ class_declaration
21
21
22
22
class_tag
23
23
: 'class'
24
-
| 'record'
24
+
| 'record' 'class'?
25
25
;
26
26
```
27
27
@@ -31,7 +31,7 @@ A class declaration shall not supply *type_parameter_constraints_clause*s unless
31
31
32
32
A class declaration that supplies a *type_parameter_list* is a generic class declaration. Additionally, any class nested inside a generic class declaration or a generic struct declaration is itself a generic class declaration, since type arguments for the containing type shall be supplied to create a constructed type ([§8.4](types.md#84-constructed-types)).
33
33
34
-
If *class_tag* contains `record`, that class is a ***record class***; otherwise, it is a ***non-record class***.
34
+
If *class_tag* contains `record`, that class is a ***record class***; otherwise, it is a ***non-record class***.`record` and `record class` are equivalent.
35
35
36
36
For a record class, *class_modifier* shall not be `static`.
Copy file name to clipboardExpand all lines: standard/expressions.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3921,6 +3921,7 @@ All non-positional properties being changed shall have both set and init accesso
3921
3921
This expression is evaluated as follows:
3922
3922
3923
3923
- For a record class type, the receiver's clone method ([§15.16.3](classes.md#15163-copy-and-clone-members)) is invoked, and its result is converted to the receiver’s type.
3924
+
- For a record struct or non-record struct type, the receiver is copied.
3924
3925
- Each `member_initializer` is processed the same way as an assignment to
3925
3926
a field or property access of the result of the conversion. Assignments are processed in lexical order. If *member_initializer_list* is omitted, no members are changed.
Copy file name to clipboardExpand all lines: standard/structs.md
+7-3Lines changed: 7 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ A *struct_declaration* is for either a ***non-record struct*** or a ***record st
42
42
43
43
A *non_record_struct_declaration* consists of an optional set of *attributes* ([§23](attributes.md#23-attributes)), followed by an optional set of *struct_modifier*s ([§16.2.2](structs.md#1622-struct-modifiers)), followed by an optional `ref` modifier ([§16.2.3](structs.md#1623-ref-modifier)), followed by an optional partial modifier ([§15.2.7](classes.md#1527-partial-type-declarations)), followed by the keyword `struct` and an *identifier* that names the struct, followed by an optional *type_parameter_list* specification ([§15.2.3](classes.md#1523-type-parameters)), followed by an optional *struct_interfaces* specification ([§16.2.5](structs.md#1625-struct-interfaces)), followed by an optional *type_parameter_constraints-clauses* specification ([§15.2.5](classes.md#1525-type-parameter-constraints)), followed by a *struct_body* ([§16.2.6](structs.md#1626-struct-body)), optionally followed by a semicolon.
44
44
45
-
A *record_struct_declaration* consists of an optional set of *attributes* ([§23](attributes.md#23-attributes)), followed by an optional set of *struct_modifier*s ([§16.2.2](structs.md#1622-struct-modifiers)), followed by an optional partial modifier ([§15.2.7](classes.md#1527-partial-type-declarations)), followed by the keyword `record`, followed by the keyword `struct` and an *identifier* that names the struct, followed by an optional *type_parameter_list* specification ([§15.2.3](classes.md#1523-type-parameters)), followed by an optional *delimited_parameter_list* specification ([§15.2.1](classes.md#1521-general), followed by an optional *struct_interfaces* specification ([§16.2.5](structs.md#1625-struct-interfaces)), followed by an optional *type_parameter_constraints-clauses* specification ([§15.2.5](classes.md#1525-type-parameter-constraints)), followed by a *record_struct_body*.
45
+
A *record_struct_declaration* consists of an optional set of *attributes* ([§23](attributes.md#23-attributes)), followed by an optional set of *struct_modifier*s ([§16.2.2](structs.md#1622-struct-modifiers)), followed by an optional partial modifier ([§15.2.7](classes.md#1527-partial-type-declarations)), followed by the keyword `record`, followed by the keyword `struct` and an *identifier* that names the struct, followed by an optional *type_parameter_list* specification ([§15.2.3](classes.md#1523-type-parameters)), followed by an optional *delimited_parameter_list* specification ([§15.2.1](classes.md#1521-general)), followed by an optional *struct_interfaces* specification ([§16.2.5](structs.md#1625-struct-interfaces)), followed by an optional *type_parameter_constraints-clauses* specification ([§15.2.5](classes.md#1525-type-parameter-constraints)), followed by a *record_struct_body*.
46
46
47
47
A *struct_declaration* shall not supply *type_parameter_constraints_clause*s unless it also supplies a *type_parameter_list*.
48
48
@@ -143,6 +143,8 @@ struct_body
143
143
144
144
## 16.3 Struct members
145
145
146
+
### 16.3.1 General
147
+
146
148
The members of a struct consist of the members introduced by its *struct_member_declaration*s and the members inherited from the type `System.ValueType`. For a record struct, the member set also includes the synthesized members generated by the compiler (§synth-members).
147
149
148
150
```ANTLR
@@ -169,8 +171,6 @@ Except for the differences noted in [§16.4](structs.md#164-class-and-struct-dif
169
171
170
172
It is an error for a member of a record struct to be named `Clone`.
171
173
172
-
It is an error for a member of a record struct to be named `Clone`.
173
-
174
174
It is an error for an instance field of a record struct to have an unsafe type.
175
175
176
176
### 16.3.2 Readonly members
@@ -207,6 +207,10 @@ An instance member definition or accessor of an instance property, indexer, or e
207
207
>thrownewInvalidOperationException("Messages collection is not initialized.");
208
208
> }
209
209
>messages.Add(message);
210
+
> }
211
+
> }
212
+
> ```
213
+
>
210
214
>The `readonly` method `AddMessage` canchangethestateofamessagelist. The `InitializeMessages` membercanclearandre-initializethelistofmessages. Inthecaseof `AddMessage`, the `readonly` modifierisvalid. Inthecaseof `InitializeMessages`, addingthe `readonly` modifierisinvalid. *endexample*
211
215
212
216
## §synth-members Synthesized record struct members
0 commit comments