-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Use scoped more in dotnet/runtime #71589
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
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:
|
src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/Interop/msquic.cs
Outdated
Show resolved
Hide resolved
jkotas
left a comment
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 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
eiriktsarpalis
left a comment
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.
Thanks
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.