codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

Feature Request - Move all private fields to top

Open AeroClassics opened this issue 7 years ago • 7 comments

Can CodeMaid or could CodeMaid gather up all the private variables and move them to the top of the class? Example:

public partial class MyWindow : Window { private string _name; private int _someInt; }

AeroClassics avatar Nov 22 '16 23:11 AeroClassics

Yes, that's our reorganizing feature. Check it out in the docs here: http://www.codemaid.net/documentation/#reorganizing

codecadwallader avatar Nov 23 '16 00:11 codecadwallader

Steve, Thanks for the fast response. If this is true what's the trick? Here is a sample out of a file I just reorganized:

    /// <summary>
    /// Sets a value indicating whether [in dwell period].
    /// </summary>
    /// <value><c>true</c> if [in dwell period]; otherwise, <c>false

. public bool InDwellPeriod { set { _inDwellPeriod = value; } }

    /// <summary>
    /// Gets the ROI rectangle stroke.
    /// </summary>
    /// <value>The ROI rectangle stroke.</value>
    public Brush RoiRectangleStroke { get { return 

rectRoiControl.Stroke; } }

    /// <summary>
    /// The current state
    /// </summary>
    private InstrumentState _currentState;

    /// <summary>
    /// Based on the userSensitivity this is the actual sensitivity to 

use when analyzing ///

    private float analyzerSensitivity = 0;
    /// <summary>
    /// The Roi type
    /// </summary>
    private RoiType _roiType;

As you can see there are privates after, or mixed in, with publics. What option changes this?

Best Regards / Mit freundlichen Grüßen, Doug

Douglas R. Jones Sr. Software Engineer/AdVISE Project Mgr. Rohde & Schwarz USA, Inc. 1500 Lakeside Parkway Ste 100 Flower Mound, TX 75028 Mobile: +1 214-601-3301 Office: +1 469-713-5344 E-Mail: [email protected] Website: http://www.rohde-schwarz.com/

From: Steve Cadwallader [email protected] To: codecadwallader/codemaid [email protected] Cc: AeroClassics [email protected], Author [email protected] Date: 11/22/2016 06:35 PM Subject: [Newsletter] Re: [codecadwallader/codemaid] Feature Request - Move all private fields to top (#369)

Yes, that's our reorganizing feature. Check it out in the docs here: http://www.codemaid.net/documentation/#reorganizing ? You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

AeroClassics avatar Nov 23 '16 00:11 AeroClassics

That's not what I would have expected. A couple things to check:

  1. When you run reorganize, are you seeing any changes take place? In the Visual Studio status bar at the bottom, does CodeMaid say that it ran or that it had to stop? If it stopped, can you check the Output tool window to get any error messages that would have been logged?
  2. If reorganize is running, but not putting things in the expected order - can you check your configuration (CodeMaid->Options->Reorganizing) to make sure the Types are in the expected order? The default settings order is that Fields come first.

If neither of those help, if you can include a full code file sample and an export of your settings I may be able to help further.

codecadwallader avatar Nov 23 '16 12:11 codecadwallader

Is there a way to stop private fields to the top. I like to keep my full properties together?

ghd796 avatar Aug 19 '22 16:08 ghd796

You can customize how things are reorganized (e.g. group fields and properties together and consider them the same thing for reorganization). There is not a way to "opt out" of certain elements being reorganized. Conceptually this would be a bit difficult as it wouldn't be clear where "opted out" elements would go in the file.

codecadwallader avatar Sep 01 '22 19:09 codecadwallader

You can customize how things are reorganized (e.g. group fields and properties together and consider them the same thing for reorganization). There is not a way to "opt out" of certain elements being reorganized. Conceptually this would be a bit difficult as it wouldn't be clear where "opted out" elements would go in the file.

I don't think I'm looking to "opt out" per say. I don't mind the properties being pulled to the top. I just would like the entire 'full property to stay together. ex. when you use the [propfull] snippet built into visual studio it groups the related private and public properties together like this

` private int property1; public int Property1 { get { return property1; } set { property1 = value; } }

    private int property2;
    public int Property2
    {
        get { return property2; }
        set { property2 = value; }
    }

`

I prefer to keep these property 'sets' together rather than separating out the private and public properties the way codemaid does it.

` private int property1;

    private int property2;

    public int Property1
    {
        get { return property1; }
        set { property1 = value; }
    }
    public int Property2
    {
        get { return property2; }
        set { property2 = value; }
    }

`

How would I go about getting codemaid to keep the sets together?

ghd796 avatar Sep 02 '22 15:09 ghd796

Ok, thanks for that clarification. There is not currently support for it, but there is an open feature request #570

codecadwallader avatar Sep 09 '22 12:09 codecadwallader