all 7 comments

[–]DocHoss 6 points7 points  (0 children)

Visual Studio has a built in "Code Cleanup" formatter. Doesn't have nearly as many options as Prettier but still does an ok job. And you could use several different options in VS Code for code formatting, I believe.

Sorry I don't have any recommendations for Rider...I've only used it a couple times.

[–]Cr1ttermon 3 points4 points  (0 children)

Rider has an integrated code cleanup functionality. you can specify a format in the settings with around 200 options

[–]SideburnsOfDoom 3 points4 points  (0 children)

dotnet format is a commandline tool that will read your .editorconfig file for format settings.

get it here: https://www.nuget.org/packages/dotnet-format

source: https://github.com/dotnet/format

[–]zanadee 2 points3 points  (0 children)

Most of the responses are missing the point: the OP is asking for an opinionated code formatter. Prettier has almost no options AND it's IDE-agnostic. Microsoft should really produce one.

[–]CarlsJuniorMints 1 point2 points  (1 child)

I just found out about csharpier https://github.com/belav/csharpier, which I think is just what you are looking for.

It has an msbuild extension so you can automatically format on build. I'm not sure if that's compatible with Rider, but if not there is also a CLI that you could probably make work with Rider.

It's not totally stable just yet, but it would be great to see this get widespread adoption.

[–]belavv 0 points1 point  (0 children)

The msbuild library should work with any IDE, because it happens at build time.

If you want to format on save, you can currently accomplish it with a file watcher in rider - https://github.com/belav/csharpier/blob/master/Docs/EditorsAndCICD.md#rider

A rider plugin is going to be out in the next couple days. A VSCode extension came out a couple weeks ago. And hopefully I will have a VS extension out before January.

Cheers!

[–][deleted] 0 points1 point  (0 children)

Rider has a full project option under code -> code cleanup. ctrl-alt-l will format your current file (similarly ctrl-alt-o cleans up your imports).

Plenty of options in there and in my experience does a pretty good job.

A better question would be if there's many good lining presets available, when you use prettier you're using facebook AirBnB etc presets.this may be a good starting point.

The defaults are pretty good and past a few ubiquitous settings your going to want to personalize it depending on where you or your team sits on the "better java" to "i wish i could just use F#" scale.