dotnet/roslyn

IDE0059 adds a redundant blank line in some cases

Open

#60.114 aperta il 11 mar 2022

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-IDEBugFeature - IDE0059help wanted

Metriche repository

Star
 (20.414 star)
Metriche merge PR
 (Merge medio 6g 17h) (256 PR mergiate in 30 g)

Descrizione

Port of https://github.com/dotnet/roslyn/issues/51401#issuecomment-1065029095

Version Used: VS 2022 v17.2 Preview 1

Steps to Reproduce: Start code:

namespace ClassLibrary1
{
    public class Class1
    {
        public string ReturnEmptyString()
        {
            #region region1

            string returnValue = null;

            #endregion

            returnValue = string.Empty;
            return returnValue;
        }
    }
}

Then apply IDE0059 on returnValue

Expected Behavior:

namespace ClassLibrary1
{
    public class Class1
    {
        public string ReturnEmptyString()
        {
            #region region1

            #endregion

            returnValue = string.Empty;
            return returnValue;
        }
    }
}

Actual Behavior:

namespace ClassLibrary1
{
    public class Class1
    {
        public string ReturnEmptyString()
        {
            // This blank line should not be here
            #region region1

            #endregion

            returnValue = string.Empty;
            return returnValue;
        }
    }
}

Demo: demo.gif

Guida contributor