dotnet/roslyn

IDE0065 messes up if/endifs around namespaces

开放

#40,001 创建于 2019年11月25日

 (4 条评论) (3 个反应) (2 位负责人)C# (4,257 个派生)batch import
Area-IDEBugFeature - IDE0065IDE-CodeStylehelp wanted

仓库指标

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

描述

Version Used: 3.5.0-beta2-19570-07+4bd316035f64c9776d5420af71df8ba38e8e23e4

Steps to Reproduce: Create a project with this code:

using System;

namespace MyNamespace
{
#if !FOO
    using System.Runtime.CompilerServices;
#endif

    class Program
    {
        static void Main() { }
    }
}

Then apply IDE0065 when it fires on the using System.Runtime.CompilerServices; directive.

Expected Behavior: Refactors to:

using System;
#if !FOO
using System.Runtime.CompilerServices;
#endif

namespace MyNamespace
{
    class Program
    {
        static void Main() { }
    }
}

or doesn't offer the refactoring.

Actual Behavior: Refactors to:

using System;
#if !FOO
using System.Runtime.CompilerServices;

namespace MyNamespace
{
#endif

    class Program
    {
        static void Main() { }
    }
}

which is broken and won't compile if that compilation constant is set.

贡献者指南