Even when I use the shortcut Ctrl+K Ctrl+D (Or Edit>Advanced>Format Document) in VS 2022, this C# code won't format properly:
Why won't the Visual Studio 2022 formatter fix these issues? How can I get this code to format correctly? Seems like a weird behavior.
Even when I use the shortcut Ctrl+K Ctrl+D (Or Edit>Advanced>Format Document) in VS 2022, this C# code won't format properly:
Why won't the Visual Studio 2022 formatter fix these issues? How can I get this code to format correctly? Seems like a weird behavior.
Based on my test, I reproduced the same problem with you. As mentioned in the comments, this issue has been discussed since 2016, but there is still no good solution.
I recommend that you could report the problem in Developer Community. There are many VS developers who can help here. It is important to note that official staff may only handle this problem when enough people report it.
List<string> myList = [ "Hello", "World", "From", "Morocco" ];
would actually be more efficient (it uses different APIs and bypasses some book-keeping that isn't going to be necessary in this scenario) – Marc Gravell Commented Feb 3 at 13:34