Bug Report T618274
Visible to All Users

Organize Members - Nested types wrapped into a region are incorrectly processed

created 7 years ago

I have my own custom profile for Organise Members, but I'm struggling with one aspect of it. One style rule we have is that if a class has any other classes defined within it, then these should be declared above the parent class's methods. To facilitate this I've got two entries at the end of my profile, below the items I want explicitly placed above them (eg, fields, event declarations, etc). The first is a group by with "Kind" set to "Class". There is no sort on it, so that the class order remains as it was manually configured. Below that I have another group by, this time with "Kind" set to "Member". The intention was that the last two groups in my source file would be any child classes, followed by any members , however the child classes get moved to the bottom. Sort of

I have a test class I'm playing with as I write this, and I think I've just narrowed down the behaviour. My child classes are always in a region block. If I have a single class in a region above my methods, it remains there. If I add a second class to the region then the region containing the two classes is moved to the bottom of the source file. If I put each class in its own region then they both remain at the top of the file. This only seems to be an issue in a VB project, in C# it works fine

Here's a simple class that exhibits the problem:

Visual Basic
Public Class Atest #Region "test" Class one Property Test As String End Class Class two Property Test As String End Class #End Region Public Sub New() End Sub End Class

Running organise members on this should leave it untouched, but instead it moves the region below the constructor. Remove the region declarations and it behaves correctly. Remove one of the child classes and it behaves correctly.

I've attached my settings that include the rules

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

    Thank you for providing the screencasts and code samples.

    >  Here is a screencast that illustrates it working correctly on my PC

    Take note that CodeRush has separate Code Cleanup settings for C# and Visual Basic. In you provided settings, the "Organize Members" rule is enabled for Visual Basic and is disabled for C#. It causes different behavior for C# and Visual Basic code samples on your side.

    > However it has also wrapped the entire class in a region with the same name?!?

    You're right. Please accept my apologies for the incomplete instructions in my previous post.  I have attached the screencast that illustrates additional changes which are required to correct this behavior to this post.

    > it has stilled moved the region to the bottom of the file.

    I have reproduced this issue and we are working on it. As a temporary workaround, I suggest you enable the "Remove all regions" Code Cleanup rule and locate it before the "Organize Members" rule.

    Take note that other region directives will be removed and after applying Code Cleanup, a file will contain only region directives that are added by the Organize Members feature.

    KO KO
    Kevin O'Donovan 7 years ago

      Thanks Alexander - I should have realised that C#/VB had their own rulesets!

      As for the workaround, I think I'll need to wait for a proper fix - removing all regions would be a bit too destructive. That's fine though, I've grown used to avoiding organize members once the file has more than skeleton content in it , so I can certainly wait a bit longer!

      Thanks for your help,
      Kevin

      DevExpress Support Team 7 years ago

        You are welcome, Kevin.

        Answers approved by DevExpress Support

        created 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.