3 Replies Last post: Jan 15, 2013 1:26 PM by Alex Berezoutsky  
Samuel Tremblay Newbie 4 posts since
2010-10-31
Currently Being Moderated

Jan 9, 2013 8:18 PM

Adding blank line before the 'return' statement while using 'Extract method'

Hi,

 

I'm wondering to know if it exist an option to add a blank line before the 'return' statement while using the 'Extract method' refactoring feature.

 

For example, I have this method:

 

      private int ExtractMethodWithNiceFormatting()
      {
         int a = 1;
         int b = 1;
         int c = 1;
         int d = 2;

 

         int total1 = a + b;
         int total2 = c + d;
         int grandTotal = total1 + total2;

 

         return grandTotal;
      }

 

And when I try to extract the total computing part, here is what I get:

 

      private int ExtractMethodWithNiceFormatting()
      {
         int a = 1;
         int b = 1;
         int c = 1;
         int d = 2;

 

         var grandTotal = GetTotal(a, b, c, d);

 

         return grandTotal;
      }

 

      private static int GetTotal(int a, int b, int c, int d)
      {
         int total1 = a + b;
         int total2 = c + d;
         int grandTotal = total1 + total2;
         return grandTotal;
      }

 

As you can see, there is no blank line before the statement 'return grandTotal'.

 

What I want is:

 

      private static int GetTotal(int a, int b, int c, int d)
      {
         int total1 = a + b;
         int total2 = c + d;
         int grandTotal = total1 + total2;


         return grandTotal;
      }

 

Also, in some cases, resharper must add some new variables while extracting method and if it possible, it would be nice to have a blank line after these variables declaration.

 

Thank you very much.

Alex Berezoutsky JetBrains 456 posts since
2011-2-18
Currently Being Moderated
Jan 14, 2013 5:49 PM in response to: Samuel Tremblay
Re: Adding blank line before the 'return' statement while using 'Extract method'

Hi Samuel,

 

There's no such formatting option in Resharper for now, so I've logged it as a feature request here in YouTrack: http://youtrack.jetbrains.com/issue/RSRP-337283.

 

Thank you.

Alex Berezoutsky JetBrains 456 posts since
2011-2-18
Currently Being Moderated
Jan 15, 2013 1:26 PM in response to: Samuel Tremblay
Re: Adding blank line before the 'return' statement while using 'Extract method'

You are welcome, Samuel!

More Like This

  • Retrieving data ...