Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: How to csharpier in combination with dotnet-format #436

Closed
Strepto opened this issue Sep 13, 2021 · 5 comments
Closed

Request: How to csharpier in combination with dotnet-format #436

Strepto opened this issue Sep 13, 2021 · 5 comments

Comments

@Strepto
Copy link
Contributor

Strepto commented Sep 13, 2021

Hey, this tool looks great!

I would like to format my whitespace like csharpier, but also to use dotnet-format to fix "linting".

Is there a recommended approach to run both tools?

Thanks!

@Strepto Strepto changed the title Request: How to use in combination with dotnet-format Request: How to csharpier in combination with dotnet-format Sep 13, 2021
@belav
Copy link
Owner

belav commented Sep 13, 2021

I have not yet used dotnet-format and assumed it was concerned purely with formatting style, but it looks like there are a large number that are not formatting. See https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options?view=vs-2019

From my quick testing, there are definitely going to be formatting conflicts between csharpier and dotnet-format with how they wants to format whitespace. One possibility would be modifying the way csharpier formats whitespace so that it conforms with a set of dotnet-format rules.

But! It looks like dotnet-format provides a way to run subsets of rules. The doc at https://github.com/dotnet/format#how-to-use appears to be outdated, but I believe this will run all of the non-whitespace rules. Running this against csharpier results in no changes. I believe because I don't have any rules defined in an editorconfig.

dotnet format --fix-style --fix-analyzers

Assuming that accomplishes what you want, I can get the doc updated!

@Strepto
Copy link
Contributor Author

Strepto commented Sep 13, 2021

I have not actually tested this combo myself yet. But I'll try to test your suggestion, and come back to you with results.

@Strepto
Copy link
Contributor Author

Strepto commented Sep 13, 2021

The combination below seemingly works fine on dotnet-format 5! Tested it on your repo, with some changes from dotnet but no formatting, and then apply your formatting in the end. (Note for future people, dotnet format has changed the command line api in dotnet 6, so the commands might differ.)

# Run dotnet format without --fix-whitespace
dotnet-format --fix-style info --fix-analyzers info
# Use csharpier for formatting
dotnet csharpier .

I think this can be a great combo, as dotnet-format is not opinionated enough about formatting. And csharpier has no linting.

You could maybe consider promoting this combo here: dotnet/format#246

@belav
Copy link
Owner

belav commented Sep 18, 2021

The combination below seemingly works fine on dotnet-format 5!

Awesome! I have a PR for adding this info to the doc and I also included the changes from running the command. I will probably start using dotnet-format going forward.

You could maybe consider promoting this combo here: dotnet/format#246

Someone else actually mentioned CSharpier on that issue already. I have been holding off on promoting too much until I consider CSharpier beta, and it is really close to that point now.

@Strepto
Copy link
Contributor Author

Strepto commented Sep 18, 2021

Great :)

Thanks for the feedback. Feel free to close this issue ✅

@belav belav closed this as completed Sep 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants