natanfudge / Auto-Using

Visual Studio Code extension that auto imports and provides auto complete for available imports in C#
https://marketplace.visualstudio.com/items?itemName=Fudge.auto-using
GNU Lesser General Public License v3.0
37 stars 7 forks source link

95% Working Workspace Loading, Watching, Reference Parsing. #4

Closed pushqrdx closed 5 years ago

pushqrdx commented 5 years ago

This took way more time than I expected, This pr isn't finished as some of the changes need to be discussed.

Here's how the new code works:

Project.cs:

Note:

The reason i chose to use NuGetPackageRoot to find nuget packages is to avoid having to wait for project builds. Plus some users might have things like Fody or simply chose not to copy the reference dll locally which would result in the server not being able to get completions for them.

Note 2:

See Project.cs#90.

And here's how i imagine the server should act:
  1. Spin up a process, passing in 1 or more .csproj file pathes.
  2. Server loads each project file and starts watching it for changes (reference addition, removal, etc).
  3. You have the ability to issue subsequent project add, remove in case more projects were added/removed.
  4. Each request contains project name as an argument. For example, getAllCompletions request might look like:
    {
        "Command":"getAllCompletions",
        "Arguments":"AutoUsing"
    }

Feel free to create unit tests for this as i only tested manually, too tired to write tests right now.

natanfudge commented 5 years ago

First of all, please add tests so I can actually see how to use the system.

Regarding scanning assemblies, this is how it will go: Base .NET libraries get precompiled and cached somewhere before production. On the first time the extension is loaded with a .csproj files, all of those libraries are cached. Whenever a completion is required, vscode sends a request to the server to get it the list of references, or the extension methods of a type. (These requests also send in the .csproj path). If this is too slow we cache everything on the client instead. Whenever .csproj changes we update the cache.