Skip to content
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

Use scoped more in dotnet/runtime #71589

Merged
merged 3 commits into from
Jul 7, 2022
Merged

Conversation

stephentoub
Copy link
Member

This PR addresses a few issues:

  • Exposes the new {ReadOnly}Span constructors 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).
  • Makes several members of Utf8JsonReader readonly and several span arguments to SequenceReader scoped in order to enable stackalloc'd spans to be used in more call sites. Fixes Use readonly/scoped with existing ref structs that accept spans #71497.
  • Removes use of 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.

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.
@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

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.

@ghost
Copy link

ghost commented Jul 3, 2022

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR addresses a few issues:

  • Exposes the new {ReadOnly}Span constructors 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).
  • Makes several members of Utf8JsonReader readonly and several span arguments to SequenceReader scoped in order to enable stackalloc'd spans to be used in more call sites. Fixes Use readonly/scoped with existing ref structs that accept spans #71497.
  • Removes use of 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.
Author: stephentoub
Assignees: -
Labels:

area-Meta, new-api-needs-documentation

Milestone: 7.0.0

Copy link
Member

@jkotas jkotas left a 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.

Copy link
Member

@eiriktsarpalis eiriktsarpalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@stephentoub stephentoub merged commit 38ca26b into dotnet:main Jul 7, 2022
@stephentoub stephentoub deleted the usescoped branch July 7, 2022 11:56
@ghost ghost locked as resolved and limited conversation to collaborators Aug 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants