Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent formatting #1247

Closed
Lowfeye opened this issue Apr 29, 2024 · 2 comments
Closed

Inconsistent formatting #1247

Lowfeye opened this issue Apr 29, 2024 · 2 comments

Comments

@Lowfeye
Copy link

Lowfeye commented Apr 29, 2024

Input:

_gradient.SetKeys(
    new GradientColorKey[] { new(Color.blue, 0.0f), new(Color.green, 0.5f), new(Color.red, 1.0f) },
    new GradientAlphaKey[] { new(1.0f, 0.0f), new(1.0f, 0.5f), new(1.0f, 1.0f) });

Output:

_gradient.SetKeys(
    new GradientColorKey[]
    {
        new(Color.blue, 0.0f),
        new(Color.green, 0.5f),
        new(Color.red, 1.0f)
    },
    new GradientAlphaKey[] { new(1.0f, 0.0f), new(1.0f, 0.5f), new(1.0f, 1.0f) }
);

Expected behavior:

_gradient.SetKeys(
    new GradientColorKey[]
    {
        new(Color.blue, 0.0f),
        new(Color.green, 0.5f),
        new(Color.red, 1.0f)
    },
    new GradientAlphaKey[] 
    { 
        new(1.0f, 0.0f),
        new(1.0f, 0.5f),
        new(1.0f, 1.0f)
    }
);
@belav
Copy link
Owner

belav commented Apr 29, 2024

The first parameter is long enough that it breaks, the second parameter fits within the width and nothing is forcing it to break.

I could see having a rule for "collection initializers that call constructors of objects should automatically break if there are 3 or more objects in the initializer". Which would result in

// input 
var array = new SomeObject[] { new(1, 0), new(1, 0), new(1, 0) };

// output
var array = new SomeObject[] 
{ 
    new(1, 0),
    new(1, 0),
    new(1, 0)
};

Object initializers have a similar rule and auto break with 3+ properties.

var x = new X
{
    x = 1,
    y = 2,
    z = 3
};

@Lowfeye
Copy link
Author

Lowfeye commented Apr 29, 2024

I thought it was two consecutive arrays that caused no line breaks. Now this is OK, thank you.

@Lowfeye Lowfeye closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants