code-butler 3.0.2

dotnet tool install --global code-butler --version 3.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local code-butler --version 3.0.2
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=code-butler&version=3.0.2
                    
nuke :add-package code-butler --version 3.0.2
                    

code-butler dotnet tool

A dotnet tool for your C# files at your service.

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

  1. reorganizing the layout of the members in the C# file to follow Microsoft's StyleCop conventions
  2. sorting it's using directives
  3. removes trailing whitespace and consecutive blank lines

Options

  • --no-sort-members-by-alphabet: Disables sorting members by alphabet. [default: false]

Reorganize the layout of members in a C# file to follow Microsoft's StyleCop conventions

First by type:

  1. Field
  2. Constructor
  3. Destructor
  4. Delegate
  5. Event
  6. Enum
  7. Interface
  8. Property
  9. Indexer
  10. Operator
  11. Method
  12. Struct
  13. Class

Then by access modifier:

  1. public
  2. internal
  3. protected
  4. protected internal
  5. private protected
  6. private

Then by additional modifiers:

  1. const
  2. static readonly
  3. static
  4. readonly
  5. 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:

  1. "Normal" using directives
  2. Aliased using statements (e.g. using MyAlias = Example.Bar)
  3. 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

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`

# Do not sort members by alphabet
dotnet-code-butler path/to/MyClass.cs --no-sort-members-by-alphabet
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
3.0.2 3,390 6/4/2024
3.0.1 1,157 3/16/2024
3.0.0 206 3/16/2024