Below are some issues I came across while trying the CodeRush Preview CleanUp/Organize Members feature. I have setup my "Organize Members" Rules such that a separate region surrounds fields, properties, and methods.
-The #region is placed between the summary comment and member of the first member in a given group. The #region tag should precede the summary/comment.
C#/// <summary>
/// My field int1
/// </summary>
#region Fields
public int MyFieldInt1;
/// <summary>
/// My field int2
/// </summary>
public int MyFieldInt2
#endregion
-If you execute "Organize Members" multiple times strange things occur. From the second time on the Delegates are moved to the top of the file. More specifically it is moved just above the first member group that has a region. For example if the first group that has a surrounding #region is properties then the delegates will be placed just above properties.
C#/// <summary>
/// Delegate - Moved to the top from second CleanUp execution onward
/// </summary>
#region Delegates
public delegate int MyDelegate(float myVar = 5f);
#endregion
-The option "Use explicit this qualifier for fields" places "this" in front of static variables which is an error.
C#private static Int myInt = 0;
static MyStaticMethod() {
// This is a compile error
this.myInt = 1;
}
-Not exactly sure what is happening with spacing, but it would be nice if it was consistent. For example 2 blank lines are placed between #endregion and start of next #region. Personally I think everyone would be happy with the 2 options listed below. I would select both these options yielding exactly 1 blank line between members. Perhaps some would unselect minimum so that they could manually have some members touching. So much screen real estate is lost because multiple blank lines are left everywhere during development/refactoring.
-Place a minimum of 1 blank line between class members.
-Condense multiple blank lines anywhere into a single blank line.
C# #region Fields
//Comment
public int MyFieldInt1;
//CR - CodeRush add blank line
//Comment
private int xxx;
#endregion
//CR - CodeRush removes extra blank lines
#region Properties
public int MyAutoInt1 { get; set; }
public int MyInt { get { return 5; } }
#endregion
Thank you for your feedback. We greatly appreciate it.
To process it more efficiently, I created separate tickets on your behalf for the first three issues:
Organize Members - A surrounded region for a members group incorrectly starts after the first member's comment
Organize Members - The 'Delegates' group is placed at the incorrect position after being re-applied
Code Cleanup - 'Use explicit this qualifier for fields' should not affect static fields
These tickets are currently in our processing queue. Our team will address them shortly.
Concerning line breaks options for members in a group and groups, we have plans to implement this functionality in the future.