dotnet/roslyn

IDE0065 messes up if/endifs around namespaces

Ouverte

#40 001 ouverte le 25 nov. 2019

 (4 commentaires) (3 réactions) (2 personnes assignées)C# (4 257 forks)batch import
Area-IDEBugFeature - IDE0065IDE-CodeStylehelp wanted

Métriques du dépôt

Stars
 (20 414 étoiles)
Métriques de merge PR
 (Merge moyen 6j 17h) (256 PRs mergées en 30 j)

Description

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.

Guide contributeur