JustCode 2011.2 916 -- C# reordering bug?

7 posts, 0 answers
  1. miksh
    miksh avatar
    275 posts
    Member since:
    Nov 2006

    Posted 28 Sep 2011 Link to this post

    I wonder can JustCode automatically reorder from

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
     
    namespace MyNamespace
    {
        public class Class1
        {
        }
    }


    to

    namespace MyNamespace
    {
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
     
        public class Class1
        {
        }
    }


    When I configure Options-Code Style-C#-Ordering with Using followed by Namespace it results in invalid code:

    namespace MyNamespace
    {
        public class Class1
        {
      }
      }using System
      ;using System.Collections.Generic
      ;using System.Linq
    ;using System.Text;
  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 28 Sep 2011 Link to this post

    Miksh,

    In short, yes it can. I'll go as far as to say, not only can it but it does. Normally.

    There are, you'll find, if you look at PITS, a number of reordering bugs. I know 'cos I logged a number of them. Most of my reported problems are, like yours,, to do with the usings clauses.

    It might be of small consolation ATM, but the guys at telerik towers are working on these issues and each new release brings us closer to a full fix. I guess we just have to wait it out.

    -- 
    Stuart
  3. DevCraft banner
  4. Svetlozar
    Admin
    Svetlozar avatar
    271 posts

    Posted 29 Sep 2011 Link to this post

    Hi,

    People tend to get confused with the reordering (formatting) in that case. We definitely want to support that case, but we don't think that the reordering (formatting) is the right way to do this. Consider the case when you have several namespace declarations in one file and you want to move the usings that are before the first namespace inside the namespace declarations, It is more like a refactoring than a reordering. Where you want to place the using statements is a matter of code style and we have done some progress on that lately. For example if you have your usings in a namespace declaration Organize And Add Missing Usings will place them in the right location(in the namespace). The same goes for Add Using for... we know where we have to put the usings according to your existing code style. We think that the best solution for that case would be to create a code style option and make the refactorings that touch the usings obey this option (they will make the transition you want). Please, let us know if you have any comments or suggestions regarding that subject.

    As for the reordering, the reordering does exactly what it is told, to put the usings after the namespace declaration (not inside). We are aware that we break the code in that case and we will improve the configuration dialog to not let you do that (this is already logged in our product backlog).


    Regards,
    Svetlozar
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. miksh
    miksh avatar
    275 posts
    Member since:
    Nov 2006

    Posted 29 Sep 2011 Link to this post

    Thanks Svetozar, I completely agree with you.
    I would appreciate if JustCode refactroing option (or command) could switch between "namespace-and-nested using" (for StyleCop users) and "using/namespaces on the same level" (for VS users) code styles. I believe that everyone could understand that ot might not work properly for complex cases with several namespaces etc - which most likely is a bad coding style.
  6. Svetlozar
    Admin
    Svetlozar avatar
    271 posts

    Posted 30 Sep 2011 Link to this post

    Hello Miksh,

    I increased the priority of this item, but I can't promise you anything for the Q, we already have a lot to do for the official release. Please, stay tuned.

    Regards,
    Svetlozar
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  7. Mark
    Mark avatar
    1 posts
    Member since:
    Jun 2012

    Posted 17 Sep 2012 Link to this post

    Hi,

    Here we are, a year later and I have hit the same issue. I have been persuaded to try JustCode (I am usually a happy Resharper user). I have managed to trash my code three times in the last ten minutes using JustCode's reordering. I don't remember EVER trashing code with Resharper's "code cleanup". Supporting using statements within the namespace is important to me idealogically. If reordering is not the correct way to do it, then the option should be removed, to be replaced with another somewhere else. B.t.w. I am using JustCode v2012.2.912.3.

    Are there updates on the way?

    Thanks
  8. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 20 Sep 2012 Link to this post

    Hi,

     Thanks for contacting us.
    If you want to reorder your Using directives and put them in the namespace by using the Ordering option is not the right way. We only order blocks that are on the same level there.

    Unfortunately, we haven't still implemented  a command that doing this. Probably, we also have to disable the option to set the Using directives after the Namespaces, because this is not a right syntax.
    I will raise the priority of this item, but most probably it won't be implemented this Q.
    Thanks and sorry for the inconvenience caused.

    Greetings,
    Zdravko
    the Telerik team

    Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

Back to Top
DevCraft banner