dotnet/roslyn

Bug in Move Type to Namespace refactoring - usings not added for namespaces in same file

オープン

#50,672 opened on 2021/01/21

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

Repository metrics

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

説明

Version Used: Visual Studio 16.9.0 Preview 3.0

Sample Code:

using System;

namespace Tests
{
    internal class Foo
    {
        public static int Do(Inner.Data d) => 42;
    }
}

namespace Tests {
    namespace Inner
    {
        public class App
        {
            static void Main()
            {
                Console.WriteLine(Foo.Do(new Data()));
            }
        }
        public class Data { }
    }
}

Steps to Reproduce:

  1. Move type Foo to Namespace Something.Else

Expected Behavior: Working Code

Actual Behavior: Compile Error

Code after refatoring:

using Something.Else;
using System;

namespace Something.Else
{
    internal class Foo
    {
        public static int Do(Inner.Data d) => 42;
    }
}

namespace Tests
{
    namespace Inner
    {
        public class App
        {
            static void Main()
            {
                Console.WriteLine(Foo.Do(new Data()));
            }
        }
        public class Data { }
    }
}

Expected Code:

using Something.Else;
using System;
using Tests.Inner;

namespace Something.Else
{
    internal class Foo
    {
        public static int Do(Data d) => 42;
    }
}

namespace Tests
{
    namespace Inner
    {
        public class App
        {
            static void Main()
            {
                Console.WriteLine(Foo.Do(new Data()));
            }
        }
        public class Data { }
    }
}

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