Need help with prettier-plugin-csharp?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

warrenseine
235 Stars 9 Forks MIT License 136 Commits 6 Opened issues

Description

Prettier C# Plugin

Services available

!
?

Need anything else?

Contributors list

# 41,781
Shell
Android
webfont...
GraphQL
115 commits
# 555,498
JavaScr...
C#
grammar
antlr
17 commits
# 297,244
C#
Shell
Rust
gameeng...
1 commit

:construction: Work in Progress! :construction:

Prettier C#

Prettier C# Plugin

Gitter Travis npm version code style: prettier Follow+Prettier+on+Twitter

Intro

Prettier C# adds C# support to the Prettier code formatter. Like Prettier, it is opinionated and restricts style options to a minimum. It runs where Prettier runs, including CI and pre-commit hooks.

WORK IN PROGRESS

Please note that this plugin is under active development, and might not be ready to run on production code yet. It will break your code.

Preview the result with this diff example.

Install

yarn add --dev --exact prettier prettier-plugin-csharp

Use

prettier --write "**/*.cs"

How it works

The plugin is written in JavaScript. It depends on the JavaScript port of ANTLR and relies on a fork of an unofficial C# 6 grammar from ANTLR. The grammar is precompiled to plain JavaScript and ready to use in the project.

Contributing

Installing dependencies

Use your favorite Node package manager:

yarn

Updating the grammar

The grammar supports C# 6 as a baseline, and tries to catch up with recent additions. Contributions are welcome. To update the grammar:

  • Update
    src/csharp/*.g4
    files.
  • Ensure you have Java 8+ installed on your machine.
  • Fetch a local copy of ANTLR:
yarn fetch-antlr
  • Generate the JavaScript parser:
yarn generate-parser

Testing

The project is developed against a single grammar-complete regression test. There are no unit tests for the moment.

Run the test with:

yarn test

To test it out on an actual C# file:

  • Clone this repository.
  • Run
    yarn
    .
  • Run
    yarn prettier Your/File.cs
    to check the output.

Maintainers

      Warren Seine
    </a>
  </td>
</tr>

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.