dotnet/roslyn

IDE0065 messes up if/endifs around namespaces

オープン

#40,001 opened on 2019/11/25

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

Repository metrics

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

説明

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.

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