dotnet/roslyn

"Remove redundant assignment" should remove extra blank lines between assignment and trivia

オープン

#33,313 opened on 2019/02/12

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

Repository metrics

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

説明

"Remove redundant assignment" already removes extra blank lines between assignment and any additional code, so the following:

        static void Main(string[] args)
        {
            string foo = null;

			Console.WriteLine();

            foo = new string('A', 10);

            Console.WriteLine(foo);
        }

Will be (correctly) collapsed to:

        static void Main(string[] args)
        {
			Console.WriteLine();

            string foo = new string('A', 10);

            Console.WriteLine(foo);
        }

However, if its trivia, this doesn't occur:

        static void Main(string[] args)
        {
            string foo = null;

            // This is a comment

            foo = new string('A', 10);

            Console.WriteLine(foo);
        }

Gets changed to:

        static void Main(string[] args)
        {

            // This is a comment

            string foo = new string('A', 10);

            Console.WriteLine(foo);
        }

Hit this in this giant code review: https://devdiv.visualstudio.com/DevDiv/_git/CPS/pullrequest/163613?_a=overview.

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