Format Code - Regions and Using Statements

6 posts, 0 answers
  1. Daniel
    Daniel avatar
    17 posts
    Member since:
    Nov 2004

    Posted 14 Oct 2010 Link to this post

    The Format Code function does not seem to work very well with code regions or using statements.  For example, when you format code and organize usings on the following (with sorting options enabled):

    using MyServices.Database.Lookups; 
      
    using System; 
    using System.Data; 
    using System.Web.UI.WebControls; 
      
    namespace MySolutions.Web.UI 
        public class MyRadioButtonList : RadioButtonList 
        
            #region Initialization 
        
            protected override void OnInit( EventArgs e )

    the result is this:

    using MyServices.Database.Lookups; 
    using System.Web.UI.WebControls;
    using System.Data;
    using System;
      
    namespace MySolutions.Web.UI 
        public class MyRadioButtonList : RadioButtonList 
        
            #region Initialization 
            protected override void OnInit( EventArgs e )

    while the desired result is this:

    using System; 
    using System.Data; 
    using System.Web.UI.WebControls; 
      
    using MyServices.Database.Lookups; 
      
    namespace MySolutions.Web.UI 
        public class MyRadioButtonList : RadioButtonList 
        
            #region Initialization 
              
            protected override void OnInit( EventArgs e )


    Handling of code regions does not appear to be implemented at all, unless I am overlooking something.  I divide every class into logical groups using code regions, and it would be great to reorder and sort code elements when formatting, but Format Code appears to ignore the code regions, which obliterates my logical groups.

    I have been a strong supporter of Telerik for many years, and I would love to replace ReSharper with Telerik's JustCode, but issues like these will need to be addressed before I am able to do so.
  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 14 Oct 2010 Link to this post

    Daniel,

    I have to say that I did as you are doing now, back in the day, grouping all my private methods, then event handlers then, then...

    I too was a bit miffed when I first started using JC until I realised that with the sorting options on, it was actually sorting the code pretty much as I had been trying to do manually, so I stopped worrying about it.

    I guess that if you're using a different scheme for grouping your methods, for example Initialization, Navigation, that kind of thing then what you end up with when JC has done it's thing is totally screwing you and I'm not sure that there is much to be done about that except for switching the sorting options off. I've no idea what formatting without the sorting options on will do to your code; I've never tried it.

    For me, the benefits I saw using JC quickly outweighed the negatives. But, your mileage may vary.

    -- 
    Stuart
    -- 
    Stuart
  3. DevCraft banner
  4. Daniel
    Daniel avatar
    17 posts
    Member since:
    Nov 2004

    Posted 14 Oct 2010 Link to this post

    I appreciate the comments, Stuart.  Code regions are indispensable for me, so JC's code formatting feature is not usable for me in its current state.  Code formatting is also indispensable for me, so if there is no short-term solution to this then I will have to continue using ReSharper and re-consider JC at a later date.
  5. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 14 Oct 2010 Link to this post

    Just out of interest, did you try formatting with the sorting options switched off?

    -- 
    Stuart
  6. Daniel
    Daniel avatar
    17 posts
    Member since:
    Nov 2004

    Posted 15 Oct 2010 Link to this post

    Yes, I turned the sorting options off, but the Format Code function still removes blank lines where I do not expect it to, even after I have disabled all of the options that appear to control formatting of blank lines.
  7. Svetlozar
    Admin
    Svetlozar avatar
    269 posts

    Posted 27 Oct 2010 Link to this post

    Hello Daniel,

    Thank you for your feedback. As you already gave us your suggestions in another thread -
     - http://www.telerik.com/community/forums/justcode/code-analysis/add-ability-to-ignore-certain-warnings.aspx and we logged these issues in our system, I will close this ticket.

    If you have any other problems or suggestions, please don't hesitate to write back.

    Sincerely yours,
    Svetlozar Angelov
    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