Use scoped more in dotnet/runtime#71589
Merged
stephentoub merged 3 commits intodotnet:mainfrom Jul 7, 2022
Merged
Conversation
This PR addresses a few issues:
- Exposes the new {ReadOnly}Span constructors that accept a ref.
- Uses those new constructors outside of corelib (they were previously internal and used only inside of corelib).
- Makes several members of Utf8JsonReader readonly in order to enable stackalloc'd spans to be used in ValueTextEquals calls.
- Makes several span arguments to SequenceReader scoped in order to enable stackalloc'd spans to be used with those calls.
- Removes all stackalloc T[0], replacing it with scoped locals.
- Removes some use of stackalloc'ing into a pointer and then manually wrapping into a span, instead directly stackalloc'ing into a span. This is possible now in more cases due to the new language validation rules.
- Replaced some use of MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(...)) with Unsafe.AsRef.
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
|
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsThis PR addresses a few issues:
|
jkotas
reviewed
Jul 3, 2022
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/msquic.cs
Outdated
Show resolved
Hide resolved
jkotas
approved these changes
Jul 3, 2022
Member
jkotas
left a comment
There was a problem hiding this comment.
The changes in quic interop files should be reverted. Otherwise looks good.
src/libraries/Common/src/System/Security/Cryptography/RSAAndroid.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/XmlKeyHelper.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexNode.cs
Show resolved
Hide resolved
src/libraries/System.Text.Json/src/System/Text/Json/Reader/Utf8JsonReader.cs
Outdated
Show resolved
Hide resolved
...raries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.WriteProperties.String.cs
Outdated
Show resolved
Hide resolved
cston
approved these changes
Jul 3, 2022
AaronRobinsonMSFT
approved these changes
Jul 7, 2022
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR addresses a few issues:
{ReadOnly}Spanconstructors that accept a ref. Fixes [API Proposal]: {ReadOnly}Span(ref T) constructor #67445. Uses those new constructors outside of corelib (they were previously internal and used only inside of corelib).Utf8JsonReaderreadonlyand several span arguments toSequenceReaderscoped in order to enablestackalloc'd spans to be used in more call sites. Fixes Use readonly/scoped with existing ref structs that accept spans #71497.stackalloc T[0], replacing it with scoped locals.stackalloc'ing into a pointer and then manually wrapping into a span, instead directlystackalloc'ing into a span. This is possible now in more cases due to the new language validation rules.MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(...))withUnsafe.AsRef.