dotnet/roslyn

csharp_space_between_method_call_parameter_list_parentheses is not honored in variable initialization

オープン

#43,791 opened on 2020/04/29

 (1 件のコメント) (0 件のリアクション) (0 人の担当者)C# (4,257 件のフォーク)batch import
Area-IDEBugIDE-Formatterhelp wanted

Repository metrics

Stars
 (20,414 個のスター)
PR merge metrics
 (平均マージ 6d 17h) (30d で 256 merged PRs)

説明

This issue has been moved from a ticket on Developer Community.


In VS 2019, I went to Tools -> Options -> Text Editor -> C# -> Code Style -> Formatting -> Spacing; and I enabled the option "Insert space within argument list parentheses", which corresponds to the .editorconfig option csharp_space_between_method_call_parameter_list_parentheses.

I generated a .editorconfig file based on this using VS and saved it to the root of my solution.

After I pressed the Code Cleanup button, the new style was applied, except as follows:

Before:

            byte[] codePointBytes = Encoding.UTF32.GetBytes(s);
            codePointBytes = Encoding.UTF32.GetBytes(s);
            Encoding.UTF32.GetBytes(s);

Expected result:

            byte[] codePointBytes = Encoding.UTF32.GetBytes( s );
            codePointBytes = Encoding.UTF32.GetBytes( s );
            Encoding.UTF32.GetBytes( s );

Actual result:

            byte[] codePointBytes = Encoding.UTF32.GetBytes(s);    // Space was not added inside parentheses
            codePointBytes = Encoding.UTF32.GetBytes( s );
            Encoding.UTF32.GetBytes( s );

To summarize, VS does not apply the code style csharp_space_between_method_call_parameter_list_parentheses when the method call is part of a variable initialization.


Original Comments

Visual Studio Feedback System on 4/29/2020, 02:13 AM:


Original Solutions

(no solutions)

コントリビューターガイド