Skip to content

Make CreateFromPinnedArray visible and move it to MemoryMarshal #25824

@ahsonkhan

Description

@ahsonkhan

Marking the method has EditorBrowsableState.Never hurts usability for users (like ASP.NET) who want to use the API.

Since the developer needs to be careful with the use of this API (it can be considered unsafe, for instance, if someone calls it on an array that isn't already pre-pinned), we should consider moving it to MemoryMarshal instead, but not hide it.

namespace System
{
    public readonly partial struct Memory<T>
    {
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public static Memory<T> CreateFromPinnedArray(T[] array, int start, int length) { throw null; }
    }
}

namespace System.Runtime.InteropServices
{
    public static partial class MemoryMarshal
    {
+        public static Memory<T> CreateFromPinnedArray(T[] array, int start, int length) { throw null; }
    }
}

cc @davidfowl, @GrabYourPitchforks, @stephentoub, @KrzysztofCwalina, @pakrym, @benaadams

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions