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

Add using directive formatting #685

Merged
merged 1 commit into from Jun 1, 2020

Conversation

wojciechcibor
Copy link
Contributor

I was playing around with dotnet-format and just for fun added support for following .editorconfig flags:

dotnet_sort_system_directives_first
dotnet_separate_import_directive_groups

It works for me. Please let me know what do you think about it. There is one TODO about using warning from Resources.

@dnfclas
Copy link

dnfclas commented May 20, 2020

CLA assistant check
All CLA requirements met.

@JoeRobich
Copy link
Member

@wojciechcibor Thanks for opening this PR! It has been on our todo list for a while and we appreciate your contribution.

For this to move forward, we would need to act on the todo and move the fix description to our .resx. We would also need to add some simple tests to ensure the formatter was being invoked. If you have the time and feel up to implementing these, I am happy to give guidance. Otherwise, I could make these final changes. How would you like to proceed?

@wojciechcibor
Copy link
Contributor Author

@JoeRobich Thanks for reply.

Well, at first just wanted to see If this has any value for you - before that I didn't want go to much into it.
In this case I can work futher on that. I can implement this TODO and add/fix tests - perhaps even later on today.

@JoeRobich
Copy link
Member

@wojciechcibor That's great! The tests don't have to be long or involved since the Formatter is already tested in dotnet/roslyn. You can use the tests from the feature/analyzers branch - https://github.com/dotnet/format/blob/feature/analyzers/tests/Formatters/ImportsFormatterTests.cs

@JoeRobich
Copy link
Member

@wojciechcibor We are at the point that we would like to do a 4.x release and this would be a great feature to include. Would you have time to fix up this PR in the next day or two?

@JoeRobich
Copy link
Member

@wojciechcibor Let me apologize for saying adding the tests would be easy. I gave it a go yesterday afternoon and now realize, with the move to the Roslyn .editorconfig support, we aren't adding an AnalyzerConfigDocument to the Workspace, which means the document options are always default. If you don't mind I would like to fix this myself and we will get your changes merged in.

@JoeRobich JoeRobich mentioned this pull request May 29, 2020
JoeRobich added a commit that referenced this pull request Jun 1, 2020
@JoeRobich JoeRobich merged commit 6dd48ec into dotnet:master Jun 1, 2020
@JoeRobich
Copy link
Member

Thanks @wojciechcibor this will be in the next release!

@virzak
Copy link

virzak commented Jun 9, 2020

Is there a way to skip this just this one rule?

@JoeRobich
Copy link
Member

@virzak We will be shipping a 4.1 release this week that has a change to only run this formatter when either of the driving properties are configured in the .editorconfig (#701). Will this work in your scenario?

@virzak
Copy link

virzak commented Jun 9, 2020

Yeah, certainly. My azure-pipelines.yml always gets the latest version of dotnet-format (which is probably a bad idea to begin with on my part). The latest version forces to change almost all files. I'll target the build to version 3.3.111304 to make sure that the old builds aren't failing and that a switch to a newer version is controlled.

vdurante pushed a commit to vdurante/format that referenced this pull request Feb 29, 2024
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

Successfully merging this pull request may close these issues.

None yet

4 participants