# prettier-csharp

> Prettier C# Plugin

Latest version **0.5.0-development** (published 2019-01-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install prettier-csharp
pnpm add prettier-csharp
yarn add prettier-csharp
bun add prettier-csharp
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0-development |
| Published | 2019-01-22 |
| First published | 2018-05-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 251 |
| Author | Warren Seine |
| Maintainers | warrenseine |

## Links

- npm: https://www.npmjs.com/package/prettier-csharp
- Repository: https://github.com/warrenseine/prettier-csharp
- Homepage: https://github.com/warrenseine/prettier-csharp#readme
- Issues: https://github.com/warrenseine/prettier-csharp/issues
- npm.io page: https://npm.io/package/prettier-csharp

## Dependencies (4)

- [antlr4](https://npm.io/package/antlr4.md) ^4.7.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.11
- [prettier](https://npm.io/package/prettier.md) ^1.15.3
- [is-alphanumerical](https://npm.io/package/is-alphanumerical.md) ^1.0.2

## Recent versions

- 0.5.0-development (latest) — 2019-01-22
- 0.4.0-development — 2019-01-17
- 0.3.0-development — 2019-01-15
- 0.2.3-development — 2018-12-05
- 0.2.2-development — 2018-06-07
- 0.2.1-development — 2018-06-07
- 0.2.0-development — 2018-06-07
- 0.1.0-development — 2018-05-24

## README

<p align="center">
    :construction: Work in Progress! :construction:
</p>

<div align="center">
<img alt="Prettier"
  src="https://cdn.rawgit.com/prettier/prettier-logo/master/images/prettier-icon-light.svg">
<img alt="C#"
  hspace="25"
  height="210"
  src="https://upload.wikimedia.org/wikipedia/commons/4/4f/Csharp_Logo.png">
</div>

<h2 align="center">Prettier C# Plugin</h2>

<p align="center">
  <a href="https://gitter.im/jlongster/prettier">
    <img alt="Gitter" src="https://img.shields.io/gitter/room/jlongster/prettier.svg?style=flat-square">
  </a>
  <a href="https://travis-ci.org/warrenseine/prettier-csharp">
    <img alt="Travis" src="https://img.shields.io/travis/warrenseine/prettier-csharp/master.svg?style=flat-square">
  </a>
  <a href="https://www.npmjs.com/package/prettier-csharp">
    <img alt="npm version" src="https://img.shields.io/npm/v/prettier-csharp.svg?style=flat-square">
  </a>
  <a href="#badge">
    <img alt="code style: prettier" src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square">
  </a>
  <a href="https://twitter.com/PrettierCode">
    <img alt="Follow+Prettier+on+Twitter" src="https://img.shields.io/twitter/follow/prettiercode.svg?label=follow+prettier&style=flat-square">
  </a>
</p>

## Intro

Prettier C# adds C# support to the [Prettier](https://github.com/prettier/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](https://github.com/warrenseine/prettier-csharp-demo/pull/1/commits/8652271a499740b726e6342346e97447abd23162).

## Install

```bash
yarn add --dev --exact prettier prettier-csharp
```

## Use

```bash
prettier --plugin=prettier-csharp --parser=cs --write "**/*.cs"
```

## How it works

The plugin is written in JavaScript. It depends on the JavaScript port of ANTLR and an
[unmodified unofficial C# 6 grammar from ANTLR](https://github.com/antlr/grammars-v4/tree/master/csharp).
The grammar is precompiled to plain JavaScript and ready to use in the project.

## Contributing

### Updating the grammar

- Copy the latest version of the [grammar](https://github.com/antlr/grammars-v4/tree/master/csharp) to `asset/csharp`
- Install ANTLR:

```bash
brew install antlr4 # on macOS
```

- Generate the JavaScript parser:

```bash
yarn install
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:

```bash
yarn test
```

To test it out on an actual C# file:

- Clone this repository.
- Run `yarn`.
- Create a file called `test.cs`.
- Run `yarn prettier test.cs` to check the output.

## Maintainers

<table>
  <tbody>
    <tr>
      <td align="center">
        <a href="https://github.com/warrenseine">
          <img width="150" height="150" src="https://github.com/warrenseine.png?v=3&s=150">
          </br>
          Warren Seine
        </a>
      </td>
    </tr>
  <tbody>
</table>

---
_Source: https://npm.io/package/prettier-csharp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
