Skip to content

Merge all features related to C# 7 ref features #795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
65d1c53
Add rules for `ref` safety (#742)
BillWagner May 19, 2023
d02b208
C# 7.x: ref struct (#601)
gafter May 19, 2023
ee0115c
C# 7.x: ref locals and returns (#213)
RexJaeschke May 19, 2023
50ff244
C# 7.x: in parameter mode (#219)
RexJaeschke May 19, 2023
3f4f7f6
C# 7.x: Add initializer list to `stackalloc` (#238)
RexJaeschke May 19, 2023
2976e80
fix build warnings
BillWagner May 19, 2023
bce32c3
Apply suggestions from code review
BillWagner May 31, 2023
1ef8c3f
fix references
BillWagner May 31, 2023
d0c1a44
add closing backticks
BillWagner May 31, 2023
6eeab33
respond to feedback through clause 15 (classes)
BillWagner May 31, 2023
64bb713
respond to feedback.
BillWagner Jun 1, 2023
5d69051
Apply suggestions from code review
BillWagner Jun 1, 2023
0c5c435
rearrange conditional specification
BillWagner Jun 1, 2023
dbf182c
Update standard/expressions.md
BillWagner Jun 1, 2023
3837c35
Update standard/variables.md
BillWagner Jun 1, 2023
1a1bf11
edits based on feedback.
BillWagner Jun 3, 2023
4384233
Update standard/expressions.md
BillWagner Jun 3, 2023
b0635f7
respond to feedback comments
BillWagner Jun 5, 2023
addcfc3
Apply suggestions from code review
BillWagner Jun 5, 2023
2cd2b7e
more feedback
BillWagner Jun 5, 2023
9d17844
Merge branch 'v7-ref-features' of https://github.com/dotnet/csharpsta…
BillWagner Jun 5, 2023
aa738d0
Update standard/classes.md
jskeet Jun 5, 2023
27db579
Update standard/classes.md
jskeet Jun 5, 2023
9292bae
Update standard/expressions.md
jskeet Jun 5, 2023
dbe51da
Update standard/expressions.md
BillWagner Jun 5, 2023
f0195c1
Update standard/expressions.md
jskeet Jun 5, 2023
0590e24
Update standard/variables.md
jskeet Jun 5, 2023
9e402f3
edits during the meeting.
BillWagner Jun 5, 2023
3c50a81
Merge branch 'v7-ref-features' of https://github.com/dotnet/csharpsta…
BillWagner Jun 5, 2023
4e5fdc3
Update standard/expressions.md
BillWagner Jun 6, 2023
32c230c
edits, part 1
BillWagner Jun 6, 2023
097f662
Merge branch 'v7-ref-features' of https://github.com/dotnet/csharpsta…
BillWagner Jun 6, 2023
57e3339
respond to meeting discussion and feedback
BillWagner Jun 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions standard/basic-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,8 @@ The following accessibility constraints exist:

Methods, instance constructors, indexers, and operators are characterized by their ***signatures***:

- The signature of a method consists of the name of the method, the number of type parameters, and the type and parameter-passing mode (value, reference, or output) of each of its formal parameters, considered in the order left to right. For these purposes, any type parameter of the method that occurs in the type of a formal parameter is identified not by its name, but by its ordinal position in the type parameter list of the method. The signature of a method specifically does not include the return type, parameter names, type parameter names, type parameter constraints, the `params` or `this` parameter modifiers, nor whether parameters are required or optional.

- The signature of an instance constructor consists of the type and parameter-passing mode (value, reference, or output) of each of its formal parameters, considered in the order left to right. The signature of an instance constructor specifically does not include the `params` modifier that may be specified for the right-most parameter.
- The signature of a method consists of the name of the method, the number of type parameters, and the type and parameter-passing mode of each of its formal parameters, considered in the order left to right. For these purposes, any type parameter of the method that occurs in the type of a formal parameter is identified not by its name, but by its ordinal position in the type parameter list of the method. The signature of a method specifically does not include the return type, parameter names, type parameter names, type parameter constraints, the `params` or `this` parameter modifiers, nor whether parameters are required or optional.
- The signature of an instance constructor consists of the type and parameter-passing mode of each of its formal parameters, considered in the order left to right. The signature of an instance constructor specifically does not include the `params` modifier that may be specified for the right-most parameter.
- The signature of an indexer consists of the type of each of its formal parameters, considered in the order left to right. The signature of an indexer specifically does not include the element type, nor does it include the `params` modifier that may be specified for the right-most parameter.
- The signature of an operator consists of the name of the operator and the type of each of its formal parameters, considered in the order left to right. The signature of an operator specifically does not include the result type.
- The signature of a conversion operator consists of the source type and the target type. The implicit or explicit classification of a conversion operator is not part of the signature.
Expand All @@ -537,9 +536,9 @@ Signatures are the enabling mechanism for ***overloading*** of members in classe
- Overloading of indexers permits a class, struct, or interface to declare multiple indexers, provided their signatures are unique within that class, struct, or interface.
- Overloading of operators permits a class or struct to declare multiple operators with the same name, provided their signatures are unique within that class or struct.

Although `out` and `ref` parameter modifiers are considered part of a signature, members declared in a single type cannot differ in signature solely by `ref` and `out`. A compile-time error occurs if two members are declared in the same type with signatures that would be the same if all parameters in both methods with `out` modifiers were changed to `ref` modifiers. For other purposes of signature matching (e.g., hiding or overriding), `ref` and `out` are considered part of the signature and do not match each other.
Although `in`, `out`, and `ref` parameter modifiers are considered part of a signature, members declared in a single type cannot differ in signature solely by `in`, `out`, and `ref`. A compile-time error occurs if two members are declared in the same type with signatures that would be the same if all parameters in both methods with `out` or `in` modifiers were changed to `ref` modifiers. For other purposes of signature matching (e.g., hiding or overriding), `in`, `out`, and `ref` are considered part of the signature and do not match each other.

> *Note*: This restriction is to allow C# programs to be easily translated to run on the Common Language Infrastructure (CLI), which does not provide a way to define methods that differ solely in `ref` and `out`. *end note*
> *Note*: This restriction is to allow C# programs to be easily translated to run on the Common Language Infrastructure (CLI), which does not provide a way to define methods that differ solely in `in`, `out`, and `ref`. *end note*

The types `object` and `dynamic` are not distinguished when comparing signatures. Therefore members declared in a single type whose signatures differ only by replacing `object` with `dynamic` are not allowed.

Expand Down Expand Up @@ -567,9 +566,7 @@ The types `object` and `dynamic` are not distinguished when comparing signatures
> }
> ```
>
> Note that any `ref` and `out` parameter modifiers ([§15.6.2](classes.md#1562-method-parameters)) are part of a signature. Thus, `F(int)`, `F(ref int)`, and `F(out int)` are all unique signatures. However, `F(ref int)` and `F(out int)` cannot be declared within the same interface because their signatures differ solely by `ref` and `out`. Also, note that the return type and the `params` modifier are not part of a signature, so it is not possible to overload solely based on return type or on the inclusion or exclusion of the `params` modifier. As such, the declarations of the methods `F(int)` and `F(params string[])` identified above, result in a compile-time error.
>
> *end example*
> Note that any `in`, `out`, and `ref` parameter modifiers ([§15.6.2](classes.md#1562-method-parameters)) are part of a signature. Thus, `F(int)`, `F(in int)`, `F(out int)` , and `F(ref int)` are all unique signatures. However, `F(in int)`, `F(out int)` , and `F(ref int)` cannot be declared within the same interface because their signatures differ solely by `in`, `out`, and `ref`. Also, note that the return type and the `params` modifier are not part of a signature, so it is not possible to overload solely based on return type or on the inclusion or exclusion of the `params` modifier. As such, the declarations of the methods `F(int)` and `F(params string[])` identified above, result in a compile-time error. *end example*

## 7.7 Scopes

Expand Down
Loading