3 ms·
dotnet format [0] exists and is maintained by the .NET team. It is different from Prettier in that it is much more configurable, but it gets the job done for us
by Cu3PO42 1y ago
dotnet format [0] exists and is maintained by the .NET team. It is different from Prettier in that it is much more configurable, but it gets the job done for us. It does integrate language services and can automatically apply code fixes for custom analyzers. I have not explicitly tried roslynator or stylecop, but I suspect this would work as expected.
[0] https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-format https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-f...
- rafaelmn 1y ago> It is different from Prettier in that it is much more configurable I only tried it briefly but found it was waaay to lenient with the amount of variance in style it left unchanged (eg line breaks for function parameters) - can it get configured to produce consistent formatting like prettier ?
- Cu3PO42 1y agoIt can be configured to be much more aggressive with formatting, but I'm not certain if you can force it to produce the exact same output for any possible whitespace in the input.
- eterm 1y agoI think there are also a lot of default rules which aren't enforced until they're bumped up in severity in the .editorconfig. Also it can hook into roslyn analyzers, so if you want a more opinionated analyzer then stylecop analyzers ( https://github.com/DotNetAnalyzers/StyleCopAnalyzers https://github.com/DotNetAnalyzers/StyleCopAnalyzers) would be an option, although I haven't used it myself for a long time.
- jswny 1y agoThe problem is that dotnet format is horribly slow. So much so that it's only useful as a precommit hook
- malkia 1y agoI was not able to use (recent) dotnet-format as standalone .exe tool, also it only worked if inside an actual project with .sln/.slnx file and all that. I could not instruct it to work on single file.