Skip to content

[browser][JSImport] Support for marshaling Memory<> #97381

Open

Description

@pavelsavara

As requested in #97268

Activity

  1. added this to the Future milestone on Jan 23, 2024
  2. self-assigned this
    on Jan 23, 2024
  3. eeegs commented on Jan 24, 2024

    @eeegs

    The extra types being discussed in #97380 should be included too.

  4. ArcadeMode commented on Jan 26, 2026

    @ArcadeMode
    Contributor

    I'd be interested in implementing this. Would this require any special consideration or can we just line up the implementation with Span and ArraySegment?

  5. pavelsavara commented on Jan 27, 2026

    @pavelsavara
    MemberAuthor

    It will require API proposal for the C# side of the API.

    public void ToManaged(out Span<byte> value) { throw null; }
    public void ToJS(Span<byte> value) { throw null; }
    public void ToManaged(out ArraySegment<byte> value) { throw null; }
    public void ToJS(ArraySegment<byte> value) { throw null; }
    public void ToManaged(out Span<int> value) { throw null; }
    public void ToJS(Span<int> value) { throw null; }
    public void ToManaged(out Span<double> value) { throw null; }
    public void ToJS(Span<double> value) { throw null; }
    public void ToManaged(out ArraySegment<int> value) { throw null; }
    public void ToJS(ArraySegment<int> value) { throw null; }
    public void ToManaged(out ArraySegment<double> value) { throw null; }
    public void ToJS(ArraySegment<double> value) { throw null; }

    The JS side API design is not so formal and our team would do it on the PR review.

    export interface IMemoryView extends IDisposable {

    Other than that, I think the experience would be similar to ArraySegment because JS side would have to hold it pinned via GCHandleType.Pinned same as ArraySegment.

    We probably want to do ReadOnlyMemory<T> at the same time.
    Which would not have write functions on JS side and new public IReadOnlyMemoryView typescript interface.

  6. pavelsavara commented on Jan 27, 2026

    @pavelsavara
    MemberAuthor

    The extra types being discussed in #97380 should be included too.

    I think that this could be separate effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions