dotnet/roslyn

Extract method over-indents second line of expression

オープン

#21,453 opened on 2017/08/11

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

Repository metrics

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

説明

Version Used: 15.3 Preview 7

:link: Originally revealed by ExtractMethodTests.TestUseExpressionWhenOnSingleLine_AndNotIsOnSingleLine in #21439.

Steps to Reproduce:

  1. Use the following code

    using System;
    
    namespace ConsoleApp5
    {
        class Program
        {
            static void Main(string[] args)
            {
                bool b = true;
                Console.WriteLine(b !=
                    true ? b = true : b = false);
            }
        }
    }
    
  2. Select b != true

  3. Apply the Extract Method refactoring

Expected Behavior:

using System;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b = true;
            Console.WriteLine(NewMethod(b) ? b = true : b = false);
        }

        private static bool NewMethod(bool b)
        {
            return b !=
                true;
        }
    }
}

Actual Behavior:

using System;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b = true;
            Console.WriteLine(NewMethod(b) ? b = true : b = false);
        }

        private static bool NewMethod(bool b)
        {
            return b !=
                            true;
        }
    }
}

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