csharpier
csharpier copied to clipboard
When csharpier does not format a file, it isn't obvious to a plugin user why it doesn't.
If a file is in csharpierignore, or it has a comment like // <auto-generated>
then csharpier will not format the file.
If a file does not compile, csharpier will also not format the file.
This can cause confusion to someone using the plugin who runs the action "Reformat with CSharpier".
This should notify them somehow that the file is ignored or has a compilation error. Probably not with the auto format, but if they specifically take an action like "Reformat file" we should let them know.
We are running into a simillar issue. It would be convenient to format auto-generated file when attempting to format an individual file. Refusing to format individual auto-generated files seems like an implementation oversight.
The dotnet format
tool has a --include-generated
cli flag, would it be possible to implement that for csharpier as well?
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-format#options
@arg0d, @meenzen
I don't think that the IDE plugins should format auto-generated files. Or if they do, it should be an explicit request from the user. This issue was in regards to the plugins, not the cli.
If you are generating your source code in c#, then https://www.nuget.org/packages/CSharpier.Core can programatically format files and it doesn't filter out auto-generated files.
Othewise adding a --include-generated
flag sounds reasonable to me.
I'm confused. Are there 2 separate CSharpier repos? I was reading code in this repo, and found that CSharpier will refuse to format files with // <auto-generated>
comment at the beginning, with no option to override this. It sounds to me like there should be an option like @meenzen suggested to bypass this check.
Or even better, formatting auto generated files should be the default when formatting individual files, while formatting all files in directory should skip auto generated files. This sounds quite intuitive even for IDE use case, where the user would be able to format individual auto generated files, instead of being told that auto generated files can't be formatted
.
@arg0d this repo is for all things CSharpier. This issue is about showing a user of the extension why a file is not being formatted, so I assumed you were attempting to do this in one of the extensions. I created #1055 to add the option to the cli.