csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

.editorconfig is not considered, when its part of the .gitignore

Open Eckii24 opened this issue 8 months ago • 3 comments

In the following implementation, the ignore file is explicitly considered, when searching for a configuration file: https://github.com/belav/csharpier/blob/4b30a177f33be5facae530432cc07dac6d991fe1/Src/CSharpier.Cli/EditorConfig/EditorConfigLocator.cs#L25

Does it really make sense to consider the ignore file, when searching for the configuration? Wouldn't it be better to only consider the ignore file when determining files to format?

Environments:

  • CSharpier Version: 1.0.0
  • Running CSharpier via: dotnet cli
  • Operating System: Debian

Steps to reproduce:

  • Add the .editorconfig to the .gitignore
  • Apply the formatting

Expected behavior:

  • .gitignore should only be applied when determining files to format
  • .editorconfig is considered

Actual behavior:

  • .gitignore is also applied when looking for configuration files
  • .editorconfig is not considered at all

Eckii24 avatar Apr 23 '25 08:04 Eckii24

+1 for this. In some of my projects the .editorconfig file is generated by a NuGet package, so we've added the .editorconfig to the .gitignore

CruseCtrl avatar Apr 25 '25 11:04 CruseCtrl

That change came about due to #1023 - an external dependency had a .editorconfig with an invalid rule that was causing parsing to fail.

I haven't tested it, but I believe as a workaround because the .csharpierignore takes priority you can explicitly include the .editorconfig with something like below. Also note that I pulled the .gitignore support out of 1.0.1 for now due to performance issues, but it will be returning in 1.0.2.

![PathToGitIgnored]/.editorconfig

I think I agree that it is a bit odd to consider the ignore file when looking for configuration files. Perhaps there should be a way to exclude a configuration file, or if a configuration file cannot be parsed it is a warning instead of an error.

belav avatar Apr 28 '25 23:04 belav

Thanks for your answer, and your awesome work btw!!

The workaround works. We had the same idea and already solved it that way.

Eckii24 avatar Apr 29 '25 04:04 Eckii24