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

Clean up unresolved dependencies check #862

Conversation

DustinCampbell
Copy link
Contributor

Fixes dotnet/vscode-csharp#1272

This change cleans up the logic (which had gotten kinda messy) that resolves MSBuild package references against a project's lock file. This also adds logging when package references can't be resolved, which should help diagnose situations where VS Code is getting restore prompts unnecessarily.

Copy link
Member

@david-driscoll david-driscoll left a comment

Choose a reason for hiding this comment

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

LGTM, unless you see some value in adding tests. I'm split the code isn't super complicated.


namespace OmniSharp.MSBuild.Resolution
{
internal class PackageDependencyResolver
Copy link
Member

Choose a reason for hiding this comment

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

Is there much value in writing tests for this class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there's definitely value in having tests, but I don't want to gate this PR on them. I want to write tests for the MSBuildProjectSystem in general because there's really not much today. Now that we have the test infrastructure in place, I'd like to write some broader MSBuildProjectSystem tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added #863 to track adding tests.

var unresolved = libraryManager.GetLibraries().Where(dep => !dep.Resolved);
var needRestore = allDiagnostics.Any(diag => diag.ErrorCode == ErrorCodes.NU1006) || unresolved.Any();
var unresolvedLibraries = libraryManager.GetLibraries().Where(dep => !dep.Resolved);
var needRestore = allDiagnostics.Any(diag => diag.ErrorCode == ErrorCodes.NU1006) || unresolvedLibraries.Any();
Copy link
Member

Choose a reason for hiding this comment

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

when lock file doesn't exist at all I believe the error code would be NU1009.
Should that be taken into account as well? a restore would then generate the lock file

Copy link
Member

Choose a reason for hiding this comment

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

actually, maybe it doesn't matter anymore - it's legacy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I wasn't trying to clean up DotNetProjectSystem too much. I've been thinking of that as a bit frozen so I don't unintentionally break anything.

@DustinCampbell DustinCampbell merged commit 4cb692a into OmniSharp:dev May 17, 2017
@DustinCampbell DustinCampbell deleted the cleanup-unresolved-dependencies-check branch August 30, 2017 19:14
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.

3 participants