This is a migrated thread and some comments may be shown as answers.

Format Code - Regions and Using Statements

5 Answers 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel
Top achievements
Rank 1
Daniel asked on 14 Oct 2010, 05:49 PM
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.

5 Answers, 1 is accepted

Sort by
0
Stuart Hemming
Top achievements
Rank 2
answered on 14 Oct 2010, 07:16 PM
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
0
Daniel
Top achievements
Rank 1
answered on 14 Oct 2010, 07:29 PM
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.
0
Stuart Hemming
Top achievements
Rank 2
answered on 14 Oct 2010, 09:13 PM
Just out of interest, did you try formatting with the sorting options switched off?

-- 
Stuart
0
Daniel
Top achievements
Rank 1
answered on 15 Oct 2010, 05:46 AM
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.
0
Svetlozar
Telerik team
answered on 27 Oct 2010, 07:04 AM
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
Tags
General Discussions
Asked by
Daniel
Top achievements
Rank 1
Answers by
Stuart Hemming
Top achievements
Rank 2
Daniel
Top achievements
Rank 1
Svetlozar
Telerik team
Share this question
or