Bug Report T576693
Visible to All Users

Code Cleanup - Applying the Make Properties auto-implemented rule produces uncompilable code

created 7 years ago

Hi,

I currently have "Make Properties auto-implemented" turn ON. turning the option off doesn't have the issue.

Given this class:

C#
public class Class2 { private TreeDataCollectionBase m_Collection; public TreeDataCollectionBase Collection { get { return m_Collection; } } public void DeleteNode(string key) { m_Collection.Remove(key); } public void PopulateTreeNodes() { m_Collection.Sort(); this.Collection.Sort(); } }

You can see that the "m_Collection" variable has the Remove() and Sort() methods on it in the two methods at the bottom of the class, (Note I've added a 2nd call to the sort method to explain another issue below. When I run code clean up with the option mentioned above turned ON, the code looks like this:

C#
public class Class2 { public TreeDataCollectionBase Collection { get; private set; } public void DeleteNode(string key) => this.Collection(key); public void PopulateTreeNodes() { this.Collection(); Collection.Sort(); } }

As you can see, the "m_collection" variable has gone (which is what I want) the two lines in the methods (DeleteNode & PopulateTreeNode) are now missing the calls to the Remove() and Sort() methods. I've bold the section where it should have the calls.

Also I have it set to remove the "THIS" part as well as it just clutters the code, but no matter how many times I press clean up, it's not removed from these two lines (but generally is) the word "this" is not faded in the above two cases. I've added in the first example the "this.Collection.Sort()" line to show that "this" is removed when done like this initially.

Hope this helps.
Alan

Show previous comments (3)
DevExpress Support Team 7 years ago

    Alan,
    Thank you for the update.

    In your case, I recommend you to keep one code style option for code cleanup, which you prefer to use in most cases ("Use Expression Bodies"). This will allow you to apply this property style in the batch manner (apply to multiple properties at the same time). And if you want to apply the different style for the particular property (e.g. Auto-Implemented), I recommend you use the Quick Action menu (Ctrl + . or Ctrl + ~) and execute the appropriate action.

    AM AM
    Alan Middleton999 7 years ago

      This makes sense to do and the expression bodies is the best one to have on, but I've always had the two options turned on and not had a problem before so I think this is a new bug recently introduced - looking at the screen shot you provided the difference screen (red/green lines) even shows the .Remove() and .Sort() method calls removed.

      Once it's been fixed I'll retest and see how it goes. Thanks.

      DevExpress Support Team 7 years ago

        Alan,
        Thank you for the update.

        We are working on a fix for the problem with unexpected removing of .Remove() and .Sort() method calls. We will update this ticket when the solution is ready.

        Answers approved by DevExpress Support

        created 7 years ago (modified 7 years ago)

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          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.