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

Ignore directories #8

Closed
AdamCaviness opened this issue Feb 21, 2019 · 5 comments · Fixed by #130
Closed

Ignore directories #8

AdamCaviness opened this issue Feb 21, 2019 · 5 comments · Fixed by #130
Labels
Bug This issue describes behavior that is not working as expected
Milestone

Comments

@AdamCaviness
Copy link

First off, I love this; great work!! I have a few directories I need to exclude. In Visual Studio this is easy to achieve by making editorconfig files in those directories and setting them as root root = true and no other content. Visual Studio respects that editorconfig and formatting within that directory applies no changes because it doesn't respect VS default formatting preferences when an editorconfig is present.

When running dotnet-format, all projects are formatted, including the projects with these extra editorconfig files set as root and no other content. I presume this is by design because, this repo's readme states that "Preferences will be read from an .editorconfig file, if present, otherwise a default set of preferences will be used.".

I can always undo changes rendered in those problem directories or I can specifically run format for the specific project files and code files via a pre-built exe or powershell script but that seems unnecessary.
Thank you again for this tool, it's great.

@jmarolf jmarolf added Feature Request This issue is requesting an enhancement or new feature Good First Issue This issue is good for newcomers labels Mar 1, 2019
@zihotki
Copy link

zihotki commented Mar 4, 2019

Hey, I wonder what should be the convention to prevent the formatting because from my understanding of editor configs they work in the way so that the ones in child directories can override the settings defined in root directory. So that if setting a=true was defined in root then in child if you specify a=false it'll be false for all files in that child directory. If it's empty then it should be true. That's how it supposed to work at least according to my understanding.

Edit:
Copied from https://editorconfig.org/#file-location :

EditorConfig files are read top to bottom and the most recent rules found take precedence. Properties from matching EditorConfig sections are applied in the order they were read, so properties in closer files take precedence

@jmarolf jmarolf added Bug This issue describes behavior that is not working as expected and removed Feature Request This issue is requesting an enhancement or new feature Good First Issue This issue is good for newcomers labels Mar 4, 2019
@jmarolf
Copy link
Contributor

jmarolf commented Mar 4, 2019

Visual Studio respects that editorconfig and formatting within that directory applies no changes because it doesn't respect VS default formatting preferences when an editorconfig is present.

There should not be a difference between what VS does and what dotnet-format does assuming you are using the default VS settings. This sounds like a bug. @AdamCaviness can you provide a repo project?

@AdamCaviness
Copy link
Author

AdamCaviness commented Mar 23, 2019

I forked this repo to demonstrate it here. The format.sln has two projects, dotnet-format.csproj and dotnet-format.UnitTests. In this case I want to format the sln solution file and still prevent dotnet-format from formatting files in the UnitTests project.

I replaced the true editorconfig in the solution root with a modified one. I then added a new editorconfig to the UnitTests project directory. This works well for VS2019 as it does not recommend any changes and "format document" doesn't do anything for files in the UnitTests project.

When running dotnet-format against the sln solution file however, files are mutated in the UnitTests project.

Clone the repo and run dotnet-format against the format.sln.
format-execution
VS2019_Team_Exp-changes-after-format-execution

@s-tarasov
Copy link

I forked this repo to demonstrate it here.

Nested .editorconfigs still not supported

Why this closed?

@JoeRobich
Copy link
Member

Nested .editorconfigs still not supported

@s-tarasov Can you open a new issue with what you are seeing in more detail? I verified that the behavior described in this issue has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This issue describes behavior that is not working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants