Search code examples
c#visual-studio-2010coding-stylestylecopvisual-studio-extensions

Is there a Visual Studio 2010 extension to sort methods?


StyleCop mandates a particular sort order for the contents of C# files. For example, fields should be declared before methods and public declarations should come before private ones.

It would be useful to have a Visual Studio extension to move these things into that order automatically.

Does a good extension exist for this (I've found CodeSorter, but the feedback suggests it's very buggy)? Or are there any extensions or shortcuts that make it less painful to reorder this content manually?


Solution

  • You can try with Regionerate :

    Regionerate is an automated tool which helps you to preserve your code's layout over time. Regionerate lets you define regions in your code and determine the way members (fields, methods, properties etc.) should be placed inside them. Regionerate is a zero-friction tool - when setting up, you can choose a Code Layout (the way you want your code to look) or just use the default Code Layout. From that moment on, Regionerate will make sure your code follows that Code Layout.