ionide / ionide-vscode-fsharp

VS Code plugin for F# development
http://ionide.io
MIT License
850 stars 276 forks source link

[WIP] Allow selecting fsproj files into workspace #1955

Open purkhusid opened 8 months ago

purkhusid commented 8 months ago

WHAT

πŸ€– Generated by Copilot at be8ee10

This pull request adds support for single F# project files (.fsproj) as a possible workspace configuration. It updates various modules and types to handle this scenario in the workspace peek feature, the build task generation, and the solution explorer panel. It also adds support for directories as results of the workspace peek feature.

πŸ€– Generated by Copilot at be8ee10

Oh, we are the coders of the F# land And we work with the WorkspacePeekFound We handle the Fsproj and the directory And we heave on the count of three

πŸ› οΈπŸŒ²πŸ“

WHY

When working in a monorepo with multiple independent projects it is not feasible to load all the projects in the repository. This change allows the user to select the projects that they are working on and only load them.

HOW

πŸ€– Generated by Copilot at be8ee10

purkhusid commented 8 months ago

@baronfel @TheAngryByrd This is still WIP but I wanted to check if this was a feature that would be accepted.

The defaults would have to be rethough a bit since Ionide always loads the available sln file instead of prompting the user.

I was also thinking about adding a new command for selecting multiple fsprojs, and then an configuration option that allows the user to set their default fsprojs.

baronfel commented 8 months ago

There's a lot of overlap here between an already-existing slnf (solution filter) feature of MSBuild, but I don't see anything inherently wrong with the "open project + direct dependencies" scenario. I think as soon as you get to wanting to open "these N projects and their dependencies" I would look strongly at that format.

purkhusid commented 8 months ago

I thought about going the slnf route but the downside of that is that you also need to maintain an actual solution file which contains all the projects. The main motivator for me is to make it as frictionless as possible to open a repo and loading only the projects that you need for the work you are about to be doing.

How I envisioned it is that a developer would do the following:

  1. Open the repo folder in VS Code
  2. If they are about to do work on F#(Could be a polyglot monorepo) they would CTRL + P -> F#: Load Projects
    • Would pop up a multiselect list that contains all the F# projects in the repo
  3. They would select the projects they are interested in
  4. Ionide would load the projects
  5. Start coding

This workflow is really nice because you can configure your workspace without having to mess with any files at. If you think we could make the slnf route as nice as the workflow I envisioned above then I would love to hear your ideas.

purkhusid commented 8 months ago

There is also one other way to make the dev experience even easier and that would be:

  1. Dev opens repo folder in VS Code
  2. If they are about to do work on F# they just open the F# file they are going to work on
  3. Ionide would find out what fsproj the opened file belongs to and would load it

This would be my ideal workflow but I think it's also quite a bit more complex to implement and that's why I went the route that is in the PR. If you think that lazy loading the projects like this would be possible then I think I'll have a go at it if you could point me in the right direction.

purkhusid commented 8 months ago

I looked a bit into the lazy loading of projects and it seems like the main blocker for doing it is that we can't tell what fsproj an .fs file belongs to without calling workspaceLoad for the project. Do you have any suggestions on a way to map fsproj -> .fs files without doing a full load of the workspace?

baronfel commented 8 months ago

No, there's no good way. In addition, our current mechanism is incomplete because the file could belong to multiple projects.

baronfel commented 8 months ago

In case you haven't seen it, slngen is some prior art in this space.