codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

(Feature) Reorganizing: Add or preserve blank line before methods or ctor

Open birgersp opened this issue 3 years ago • 1 comments

Environment

  • Visual Studio version: 2019 Community
  • CodeMaid version: 11.2
  • Code language: C#

Description

When reorganizing, I think it would be preferable if all methods and constructors in a class has a blank line above it.

Steps to recreate

Reorganize this code:

class Foobar
{
	int b = 1;
	int a = 0;

	Foobar() { }
}

Current behavior

I get this:

class Foobar
{
	int a = 0;
	int b = 1;
	Foobar() { }
}

Expected behavior

I think most developers would agree that for readability it would be better if all methods and constructors has an empty line above it. So IMO the reorganized code should look like this:

class Foobar
{
	int a = 0;
	int b = 1;

	Foobar() { }
}

birgersp avatar Aug 21 '21 09:08 birgersp

Thanks for the suggestion! An easy workaround is to run CodeMaid's cleanup after reorganization which will re-insert that desired blank line. Reorganization focuses on moving elements into the correct order but cleaning is what covers that other stage of inserting/removing preferred spacing. Hope it helps!

codecadwallader avatar Aug 22 '21 13:08 codecadwallader