Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] - csproj intellisense #1214

Closed
wants to merge 12 commits into from

Conversation

cmurczek-it
Copy link

@cmurczek-it cmurczek-it commented Feb 9, 2017

preliminary task list to fix #1156

  • familiarize with NuGet V4 API
    NuGet Gallery still runs on V3. I will get the feeds from the user scoped nuget.config, that way it'll "auto-update" as soon as the new api is referenced there. I'll put a test in for the feed name to make sure smthg breaks when that happens.
  • familiarize with how NuGet intellisense works in project.json
  • write tests and enhance PackageManager introduce NuGetClient
  • write tests and provider
  • wire up the provider with the extension

@dnfclas
Copy link

dnfclas commented Feb 9, 2017

Hi @cmurczek, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla2.dotnetfoundation.org.

TTYL, DNFBOT;


test('Retrieve packages from NuGet Gallery', () => {
let partialPackageId = 'newtonsoft';
let target = new PackageManager(platformInfo, logger);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that PackageManager in the VS Code extension has nothing to do with NuGet.

@cmurczek-it
Copy link
Author

@DustinCampbell: Travis CI fails when I call PlatformInformation.GetCurrent() while setting up my tests. Any idea how to fix this? It's working on my (Windows) machine...

src/nuget.ts Outdated

fs.readFile(nuGetConfig, 'utf-8', (err, data) => {
if (err) {
reject('Reading ' + nuGetConfig + ' failed with error ' + err);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this will just carry below trying to access data. I suspect you want to return here.

@DustinCampbell
Copy link
Member

PlatformInformation.GetCurrent() calls our execChildProcess utility, which relies on setExtensionPath being initialized here. This function called as part of extension activation.

Since you're just checking whether you're on windows, you might consider just checked process.platform === 'win32' instead of using PlatformInformation.

@DustinCampbell
Copy link
Member

You should also be aware of this PR: #224. We'll be taking this soon to pull project.json completion into C# for VS Code (it lives in VS Code today). We'll want to unify these two to have the same behavior.

@cmurczek-it
Copy link
Author

yeah, I'm using that one as a template. The NuGetClient class would be my shot at the future improvement that is mention in the PR regarding making the FEED_INDEX_URL configurable.

I'll refactor some more to mock away as many dependencies as possible and the push another update.

@dnfclas
Copy link

dnfclas commented Feb 13, 2017

@cmurczek, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, DNFBOT;

@DustinCampbell
Copy link
Member

I'll refactor some more to mock away as many dependencies as possible and the push another update.

Please don't over mock if you feel like you're going too far. After all, the tests run inside of VS Code to provide access to various VS Code services. So, if you must use PlatformInformation (which we don't use everywhere either -- only when we need bitness and Linux distro information), it's just a matter of ensuring that the extension is activated. I'm not sure what that looks like precisely, but it's certainly feasible.

@cmurczek-it
Copy link
Author

And we're back on track. Thx for the heads up regarding test environment. I was coming from the fact that, the tests as they were, were dependent on an actual nuget.config file being present on the target system. Which in case of Travis CI is probably not the case. After refactoring processing of the config is separated from loading it from the file, so we're good, even on servers without any nuget installation/config.

There's however the question of testing the CompletionItemProvider for PackageReference elements. This will derive from AbstractProvider which requires me to pass an instance of OmniSharpServer. Is there a reasonable way to set up the infrastructure for such tests, or is that the reason why there aren't any tests for all the other providers? If so, I'd keep the PackageReferenceCompletionProvider as thin as possible on top of the NuGetClient.

@DustinCampbell
Copy link
Member

I wouldn't bother deriving from AbstractProvider. It really doesn't buy you much and this shouldn't have any OmniSharp dependencies anyway.

@DustinCampbell
Copy link
Member

I just wanted to point out that I've updated the PR for moving project.json completion and hover support into C# for VS Code: #1236. I'll likely be merging this soon. When I do, you might want to rebase onto the latest master.

@cmurczek-it
Copy link
Author

Thx for letting me know. Will update when you signal. I guess that means I'll be tasked with unifying both of them too?

On a different note: What's your opinion on running live http-requests during tests? Right now Mocha flags them as slow, <1s but still. If it bothers you I could look into stubbing https calls using sinon, playing back canned responses. Might be worth the work anyway for the consistency of test data alone. Let me know.

@DustinCampbell
Copy link
Member

I'm not expecting you to unify them. They can be separate for now and we can a work item to unify them later. You can stay focused. 😄

@DustinCampbell
Copy link
Member

FYI that I merged the project.json IntelliSense yesterday.

@cmurczek-it cmurczek-it force-pushed the packageRef-intellisense branch from 4eccbe8 to 3f424c9 Compare February 20, 2017 14:49
the NuGetClient takes the activePackageSources from user scope NuGet.config and extracts the needed urls from the package source's index
probably needs more tests and mocking/stubbing of http calls
I had to update node from 4.4.5 to 6.9.5 in order to successfully complete the npm run compile script. Before the update it failed due to an unexpected = in executeChildProcess's parameters in common.js
this removes dependencies on external services (stubbing of  http calls) as well as dependencies between tests
@cmurczek-it cmurczek-it force-pushed the packageRef-intellisense branch from 3f424c9 to 6da0224 Compare February 20, 2017 16:00
@NinoFloris
Copy link

Would this be easy to extend now @DustinCampbell?

@NinoFloris
Copy link

This being the project.json infra you already merged?

@borgdylan
Copy link

Will this only read PackageReferences via .csproj or will the extension allow loading of any arbitrary extension as long as it is an MSBuild project?

@DustinCampbell
Copy link
Member

@borgdylan: I'm not sure I understand your question.

@borgdylan
Copy link

Will it be hardcoded to project that use ".csproj"? Or will it allow projects that are .".fsproj" etc. Intellisense for NuGet package versions is not C# specific and should be available for any project or else put in a separate extension that is generic.

@DustinCampbell
Copy link
Member

@borgdylan: For C# for VS Code, it'll be specific to .csproj.

@NinoFloris
Copy link

So... Is this an abandoned project?

@DustinCampbell
Copy link
Member

It seems like it might be. I'm awaiting @mlorbetske to deliver me a NuGet package of https://github.com/dotnet/ProjFileTools so we can use that within OmniSharp and provide completion to C# for VS Code.

@mlorbetske
Copy link

Sorry for the delay, I've been swamped of late. I got the go ahead to make a package for the project file tools earlier this week, just need to update the build and find someone to upload it to NuGet under one of the official accounts. I could also make it available on MyGet earlier (tonight maybe?) if that'd help.

@mlorbetske
Copy link

mlorbetske commented Mar 31, 2017

Filed dotnet/ProjFileTools#10 to get the packaging going as part of the official build.

For the time being, the package is available as ProjectFileTools.NuGetSearch v1.0.0 on https://dotnet.myget.org/F/temp-projfiletools/api/v3/index.json.

@DustinCampbell

@cmurczek
Copy link

Sorry I went AWOL for a couple of weeks. I'll have a couple of hours to kill while traveling tomorrow. I could try to wrap it up then, but I guess using the same told as VS2017 would be preferable. @DustinCampbell let me know

@cmrigney
Copy link

Any progress? This would be very useful.

@xsoheilalizadeh
Copy link

any plan? I Wait for this thanks :)

@ghost ghost removed the cla-signed label Dec 7, 2017
@tintoy
Copy link

tintoy commented Mar 13, 2018

Hi.

Just stumbled across this PR and, in case anybody's still wondering about intellisense for .csproj files (or any MSBuild project file, really), there's a separate extension that does this:

https://marketplace.visualstudio.com/items?itemName=tintoy.msbuild-project-tools

@DustinCampbell
Copy link
Member

Given that it's been a year, I'm going to go ahead and close this PR. @tintoy's msbuild-project-tools extension is an excellent alternatively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement completion for package references in csproj files
10 participants