Skip to content

[Bug]: Unexpected newline added in ternary assignment #1847

@jlocans

Description

@jlocans

Description

When assigning value of ternary result the condition is unexpectedly always moved to a new line. This looks especially weird if used with discard variable.

CSharpier 1.2.6
VS Extension 10.0.2

Steps to Reproduce

Take this code example:

class ClassName
{
    void MethodName()
    {
        _ = true != null
                ? Foo.GetOneGetOneGetOneGetOneGetOneGetOne
                : Foo.GetTwoGetTwoGetTwoGetTwoGetTwoGetTwo;
    }
}

Expected Behavior

Expected is that code remains formatted as is. Assignment and condition check should be on the same line if line width allows it.

Actual Behavior

Condition is moved to a new line.

class ClassName
{
    void MethodName()
    {
        _ =
            true != null
                ? Foo.GetOneGetOneGetOneGetOneGetOneGetOne
                : Foo.GetTwoGetTwoGetTwoGetTwoGetTwoGetTwo;
    }
}

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