-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Break object initializers if there are 3 or more properties #446
Comments
I am not sure if we really want this change. It leads to cases like this. var myList = new MyList<Point>
{
new Point
{
x = 10,
Y = 10
},
new Point
{
x = 20,
Y = 20
}
};
// vs
var myList = new MyList<Point>
{
new Point { x = 10, Y = 10 },
new Point { x = 20, Y = 20 }
}; And list.Add(
new RadioItem
{
Text = "text-foo",
Value = "foo"
}
);
list.Add(
new RadioItem
{
Text = "text-bar",
Value = "bar"
}
);
list.Add(
new RadioItem
{
Text = "text-baz",
Value = "baz"
}
);
// vs
list.Add(new RadioItem { Text = "text-foo", Value = "foo" });
list.Add(new RadioItem { Text = "text-bar", Value = "bar" });
list.Add(new RadioItem { Text = "text-baz", Value = "baz" }); Which I prefer with the condensed format. But something nested like this I think is better expanded MyClass myClass = new MyClass
{
Value = "Foo",
Thing = new MyThing { Number = 456, }
};
// vs
MyClass myClass = new MyClass { Value = "Foo", Thing = new MyThing { Number = 456, } }; A ton of real world examples are here The official microsoft documentation has them expanded. It might be worth trying to analyze csharpier-repos to get an idea if a large percent of the real world code had them expanded. Also worth noting that prettier has been unable to find a good heuristic on when to expand objects |
The changes from #488 are related. |
How about 3 or more? With file scoped namespaces, a lot of smaller props will fit in 100 characters. |
This is the result of breaking things with 3 or more. https://github.com/belav/csharpier-repos/pull/17/files |
* try out break at 3 * Breaking initializers if there are 3 or more closes #446
Should we always break if there are two properties? Should be easy to test out across all the forked repos.
The text was updated successfully, but these errors were encountered: