How can I sort Fields, Properties and Methods in Visual Studio?

前端 未结 5 1394
迷失自我
迷失自我 2020-12-29 18:08

I know that for clarity in codes, I have to write first fields then constructor and then methods etc. But how can I automate it in Visual Studio?

5条回答
  •  再見小時候
    2020-12-29 18:56

    If Code Sorting is your only concern, you can try the Visual Studio Extension CodeSorter

    CodeSorter is highly customizable extension that allows its users to sort C# code itby various conditions such as names, types (method, class, struct, ...), visibility modifiers (private, public, ...), constness modifiers (const, static, readonly) and virtuality modifiers (virtual, override, new, ...).

    It is possible to assign multiple search criteria to have the same priority, for example place protected and private members first, and then publics and internals.

    Names are compared in a way that leading "m_" and "_" is stripped. This allows fields and properties (eg. _foo and Foo) to be right next to each other.

    One-lined declarations are placed without delimiting blank line, while multi-lined declarations are separated by a blank line. The exception is that one-lined field followed by a multi-lined property without comment of the same name will be placed without the delimiting blank line.

提交回复
热议问题