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

Display prompt to restore all projects #2323

Merged
merged 11 commits into from
Jun 18, 2018

Conversation

akshita31
Copy link
Contributor

@akshita31 akshita31 commented May 17, 2018

Fixes: #2276 #240

The prompt that asks to restore the project dependencies appears just once and clicking on "Restore" , restores all the projects.
The command palette has 2 options:

  1. .NET : Restore Project - Displays a menu to select one project to be restored.
  2. .NET : Restore Packages - Restores all the projects.

@akshita31
Copy link
Contributor Author

I am not sure what should be the names of the commands in the command pallette.

@codecov
Copy link

codecov bot commented May 17, 2018

Codecov Report

Merging #2323 into master will increase coverage by 0.04%.
The diff coverage is 51.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2323      +/-   ##
==========================================
+ Coverage   62.21%   62.25%   +0.04%     
==========================================
  Files          86       86              
  Lines        3864     3855       -9     
  Branches      556      551       -5     
==========================================
- Hits         2404     2400       -4     
+ Misses       1299     1293       -6     
- Partials      161      162       +1
Flag Coverage Δ
#integration 51.34% <48.38%> (+0.06%) ⬆️
#unit 84.25% <100%> (-0.03%) ⬇️
Impacted Files Coverage Δ
src/observers/InformationMessageObserver.ts 100% <100%> (ø) ⬆️
src/observers/utils/ShowInformationMessage.ts 83.33% <100%> (-4.17%) ⬇️
src/features/commands.ts 31.81% <46.42%> (+2.34%) ⬆️
src/omnisharp/delayTracker.ts 68.42% <0%> (-5.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f388323...e5a920f. Read the comment docs.

package.json Outdated
"category": ".NET"
},
{
"command": "dotnet.restore.all",
"title": "Restore Packages",
Copy link
Member

Choose a reason for hiding this comment

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

Should we rename this to "Restore All Projects" for symmetry with "Restore Project"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

let csharpConfig = this.vscode.workspace.getConfiguration('csharp');
if (!csharpConfig.get<boolean>('suppressDotnetRestoreNotification')) {
let message = `There are unresolved dependencies from '${this.vscode.workspace.asRelativePath(event.unresolvedDependencies.FileName)}'. Please execute the restore command to continue.`;
return showInformationMessage(this.vscode, message, { title: 'Restore', command: 'dotnet.restore', args: event.unresolvedDependencies.FileName });
let message = `There are unresolved dependencies'. Please execute the restore command to continue.`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DustinCampbell Do we want to display the solution name ( the one we display in the status bar item) here -- There are unresolved dependencies from abc.sln ?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe. If we do, the text should probably be in abc.sln rather than from abc.sln.

However, I'm interested in the semantics of how this message appears. If several "unresolved dependencies" events trigger for different projects, will we just display a single message? If so, would it be better if we triggered dotnet restore for each project rather than running it over the whole workspace? Doing the latter might be unexpected.

Copy link

Choose a reason for hiding this comment

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

I think one problem is that discovery of unrestored projects is asynchronous. If we implement the feature so that it only restores projects for which it received the "unrestored project" message, there's a race condition between this popup and the discovery. Eg, one unrestored project is discovered and the warning is shown, and the user clicks restore. O# continues discovering projects and finds more, triggering a new prompt that the user needs to click to restore the newly discovered projects.

Restoring the entire sln file at once avoids that race condition. I suppose restoring the whole solution could be slow, but what else is "unexpected" about it?

There's also the case of multiple csproj's floating around with no sln file. I'm not sure how you would coordinate restoring all of those projects simulatenously without an sln...

dotnetRestoreAllProjects(server, eventStream);
}
});
let d4 = vscode.commands.registerCommand('dotnet.restore.project', () => pickProjectAndDotnetRestore(server, eventStream));
Copy link

Choose a reason for hiding this comment

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

This is getting a bit silly. Can we just start pushing these into an array and construct our composite disposable from that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

let descriptors = await getProjectDescriptors(server);
eventStream.post(new CommandDotNetRestoreStart());
for (let descriptor of descriptors) {
await dotnetRestore(descriptor.Directory, eventStream);
Copy link

Choose a reason for hiding this comment

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

What does the log output look like while we restore multiple projects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It shows the logs from the restore of each project
restore

@rchande
Copy link

rchande commented Jun 8, 2018

@DustinCampbell @akshita31 Do we still have outstanding concerns about this PR or is it ready to merge? 😄

@DustinCampbell
Copy link
Member

None from me.

@akshita31 akshita31 merged commit 05fcd71 into dotnet:master Jun 18, 2018
@akshita31 akshita31 deleted the restore_solution branch June 18, 2018 17:43
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