format icon indicating copy to clipboard operation
format copied to clipboard

Add a stock Azure DevOps pipeline stage to run dotnet-format

Open frrossms opened this issue 4 years ago • 4 comments

I'm looking at running dotnet-format --check on all our PRs. The simplest result is just to fail if it returns an error and tell the user to run dotnet-format, but this seems like a common enough thing that it would be worth trying to add to Azure DevOps with integration where it adds inline comments where there are formatting errors.

frrossms avatar May 27 '21 16:05 frrossms

@mikadumont I think this aligns with things you were designing

jmarolf avatar May 27 '21 16:05 jmarolf

Could this possibly include an option to not produce inline comments but instead write a file that can be used to produce inline comments? For example, a list of: File name, starting line, ending line, expected new code (and possibly incorrect old code, if we're thinking Diff hunks) - either in JSON, XML, or whatever machine-readable format that isn't necessarily a plain Diff/Patch.

Reason being is that we use Azure DevOps for CI, but Code Hosting is done elsewhere (which does support inline code comments, but seems infeasible to support in a stock task when there are many ways of using this information, like in GitHub, GitLab, Bitbucket, etc. - both as commit comments and Pull Request/Merge Request comments).

BhaaLseN avatar Jun 12 '21 11:06 BhaaLseN

@BhaaLseN Having the tool produce a tool agnostic output and then doing the parsing and integration of it in each tool seems like an excellent idea to me. Then create a stock task for ADO and GH that parses that file.

frrossms avatar Jun 14 '21 16:06 frrossms

FYI: the --report option seems to be a suitable basis for this. At least it produces a JSON file that can be read by something else and has enough information to get the file path, line number and character number to potentially generate a comment on the offending source file.

BhaaLseN avatar Feb 03 '23 06:02 BhaaLseN