Skip to content

API Proposal: SafeBuffer Span<T> methods #27831

@vcsjones

Description

@vcsjones

Proposal:

namespace System.Runtime.InteropServices
{
    public abstract unsafe class SafeBuffer
    {
        public void ReadSpan<T>(ulong byteOffset, Span<T> buffer) where T : struct => throw null;
        public void WriteSpan<T>(ulong byteOffset, ReadOnlySpan<T> data) where T : struct => throw null;
    }
}

The purpose of this is to be a Span-based equivalent of ReadArray. The motivation for this is for a later API proposal to add the same methods to UnmanagedMemoryAccessor which will work for memory mapped views.

This would make it possible to work efficiently and safely with stackalloc'ed data.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions