Clean, but not properly clean

10 posts, 1 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 24 Mar 2011 Link to this post

    I'm in the process of patching some code in a number of WCF services that have never been visited by a JC user.

    These methods have no ordering of methods at all.

    My default cleaning profile is set to reorder the methods using the default ordering profile.

    If I ctrl-shift-alt-F on a file, it does a number of things including removing unused using clauses and the like, but what it doesn't do is reorder the methods. However, if I ctrl-shift-alt-F a second time, it does.

    A little odd.

    -- 
    Stuart
  2. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 24 Mar 2011 Link to this post

    Where do you specify ordering?

    I would love to have it sort like this
    - Page LifeCycle
    - Methods
    - Properties
    - Events
    ...and then sort each alphabetically

    Wishlist is wrapping all those in #regions :)
  3. DevCraft banner
  4. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 24 Mar 2011 Link to this post

    Steve,

    From the JustCode menu in VS select Options|Code Style|C#|Ordering.

    You'll see what you can and can't get once you're there.

    I've not really looked in to this too closely 'cos I don't use regions in my code (I don't like 'hiding' code), but I think that if you create regions, your code is ordered inside them.

    -- 
    Stuart
  5. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 30 Mar 2011 Link to this post

    Anyone?

    -- 
    Stuart
  6. Blagoev
    Admin
    Blagoev avatar
    49 posts

    Posted 06 Apr 2011 Link to this post

    Hi Stuart Hemming,

    I can reproduce this for alphabetic ordering option. If you have internal and public method the public one will be moved ahead of the internal one. Still this does not work for alphabetically similar elements option. Thats a bug and we will work on fixing that. I created a PITS 5407 for that. Thanks taking the time reporting this.

    There are some problems when the file has regions in it and we decided to disable reordering in that case for now.

    Best wishes,
    Blagoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Blagoev
    Admin
    Blagoev avatar
    49 posts

    Posted 06 Apr 2011 Link to this post

    Hi Stuart Hemming,

    I can reproduce this for alphabetic ordering option. If you have internal and public method the public one will be moved ahead of the internal one. Still this does not work for alphabetically similar elements option. Thats a bug and we will work on fixing that. I created a PITS 5407 for that. Thanks taking the time reporting this.

    There are some problems when the file has regions in it and we decided to disable reordering in that case for now.

    Best wishes,
    Blagoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 06 Apr 2011 Link to this post

    It might just be me, but I have a real thing about regions in code.

    I understand the principle, I just hate having whole chunks of code hidden from me.

    I'd like to see 'Clean' options to:
    1. remove all regions
    2. reorder (using the normal JC ordering rules) inside individual regions.

    Option 1 for me, Option 2 for those who like to see these things in their code.

    -- 
    Stuart
  9. Answer
    Blagoev
    Admin
    Blagoev avatar
    49 posts

    Posted 07 Apr 2011 Link to this post

    Hi Stuart Hemming,
    There is such request for removing regions. Also there is a stylcop waring about this, thats why many people want it. We will work on delivering such functionality.

    As for reordering within regions there are some cases when thats event not possible. Consider this code
    #region 
    public void Start()
    {
    #endregion
    ....
    }
    this is legal and produces no errors on build. We are still considering all the odds about such a feature.

    Thanks for sharing your thoughts.

    Regards,
    Blagoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 07 Apr 2011 Link to this post

    Please, Just Stuart will do.

    Glad to hear you are considering a remove regions option.

    FWIW, I think that this should include (as an option, at least) regions /inside/ methods. For example
    void MyMethod()
    {
      int i = 0;
     
      #region
      // let's just hide some code in here
      # endregion
     
      // more code
    }

    I see this in legacy code more often than I'd like and whilst it's not as bad as the example you shared (Gods, but do people /really/ do that?) it is still nasty.

    -- 
    Stuart

  11. Blagoev
    Admin
    Blagoev avatar
    49 posts

    Posted 08 Apr 2011 Link to this post

    Hello Stuart Hemming,
    Thanks. We will provide such an option to remove regions in member body only. Good suggestion.

    All the best,
    Blagoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner