Ticket T346361
Visible to All Users

CodeRush for Roslyn Code CleanUp issue

created 9 years ago (modified 9 years ago)

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
Comments (1)
DevExpress Support Team 9 years ago

    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.

    Answers approved by DevExpress Support

    created 9 years ago (modified 9 years ago)

    Hi Kevin,
    We have introduced the requested functionality in the latest build, 1.0.11. On the 'Organize members' options page, you can set line breaks options for both groups and members in the groups.

      Comments (2)

        How very cool you guys implemented my exact suggestion.  The improvements on 1.0.11 are very helpful.  On the new "line breaks" options I have a few concerns below.  Again my "Organize Members" options are setup to create a separate Region around each member type (ie. Fields, Properties, Methods…).

        Settings:
        Empty line count between groups = 1
        Remove existing line breaks = Checked
        Methods Region "Emply line count between members"=1
           Methods "Emply line count between members"=0

        Issues:
        -All but the first created region, in the class, start out with a line-break between the #region and the comment of the first encompassing member.  The preferred solution is no line-break anywhere, which is like #endregion.

        -Both my "Methods" rule and surrounding "Method Region" have the option "Empty line count between members".  Since a Region rule can only contain 1 rule I guess both options are talking about the same spacing?  However only the "Method Region" option has any effect on spacing.   In my humble opinion a Region rule should be allowed to have multiple child rules in which case having "Empty line count between members" at both levels make sense.  In this case the options make sense, but still need to be fixed to do the right thing.

        Thanks,

        AE AE
        Alex Eg (DevExpress) 9 years ago

          Hello,

          I've created a separate ticket on your behalf (Organize Members - Line breaks behavior inside regions should be improved). It has been placed in our processing queue and will be answered shortly.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.