dotnet/roslyn

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

开放

#50,672 创建于 2021年1月21日

 (11 条评论) (0 个反应) (1 位负责人)C# (4,257 个派生)batch import
Area-IDEBughelp wanted

仓库指标

星标
 (20,414 个星标)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

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 { }
    }
}

贡献者指南