Closed natanfudge closed 9 hours ago
I found the same behaviour to be true when multiline initialising Dictionary as well.
var data = new Dictionary<string, string> {
{ "a", "a" },
{ "b", "b" },
{ "c", "c" }
};
Remains the same. Single line works as expected
By design the Roslyn Formatter does not format initializers.
Issue Description
When you declare some kind of list / dictionary with "{}" (list initializer) that takes more than one line to write and try to format it, none of the list will get formatted.
Steps to Reproduce
Create a new
.cs
file and type:And then activate the
Format Document
command.Expected Behavior
The list initializer will get formatted to this:
or this:
Actual Behavior
The list remains unchanged.
Logs
OmniSharp log
C# log
Environment information
VSCode version: 1.32.3 C# Extension: 1.18.0
Dotnet Information
.NET Core SDK (reflecting any global.json): Version: 2.1.502 Commit: c74ce8f29f Runtime Environment: OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.502\ Host (useful for support): Version: 2.1.6 Commit: 3f4f8eebd8 .NET Core SDKs installed: 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.500 [C:\Program Files\dotnet\sdk] 2.1.502 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-downloadVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |auto-using|Fudge|0.7.4| |cs2ts-vscode-extension|chiadem|0.2.1| |csharp|ms-vscode|1.18.0| |csharpextensions|jchannon|1.3.0| |docomment|k--kato|0.1.6| |msbuild-project-tools|tintoy|0.2.54| |vscode-nuget-package-manager|jmrog|1.1.6| |vscode-path-tools|cg-cnu|0.0.4| |vscode-test-explorer|hbenl|2.9.1| |vscode-todo-highlight|wayou|1.0.4|;