runtime icon indicating copy to clipboard operation
runtime copied to clipboard

[API Proposal]: Introduce BinaryData.Length

Open lilinus opened this issue 3 years ago • 2 comments

Background and motivation

There is currently no intuitive way of getting the length of BinaryData, using a workaround ToArray or ToMemory it is not easy to assume it will not allocate anything.

API Proposal

namespace System;

public class BinaryData
{
    public int Length { get; }
}

API Usage

var b = new BinaryData(new byte[] { 1, 2, 3, 4 });
Console.WriteLine(b.Length);

Alternative Designs

No response

Risks

No response

lilinus avatar Nov 20 '23 13:11 lilinus

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

Issue Details

Background and motivation

There is currently no intuitive way of getting the length of BinaryData, using a workaround ToArray or ToMemory it is not easy to assume it will not allocate anything.

API Proposal

namespace System;

public class BinaryData
{
    public int Length { get; }
}

API Usage

var b = new BinaryData(new byte[] { 1, 2, 3, 4 });
Console.WriteLine(b.Length);

Alternative Designs

No response

Risks

No response

Author: lilinus
Assignees: -
Labels:

api-suggestion, area-System.Memory

Milestone: -

ghost avatar Nov 20 '23 13:11 ghost

Oh i saw this exists in .NET 8 now....

lilinus avatar Nov 20 '23 13:11 lilinus