Skip to content

[Bug]: Initializing a span using stackalloc leads to different formatting compared to new #1808

@OleRoss

Description

@OleRoss

Description

When formatting a stackalloc span initializer, I get more verbose output than with a normal new initializer.

This is the behavior with new:

Span<int> metatable = new int[] {00000000000000000000000001, 00000000000000000000000002, 00000000000000000000000003};

Is formatted as

Span<int> metatable = new int[]
{
    00000000000000000000000001,
    00000000000000000000000002,
    00000000000000000000000003
};

Steps to Reproduce

Span<int> metatable = stackalloc int[] {00000000000000000000000001, 00000000000000000000000002, 00000000000000000000000003};

using the playground with 100 line-width (also tested with csharpier 1.2.5)

Expected Behavior

Span<int> metatable = stackalloc int[]
{
    00000000000000000000000001,
    00000000000000000000000002,
    00000000000000000000000003
};

Actual Behavior

Span<int> metatable =
    stackalloc int[] {
        00000000000000000000000001,
        00000000000000000000000002,
        00000000000000000000000003,
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions