Code Butler for Visual Studio Code
This extension makes use of the dotnet tool code-butler to clean up you C# files.
This tool is heavily inspired by CodeMaid. As it is available as as a dotnet tool and Visual Studio Code extension, this tool will provide similar features.
Features
Using this tool will cleanup your C# file by
- reorganizing the layout of the members in the C# file to follow Microsoft's StyleCop conventions
- sorting it's using directives
- removes trailing whitespace and consecutive blank lines
- Executing the
Format Document command.
as described below.
Settings
- Run code cleanup on save (disabled by default)
- Sort members by alphabet (enabled by default)
Reorganize the layout of members in a C# file to follow Microsoft's StyleCop conventions
First by type:
- Field
- Constructor
- Destructor
- Delegate
- Event
- Enum
- Interface
- Property
- Indexer
- Operator
- Method
- Struct
- Class
Then by access modifier:
public
internal
protected
protected internal
private protected
private
Then by additional modifiers:
const
static readonly
static
readonly
- none
And finally alphabetically (optional).
Warning: #region ... #endregion is not supported.
Sort using directives
Sorts using directives alphabetically while placing System directives first and taking into account the following order:
- "Normal" using directives
- Aliased using statements (e.g.
using MyAlias = Example.Bar )
- Static using statements (e.g.
using static System.Math )
Example:
using System;
using Example;
using Example.Foo;
using MyAlias = Example.Bar;
using static System.Math;
Removes trailing whitespace and consecutive blank lines
- Removes trailing whitespace.
- Removes consecutive blank lines.
Prerequisites
Usage
Execute command Code Butler: Cleanup C# file while editing a C# file to clean it up.
| |