code-butler
3.0.0
See the version list below for details.
dotnet tool install --global code-butler --version 3.0.0
dotnet new tool-manifest
dotnet tool install --local code-butler --version 3.0.0
#tool dotnet:?package=code-butler&version=3.0.0
nuke :add-package code-butler --version 3.0.0
Code Butler
Code Butler is a dotnet tool and VS code extension for your C# files at your service.
This tool is heavily inspired by CodeMaid. As it is available as as a stand-alone version and as a 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
- (only in VS code extension) executing
Format Documentcommand.
as described below.
VS code extension
- Run code cleanup on save (disabled 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:
publicinternalprotectedprotected internalprivate protectedprivate
Then by additional modifiers:
conststatic readonlystaticreadonly- none
And finally alphabetically.
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
Visual Studio Code Extension
Execute command Code Butler: Cleanup C# file while editing a C# file to clean it up.
dotnet tool:
Install Code Butler as a global tool with the following command.
dotnet tool install --global code-butler
Then use the tool to cleanup your code.
# File mode
dotnet-code-butler path/to/MyClass.cs
# Pipe mode
type path/to/MyClass.cs | dotnet-code-butler > MyClass.Reorganized.cs`
Contributors
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.