CSharpier 0.10.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global CSharpier --version 0.10.0
                    
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 CSharpier --version 0.10.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=CSharpier&version=0.10.0
                    
nuke :add-package CSharpier --version 0.10.0
                    

CSharpier

CSharpier is an opinionated code formatter for c#. It uses Roslyn to parse your code and re-prints it using its own rules. The printing process was ported from prettier but has evolved over time.
CSharpier provides a few basic options that affect formatting and has no plans to add more. It follows the Option Philosophy of prettier.

Work In Progress

CSharpier is still in active development and the rules it uses to format code are not yet finalized and will change over time.

If you can live with the fact that the formatting will be changing over time, it is safe to use. In addition to a steadily growing set of unit tests; csharpier is tested against ~60k c# files from a range of public repositories to validate it does not result in the lose of any source code.

Features

  • It is fast. It can format a solution of ~11,000 files in ~30 seconds.
  • It supports validating the syntax of the code it produces to ensure the only changes made were whitespace and line breaks.
  • It formats c# ⇐ 9.0 - c# 10 coming soon

Try it out at Playground

Before

public class ClassName {
    public string ShortPropertyName {
        get;
        set; 
    }

    public void LongUglyMethod(string longParameter1, string longParameter2, string longParameter3) { 
        this.LongUglyMethod("1234567890", "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    }
}

After

public class ClassName
{
    public string ShortPropertyName { get; set; }

    public void LongUglyMethod(
        string longParameter1,
        string longParameter2,
        string longParameter3
    )
    {
        this.LongUglyMethod(
            "1234567890",
            "abcdefghijklmnopqrstuvwxyz",
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        );
    }
}

Installation

dotnet tool install -g csharpier

Basic Usage

Run csharpier from the directory you wish to format to recursively format all .cs files

dotnet csharpier .

Run csharpier on a specific file

dotnet csharpier /src/UglyUnformattedFile.cs

MsBuild Package

If you prefer to have csharpier run when a project is built, you can use the CSharpier.MSBuild nuget package

Install-Package CSharpier.MSBuild

Documentation

Command Line Interface
Configuration File
Editors and CI/CD
Integrating with Linters/Formatters
Ignoring Files
ChangeLog
MSBuild Package

Contributing

See Development Readme

Join Us Discord

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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
1.2.5 169,419 12/31/2025
1.2.4 40,578 12/23/2025
1.2.3 71,778 12/14/2025
1.2.2 16,706 12/13/2025
1.2.1 345,963 11/10/2025
1.2.0 27,782 11/10/2025
1.1.2 924,886 8/16/2025
1.1.1 119,020 8/4/2025
1.1.0 7,603 8/3/2025
1.0.3 353,355 6/29/2025
1.0.2 369,823 5/24/2025
1.0.1 335,718 4/26/2025
1.0.0 100,484 4/22/2025
1.0.0-alpha99 316 4/13/2025
1.0.0-alpha84 169 4/19/2025
1.0.0-alpha83 155 4/19/2025
1.0.0-alpha81 263 4/13/2025
1.0.0-alpha80 183 3/15/2025
1.0.0-alpha46 245 2/22/2025
1.0.0-alpha45 335 2/22/2025
1.0.0-alpha44 171 2/21/2025
1.0.0-alpha43 211 2/14/2025
1.0.0-alpha33 196 2/9/2025
1.0.0-alpha32 234 2/2/2025
1.0.0-alpha24 174 1/26/2025
1.0.0-alpha22 172 1/26/2025
1.0.0-alpha21 183 1/21/2025
1.0.0-alpha20 150 1/20/2025
1.0.0-alpha10 666 1/20/2025
0.30.6 1,265,389 1/10/2025
0.30.5 109,865 1/3/2025
0.30.4 84,424 12/28/2024
0.30.3 288,721 12/7/2024
0.30.2 325,675 11/22/2024
0.30.1 61,435 11/18/2024
0.30.0 19,543 11/17/2024
0.29.2 655,761 9/15/2024
0.29.1 259,910 8/23/2024
0.29.0 76,359 8/17/2024
0.28.2 1,272,343 4/26/2024
0.28.1 226,881 4/16/2024
0.28.0 161,089 4/7/2024
0.27.3 458,782 2/18/2024
0.27.2 204,120 1/28/2024
0.27.1 39,935 1/24/2024
0.27.0 108,273 1/15/2024
0.26.7 259,418 12/16/2023
0.26.6 20,885 12/14/2023
0.26.5 103,844 12/10/2023
0.26.4 55,159 12/2/2023
0.26.3 108,900 11/23/2023
0.26.2 99,605 11/16/2023
0.26.1 52,711 11/9/2023
0.26.0 21,797 11/6/2023
0.25.0 798,348 6/25/2023
0.24.2 149,978 5/5/2023
0.24.1 73,361 4/26/2023
0.24.0 2,341 4/26/2023
0.23.0 166,874 3/6/2023
0.22.1 146,238 1/18/2023
0.22.0 36,634 1/15/2023
0.21.0 166,504 11/29/2022
0.20.0 122,100 10/3/2022
0.19.2 28,841 9/15/2022
0.19.1 84,155 8/27/2022
0.19.0 102,493 8/15/2022
0.18.0 98,586 6/13/2022
0.17.0 47,716 5/23/2022
0.16.0 96,266 3/26/2022
0.15.1 31,064 2/14/2022
0.15.0 2,405 2/9/2022
0.14.0 5,945 1/22/2022
0.13.0 4,057 1/3/2022
0.12.0 5,013 11/30/2021
0.11.1 1,247 11/15/2021
0.10.0 1,465 10/18/2021
0.9.9 1,629 8/23/2021
0.9.8 1,255 7/27/2021
0.9.7 744 6/26/2021
0.9.6 765 6/12/2021
0.9.5 1,052 6/1/2021
0.9.4 696 5/24/2021
0.9.3 653 5/18/2021
0.9.2 701 5/6/2021
0.9.1 602 5/5/2021
0.9.0 651 4/23/2021
0.8.9 589 4/12/2021
0.8.8 758 3/27/2021
0.8.7 602 3/22/2021
0.8.6 593 3/16/2021
0.8.5 604 3/12/2021
0.8.4 614 3/8/2021
0.8.3 700 3/8/2021
0.8.2 614 2/27/2021
0.8.1 880 2/22/2021