This request applies to Refactor! Pro as much as it applies to CodeRush, so I will post the same suggestion under that product.
When performing operations such as Move To Region, that moves code around in the file, or using Refactor! Pro to extract methods and other code modifying tools, it would be nice to specify a default line spacing between items. Currently code is moved or generated and sometimes there is one blank line separating the new item from the items around it, while other times ther are no blank lines between the items and everything is scrunched together.
This results in the code getting very messy after a while.
It would help maintain code cleanliness and organization if the user could define a few simple spacing rules, indicating their preferences for the number of lines separating items.
I know that each developer would have their own ideas about how this should be handled and I assume that a survey of various developer coding habbits and code organization techniques would be required to implement this properly. I will post my personal preferences here as something to start with.
Personally, I prefer no blank lines between member variables, one blank line between #Region definitions, and two blank lines surrounding methods, properties, and classes. The example class below shows a basic example o this formatting.
''' -----------------------------------------------------------------------------
''' Project : Company.Project.System.Namespace
''' Class : Project.System.Namespace.MyClass
''' -----------------------------------------------------------------------------
''' <summary>
''' Provides generic functionality for demonstration purposes.
''' </summary>
''' <remarks>
''' This class is created as an example and does not do any real work.
''' </remarks>
''' <history>
''' [user123] 3/23/2006 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class MyClass
#Region "Member Variables"
Private _Var1 As Integer
Private _Var2 As Integer
#End Region
#Region "Public Properties"
''' -----------------------------------------------------------------------------
''' <summary>
''' Gets or sets a value.
''' </summary>
''' <value>The value</value>
''' <remarks>
''' </remarks>
''' <history>
''' [user123] 3/23/2006 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Property Var1 As Integer
Get
Return _Var1
End Get
Set(ByVal Value As Integer)
_Var1 = Value
End Set
End Property
''' -----------------------------------------------------------------------------
''' <summary>
''' Gets or sets a value.
''' </summary>
''' <value>The value</value>
''' <remarks>
''' </remarks>
''' <history>
''' [user123] 3/23/2006 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Property Var2 As Integer
Get
Return _Var2
End Get
Set(ByVal Value As Integer)
_Var2 = Value
End Set
End Property
#End Region
End Class
Proposed Solution:
- Create a section in the configuration, that allows users to set their default preferences for spacing.
- Modify functionality in CodeRush and Refactor! Pro which moves/modifies code to ensure that the spacing rules are followed.
I noticed that there were a couple of updates today, to the following issue:
http://www.devexpress.com/Support/Center/p/S19229.aspx
The updates were a couple of "SEE ALSO" references.
I know that this issue has been marked as a duplicate, but it does contain a fairly verbose, distinct perspective on code formatting. I am wondering if you guys could update S19229, to reference this issue as well.
Thanks!
Sure, Todd … thank you for the note!
Regards,
Serge