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
@@ -3934,6 +3934,7 @@ All non-positional properties being changed shall have both set and init accesso
3934
3934
This expression is evaluated as follows:
3935
3935
3936
3936
- 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.
3937
+
- For a record struct or non-record struct type, the receiver is copied.
3937
3938
- Each `member_initializer` is processed the same way as an assignment to
3938
3939
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
@@ -141,6 +141,8 @@ struct_body
141
141
142
142
## 16.3 Struct members
143
143
144
+
### 16.3.1 General
145
+
144
146
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).
145
147
146
148
```ANTLR
@@ -167,8 +169,6 @@ Except for the differences noted in [§16.4](structs.md#164-class-and-struct-dif
167
169
168
170
It is an error for a member of a record struct to be named `Clone`.
169
171
170
-
It is an error for a member of a record struct to be named `Clone`.
171
-
172
172
It is an error for an instance field of a record struct to have an unsafe type.
173
173
174
174
### 16.3.2 Readonly members
@@ -205,6 +205,10 @@ An instance member definition or accessor of an instance property, indexer, or e
205
205
>thrownewInvalidOperationException("Messages collection is not initialized.");
206
206
> }
207
207
>messages.Add(message);
208
+
> }
209
+
> }
210
+
> ```
211
+
>
208
212
>The `readonly` method `AddMessage` canchangethestateofamessagelist. The `InitializeMessages` membercanclearandre-initializethelistofmessages. Inthecaseof `AddMessage`, the `readonly` modifierisvalid. Inthecaseof `InitializeMessages`, addingthe `readonly` modifierisinvalid. *endexample*
209
213
210
214
## §synth-members Synthesized record struct members
0 commit comments