codeformatter icon indicating copy to clipboard operation
codeformatter copied to clipboard

Visual Studio auto-formatting extension

Open jaredpar opened this issue 10 years ago • 3 comments
trafficstars

In it's current form the formatter operates as an extra step in the development process:

  1. Write the code for my feature.
  2. Run the formatter tool.
  3. Send PR.

I would really like to remove item 2 as much as possible. It's an extra step from what developers are doing today and I can very easily see it being labeled as a "style tax".

This tool shows coding guideline enforcement can be cheaply and reliably automated. Let's take this tool to the next level so that developers rarely, if every, need to go to the command line formatter for their daily development activities.

I think a Visual Studio plugin that leverages the underlying library is a great way to integrate the formatting into the existing developer routines. Many of the formatting operations are cheap enough that they could be done as a part of existing formatting hooks in Visual Studio:

  • When saving a file.
  • When typing a formatting character like }.

Items like underscores in field names are expensive enough that it would probably need to be done as an explicit user action. Adding a menu item for that is very cheap.

jaredpar avatar Jan 08 '15 16:01 jaredpar

Suggestion: We should consider using diagnostic analyzers with codefixes that show up as lightbulbs in VS.

Priya91 avatar Jan 08 '15 17:01 Priya91

@Priya91 i'm fine with integrating that functionality as well. But I want to prioritize making style conformance easy. Having to click a lot of drop downs isn't much faster than just fixing it yourself.

jaredpar avatar Jan 08 '15 17:01 jaredpar

:+1:

I use BatchFormat VS extension (by @yongfa365 yongfa365/BatchFormat) which formats and sort/remove-unused using directives solution-wide with a click in solution explorer.

Would be really great if we get this Roslyn-driven intelligent code formatting tool as extension and as simple in usage as BatchFormat. Also, a simple MSBuild integration support (for pre-build task) would be a cherry on top. :cherries:

am11 avatar Mar 14 '15 15:03 am11