microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
207 stars 6 forks source link

Enable P2P reference from command pallette #1163

Open timheuer opened 2 weeks ago

timheuer commented 2 weeks ago

From vscode-csharp created by richlander: dotnet/vscode-csharp#7190?_features=!issues_react_v2

I wanted to add a P2P reference. I don't normally use command pallet for that, but decided to give it a try.

image

Excellent! I did that and I was surprised it didn't "work". After a big of digging, I realized that this is a S2P reference. That sort of blew my mind. I was operating under the mental model of a project. The project was my object/noun. It's clear that devkit doesn't share this view and has the solution as the primary substrate for all operations.

I see now that DevKit offers P2P references in Solution Explorer (which I never use).

image

This seems to be something different. It seems to want to only want to add P2P references to projects within the same solution???

image

Note: I did this after removing the second project in the solution that is displayed in the earlier image.

I also see that DevKit offers S2P references in that same UI.

image

There is currently just one command pallet entry for "Add Project". So, its just a question of whether it adds the project reference to the solution or the project. The solution was chosen.

It seems like there are three options:

I like the last option best. I suspect many other users will prefer this. Please consider it.

At the same time, there are affordances given to special projects. Perhaps there is some bigger opportunity here.

image

It should also be noted that the CLI defaults to P2P.

I just did this:

$ dotnet add reference ../BacktrackerBenchmarks
Reference `..\BacktrackerBenchmarks\Benchmarks.csproj` added to the project.

This is in the same directory, which contains a project and a Devkit-generated solution file.

It's a yellow flag if the CLI and DK disagree on what the primary artifacts are at play. For the CLI, SLN operations are more off-to-the-side (which I'm good with).

timheuer commented 2 weeks ago

An example prototype:

https://github.com/microsoft/vscode-dotnettools/assets/4821/0c9315f4-9de8-4d74-a786-7f5d7d4bd726

First: assume no context-- aske source/target Second: if active document can infer a starting point, use that, just ask the proj to ref from any in the workspace