csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Consider - only support local installs of CSharpier for the IDE extensions.

Open belav opened this issue 2 years ago • 2 comments

The extensions keep CSharpier running in the background to speed up formatting. It is ~300ms to format a single file without keeping it running, ~10ms when it is running.

Keeping the CSharpier running while using dotnet csharpier within the project directory was problematic with global installs. If your IDE was open and you ran dotnet tool update -g csharpier it would fail and it wasn't obvious why.

This lead to the current implemention of the extensions that installs CSharpier into a custom location and runs it from there.

I think it is worth considering only supporting local installs of CSharpier.

  • All of the code around installing CSharpier to a custom location and validating that it works has been error prone and it can all go away
  • It pushes people to use CSharpier in the suggested way, which is tying a given project to a given version of CSharpier formatting. Prettier has a big note about this.
  • It can remove the need to popup a message about CSharpier needed to be installed globally for files that are outside of a project.

The obvious downside would be that you can no longer format files outside of a project.

A middleground may be

  • When CSharpier is a local tool, run it in place and keep it running to speed up formatting.
  • When CSharpier is a global tool, pipe a single file to it so that it is not left running and can be easily upgraded by the user.

belav avatar Nov 21 '23 19:11 belav

Another idea after #1033

Does it make sense to ask the user to install csharpier globally if the extension then installs that same version to a custom location?

Most of this assumes we keep the code as is, and don't make any changes above.

  • Local versions need to be a specific version. There is often CI enforcing the formatting. You want to avoid conflicts with team members
  • If there is no global version installed, install the latest csharpier to something like CustomPath/Global. In the future when the extension starts, look for this folder if no global verson is found. That ensures the user isn't suprised by files changing the way they format when csharpier is updated. But maybe they want to always be on the latest csharpier.
  • If there is a global version installed, keep the existing logic

belav avatar Nov 22 '23 16:11 belav

I think the easiest option is ignoring the global install and maintaining your own cached version.

Then you can show a warning for local installs, with a checkbox to not show again (the checkbox has to be global, as most likely the person ignoring a local install also doesn't want -or not able- to add local settings to the project repo).

Then you drop support for a custom global install version. If people are not running CSharpier locally, they'll be expected to keep the extension up to date, which will install and use the latest CSharpier tool version (cached), to get as similar versions as possible (but only local guarantees it).

Then you don't need the complexity about morroring the global tool version. It's a nice feature though!

Meligy avatar Nov 22 '23 23:11 Meligy