zzarchive-VisualFSharpPowerTools icon indicating copy to clipboard operation
zzarchive-VisualFSharpPowerTools copied to clipboard

[Resolve unopened namespaces] Solution wide search

Open vasily-kirichenko opened this issue 10 years ago • 9 comments

It would be great to search for entities in all projects in current solution instead of referenced assemblies only.

  • Call FCS for AssemblySignature for every compiled project in current solution (ParseAndCheckProject -> AssemblySignature will be too slow I guess). I'm not sure there is an API for this.
  • Cache results as we already do.
  • For not referenced assemblies suggest "open Foo.Bar (add reference to External.dll)" instead of "open Foo.Bar".
  • If the user executes the action, we add reference to the assembly (by patching fsproj file if F# project system does not expose such functionality), then open the namespace/module as before.

What do you think?

vasily-kirichenko avatar Jul 03 '14 06:07 vasily-kirichenko

For adding a reference to external.dll it sounds like how resharper does it, until they allowed you to add an reference via nuget it used to trip me up as I'd forget about it, check it in and break the build.

An option to add a reference via nuget as well?

TWith2Sugars avatar Jul 03 '14 07:07 TWith2Sugars

I think for NuGet it should be a slightly different algorithm:

  • Get all entities from all assemblies filtering by mask "\packages*\lib*__.dll"
  • Do the same as for the assemblies in current solution
  • When the user executes "open namespace" we add reference on the assembly and to "packages.config" as well

I believe this will work for already installed packages. I'm not sure it's possible to do the same for the whole NuGet.

Or we should use nuget.exe instead?

vasily-kirichenko avatar Jul 03 '14 07:07 vasily-kirichenko

Could do both

  • Open X
  • Open X via Nuget

I'm sure there are scenarios where people would rather use a local reference rather than a nuget package.

TWith2Sugars avatar Jul 03 '14 08:07 TWith2Sugars

I feel like it is too open-ended as being proposed. What happens if I find an entity defined in another project in the solution? Should I make a project reference or an assembly reference?

Project system is a delicate matter. As a user, I don't want IDEs to add project references/assembly references inadvertently. I like the feature as it is because its scope is just right (finding unbound identifiers in referenced assemblies).

dungpa avatar Jul 05 '14 18:07 dungpa

For large solutions solution-wide search is a very nice feature. Consider a solution containing several dozens of similar applications (and several hundred projects in total), all of them need to reference a dozen of other projects in the solution. Now imagine you are adding another app and have to add all needed references by hand. That's exactly my story at work and it's very annoying. This is even more relevant for NuGet packages because NuGet UI is very, very slow on large solutions and adding several packages into a new project is very time consuming.

ReSharper has had the same feature for years by now and, as far as I know, nobody complains that it's too powerful.

So I suggest:

  • show a modal confirmation dialog if opening namespace/module requires referencing a project
  • make it optional via settings

If you very much against this feature, we can create a User Voice item for it.

vasily-kirichenko avatar Jul 05 '14 19:07 vasily-kirichenko

From the scenario you described, what is needed is a simple way to add the same reference to multiple projects that is orthogonal to this feature.

This feature is purely an editing one. Intertwining it with modifying project system isn't a good idea. Moreover, you can't add a single reference to a project and expect things to be type checked. You need to own the reference resolution module in order to know all required dependencies for an entity from another project. Referenced assemblies are a safe ground in that regard; the solution space is known and there is no unexpected combination.

Feel free to create a User Voice item for this if you would like to.

dungpa avatar Jul 06 '14 16:07 dungpa

There's one similar feature that ReSharper does: it automatically references missing assemblies from the .NET framework to your project.

OkayX6 avatar Jul 11 '14 11:07 OkayX6

My opposition to this issue is due to the messy VFT project system that we shouldn't touch. @vasily-kirichenko Do you still want to do this or can we close the issue?

dungpa avatar Dec 16 '15 14:12 dungpa

I think it's appoachable and very useful.

vasily-kirichenko avatar Dec 16 '15 17:12 vasily-kirichenko