dotnet / roslynator

Roslynator is a set of code analysis tools for C#, powered by Roslyn.
https://josefpihrt.github.io/docs/roslynator
Other
3.09k stars 258 forks source link

RCS0005 reports False Positive when #endregion follows a #pragma line plus a blank line #1528

Closed Bergam64 closed 1 month ago

Bergam64 commented 2 months ago

Product and Version Used: VS extension Roslynator 2022 v4.12.5

Steps to Reproduce:

Actual Behavior:

namespace MyNamespace
{
    /// <summary>
    /// ...
    /// </summary>
    public class Class1
    {
        #region MyRegion

#pragma warning disable 1591

        public int MyProperty { get; set; }

#pragma warning restore 1591

        #endregion // <-- RCS0005 is wrongly reported here, although there's a blank line above.
    }
}

Applying the code fix adds a blank line that is not needed, which causes RCS1036 (Remove unnecessary blank line) to be reported on that line:

namespace MyNamespace
{
    /// <summary>
    /// ...
    /// </summary>
    public class Class1
    {
        #region MyRegion

#pragma warning disable 1591

        public int MyProperty { get; set; }

#pragma warning restore 1591

        #endregion
    }
}

Expected Behavior:

namespace MyNamespace
{
    /// <summary>
    /// ...
    /// </summary>
    public class Class1
    {
        #region MyRegion

#pragma warning disable 1591

        public int MyProperty { get; set; }

#pragma warning restore 1591

        #endregion // <-- No RCS0005 reported here.
    }
}