Repository navigation
Updates to Articles Concerning Ref Locals, In Parameters, and Readonly Ref Structs #4710
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
BillWagner
merged 8 commits into
dotnet:master
from
anonymousgituser:proposed_2018_03_19
Mar 22, 2018
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fc19f43
Update to article on In Parameter Modifiers
anonymousgituser 47ec400
Update to Article on Ref Keyword
anonymousgituser ff8a486
Update to Article on "Reference semantics with value types"
anonymousgituser 6fec691
Whitespace adjustment
anonymousgituser 810782d
Update to Article "Ref returns and ref locals"
anonymousgituser 54e0e71
Naming tweak.
anonymousgituser 24a9ea5
Updated reference-semantics-with-value-types.md per @BillWagner's sug…
anonymousgituser 737a4eb
Update in-parameter-modifier.md
BillWagner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,6 +202,22 @@ types. | |
| These restrictions ensure that you do not accidentally use a `ref struct` | ||
| in a manner that could promote it to the managed heap. | ||
|
|
||
| ## `readonly ref struct` type | ||
|
|
||
| Declaring a struct as `readonly ref` combines the benefits and restrictions of `ref struct` and `readonly struct` delcarations. | ||
|
|
||
| The following example demonstrates the declaration of `readonly ref struct`. | ||
|
|
||
| ```csharp | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need a better example here. I'd suggest adding the following constructor: ReadOnlyRefPoint2D(int x, int y) => (X, Y) = (x, y);Otherwise, |
||
| readonly ref struct ReadOnlyRefPoint2D | ||
| { | ||
| public int X { get; } | ||
| public int Y { get; } | ||
|
|
||
| ReadOnlyRefPoint2D(int x, int y) => (X, Y) = (x, y); | ||
| } | ||
| ``` | ||
|
|
||
| ## Conclusions | ||
|
|
||
| These enhancements to the C# language are designed for performance critical | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more I thought about this, the more I liked your proposed wording. Let's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch on the example.
I have committed the change.
Thanks for your thorough review and help with this @BillWagner!