dotnet / dotnet/dotnet-api-docs

Span<T>(Void*, Int32) points to original unmanaged block or copies it?

Open
#1,873 2 comments 0 reactions 0 assignees View on GitHub
area-System.Runtime dotnet-api/prod Pri2 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

Doc is unclear - does Span<T>(Void*, Int32) refer to the original unmanaged memory block, or copy the unmanaged data into a T[] managed object, that is then pinned when a pinnable ref is requested?
The former would certainly be desired, at least in some instances, but from tests it seems impossible to get the address of the original unmanaged object when requesting a pinnable ref. Doc needs to be clear here.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 12542bab-90d5-ee4f-fe42-3ad37dd133a1
* Version Independent ID: 1265f19b-bf12-ea32-0b5a-1bfae94b1be4
* Content: [Span<T> Constructor (System)](https://docs.microsoft.com/en-us/dotnet/api/system.span-1.-ctor?view=netcore-2.2#System_Span_1__ctor_System_Void__System_Int32_)
* Content Source: [xml/System/Span`1.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System/Span`1.xml)
* Product: **dotnet-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **dotnetcontent**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.