-
Notifications
You must be signed in to change notification settings - Fork 172
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
dotnet-format: accept a list of files to format (instead of a full workspace) #9
Comments
@JoeRobich or @jinujoseph can you move this to https://github.com/dotnet/format? |
Oh, nice, didn't know there was a repository dedicated to |
@BhaaLseN you did the right thing. I just put this repo together recently |
@jmarolf @JoeRobich I was thinking of looking into this, as it's something I could use too. Is the way it's written in the above intended use case the way to move forward? Is a |
Personally, my gut tells me |
@BhaaLseN When thinking long-term, I agree with you. Currently we get some benefits from using the MSBuildWorkspace to enumerate projects and documents as well as saving changes, which requires a project or solution file. @challen0 I think the easiest path to get this in would be to:
|
This is available on myget version 3.0.4-prerelease.19171.3 and later
|
In order to format list of files that I have just committed, I am using the following command before pushing my changes upstream:
(followed by It would be great if we can pipe the files one by one:
or simply
and/or even: i.e. without needing to join the list as comma separated and read path from stdin. |
@am11 can you file a new issue for that request? Thanks! |
Version Used: dotnet-format 3.0.0-beta4-19105-10 (70a2f514eb3932648f771b086834cb0a376fee20)
Steps to Reproduce:
git diff --name-only
)dotnet format
(or try to pipe them into stdin)Expected Behavior:
dotnet format
only changes the passed files instead of the whole project (or solution)Actual Behavior:
dotnet format
errors out with either "Both a MSBuild project file and solution file found in $path. Specify which one to use with the --workspace option" or "Unrecognized command or argument 'path/to/file.cs'". Or somewhat...not sure if I should call it worse or just different: it runs successfully, formatting all files referenced by the project or solution (in case only a single project or solution file is found in the current working directory).Intended Use-Case:
We run a few things as part of our CI (such as static analysis), and we'd also like to use
dotnet format
as a way to enforce code style before it even reaches the first review by a human. Right now this isn't too feasible asdotnet format
takes quite a while on larger solutions with a lot of files; and running it only on the changed files would significantly improve the time to feedback (with the intention to simply error out in case it produces any changes in the CI working copy).For smaller change sets, passing file names as command line parameter is likely a usable solution, but the larger the change set the more likely it would be to reach a length limit for arguments; so piping it into stdin would probably be the better approach there.
Or, alternatively (if it makes sense to do so), support this use case from within
dotnet format
itself (or a tool derived from it), along with the--dry-run
switch: stop processing as soon as a change would have been made and return an error code that can be checked by a caller.Thoughts and ideas are more than welcome, especially in case I missed some other tooling that already does this.
The text was updated successfully, but these errors were encountered: