dotnet/roslyn

Decompilation should put new lines between blocks

Aperta

#25.303 aperta il 7 mar 2018

 (16 commenti) (0 reazioni) (0 assegnatari)C# (4257 fork)batch import
Area-IDEIDE-Formatterhelp wanted

Metriche repository

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

Descrizione

We should layout methods a little better by introducing new lines to make a little more readable (Reflector did this well)

  1. Create Console App (.NET Framework)
  2. In the following, CTRL+Click int
    class Program
    {
        static void Main(string[] args)
        {
            int foo;
        }
    }
  1. When prompted say Yes to decompile
  2. Scroll down to CompareTo:

Expected:

		public int CompareTo(object value)
		{
			if (value == null)
			{
				return 1;
			}

			if (value is int)
			{
				int num = (int)value;
				if (this < num)
				{
					return -1;
				}

				if (this > num)
				{
					return 1;
				}

				return 0;
			}

			throw new ArgumentException(Environment.GetResourceString("Arg_MustBeInt32"));
		}

Actual:

		public int CompareTo(object value)
		{
			if (value == null)
			{
				return 1;
			}
			if (value is int)
			{
				int num = (int)value;
				if (this < num)
				{
					return -1;
				}
				if (this > num)
				{
					return 1;
				}
				return 0;
			}
			throw new ArgumentException(Environment.GetResourceString("Arg_MustBeInt32"));
		}

Guida contributor