From b613ec5ac85b7f235a98766a68bcf68182045929 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Wed, 9 May 2018 13:07:57 -0700 Subject: [PATCH 1/9] dotnet restore solution --- package.json | 8 +++- src/features/commands.ts | 80 ++++++++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 247a2abca..508d324bb 100644 --- a/package.json +++ b/package.json @@ -278,6 +278,7 @@ "onCommand:o.pickProjectAndStart", "onCommand:o.showOutput", "onCommand:dotnet.restore", + "onCommand:dotnet.restore.solution", "onCommand:dotnet.generateAssets", "onCommand:csharp.downloadDebugger", "onCommand:csharp.listProcess", @@ -607,7 +608,12 @@ }, { "command": "dotnet.restore", - "title": "Restore Packages", + "title": "Restore Project", + "category": ".NET" + }, + { + "command": "dotnet.restore.solution", + "title": "Restore solution", "category": ".NET" }, { diff --git a/src/features/commands.ts b/src/features/commands.ts index 2bfa76aca..edccd1376 100644 --- a/src/features/commands.ts +++ b/src/features/commands.ts @@ -31,28 +31,30 @@ export default function registerCommands(server: OmniSharpServer, platformInfo: else { dotnetRestoreAllProjects(server, eventStream); } - }); + }); + + let d5 = vscode.commands.registerCommand('dotnet.restore.solution', () => dotnetRestoreSolution(server, eventStream)); // register empty handler for csharp.installDebugger // running the command activates the extension, which is all we need for installation to kickoff - let d5 = vscode.commands.registerCommand('csharp.downloadDebugger', () => { }); + let d6 = vscode.commands.registerCommand('csharp.downloadDebugger', () => { }); // register process picker for attach let attachItemsProvider = DotNetAttachItemsProviderFactory.Get(); let attacher = new AttachPicker(attachItemsProvider); - let d6 = vscode.commands.registerCommand('csharp.listProcess', async () => attacher.ShowAttachEntries()); + let d7 = vscode.commands.registerCommand('csharp.listProcess', async () => attacher.ShowAttachEntries()); // Register command for generating tasks.json and launch.json assets. - let d7 = vscode.commands.registerCommand('dotnet.generateAssets', async () => generateAssets(server)); + let d8 = vscode.commands.registerCommand('dotnet.generateAssets', async () => generateAssets(server)); // Register command for remote process picker for attach - let d8 = vscode.commands.registerCommand('csharp.listRemoteProcess', async (args) => RemoteAttachPicker.ShowAttachEntries(args, platformInfo)); + let d9 = vscode.commands.registerCommand('csharp.listRemoteProcess', async (args) => RemoteAttachPicker.ShowAttachEntries(args, platformInfo)); // Register command for adapter executable command. - let d9 = vscode.commands.registerCommand('csharp.coreclrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream)); - let d10 = vscode.commands.registerCommand('csharp.clrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream)); + let d10 = vscode.commands.registerCommand('csharp.coreclrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream)); + let d11 = vscode.commands.registerCommand('csharp.clrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream)); - return new CompositeDisposable(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10); + return new CompositeDisposable(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11); } function restartOmniSharp(server: OmniSharpServer) { @@ -126,46 +128,62 @@ export async function dotnetRestoreAllProjects(server: OmniSharpServer, eventStr return Promise.reject('OmniSharp server is not running.'); } - return serverUtils.requestWorkspaceInformation(server).then(async info => { + let info = await serverUtils.requestWorkspaceInformation(server); - let descriptors = protocol.getDotNetCoreProjectDescriptors(info); + let descriptors = protocol.getDotNetCoreProjectDescriptors(info); - if (descriptors.length === 0) { - return Promise.reject("No .NET Core projects found"); - } + if (descriptors.length === 0) { + return Promise.reject("No .NET Core projects found"); + } - let commandPromises = projectsToCommands(descriptors, eventStream); + let commandPromises = projectsToCommands(descriptors, eventStream); - return Promise.all(commandPromises).then(commands => { - return vscode.window.showQuickPick(commands); - }).then(command => { - if (command) { - return command.execute(); - } - }); + return Promise.all(commandPromises).then(commands => { + return vscode.window.showQuickPick(commands); + }).then(command => { + if (command) { + return command.execute(); + } }); } +export async function dotnetRestoreSolution(server: OmniSharpServer, eventStream: EventStream): Promise { + + if (!server.isRunning()) { + return Promise.reject('OmniSharp server is not running.'); + } + + let info = await serverUtils.requestWorkspaceInformation(server); + let descriptors = protocol.getDotNetCoreProjectDescriptors(info); + + if (descriptors.length === 0) { + return Promise.reject("No .NET Core projects found"); + } + + for (let descriptor of descriptors) { + await dotnetRestore(descriptor.Directory, eventStream, descriptor.FilePath); + } +} + export async function dotnetRestoreForProject(server: OmniSharpServer, filePath: string, eventStream: EventStream) { if (!server.isRunning()) { return Promise.reject('OmniSharp server is not running.'); } - return serverUtils.requestWorkspaceInformation(server).then(async info => { + let info = await serverUtils.requestWorkspaceInformation(server); - let descriptors = protocol.getDotNetCoreProjectDescriptors(info); + let descriptors = protocol.getDotNetCoreProjectDescriptors(info); - if (descriptors.length === 0) { - return Promise.reject("No .NET Core projects found"); - } + if (descriptors.length === 0) { + return Promise.reject("No .NET Core projects found"); + } - for (let descriptor of descriptors) { - if (descriptor.FilePath === filePath) { - return dotnetRestore(descriptor.Directory, eventStream, filePath); - } + for (let descriptor of descriptors) { + if (descriptor.FilePath === filePath) { + return dotnetRestore(descriptor.Directory, eventStream, filePath); } - }); + } } async function dotnetRestore(cwd: string, eventStream: EventStream, filePath?: string) { From 996094790b744a58af6b5299f3ab458f5a18d04d Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Wed, 9 May 2018 16:11:16 -0700 Subject: [PATCH 2/9] remove using --- src/features/commands.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/commands.ts b/src/features/commands.ts index edccd1376..6632379ea 100644 --- a/src/features/commands.ts +++ b/src/features/commands.ts @@ -161,7 +161,7 @@ export async function dotnetRestoreSolution(server: OmniSharpServer, eventStream } for (let descriptor of descriptors) { - await dotnetRestore(descriptor.Directory, eventStream, descriptor.FilePath); + await dotnetRestore(descriptor.Directory, eventStream); } } From 1d798667693f496eac9458c3a63c6ab83f4c23af Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Wed, 9 May 2018 16:38:06 -0700 Subject: [PATCH 3/9] Perfom restore on the solution --- package.json | 6 +- src/features/commands.ts | 64 ++++--------------- src/observers/InformationMessageObserver.ts | 4 +- .../InformationMessageObserver.test.ts | 18 ++---- 4 files changed, 21 insertions(+), 71 deletions(-) diff --git a/package.json b/package.json index 508d324bb..4c55dd883 100644 --- a/package.json +++ b/package.json @@ -277,7 +277,7 @@ "onCommand:o.restart", "onCommand:o.pickProjectAndStart", "onCommand:o.showOutput", - "onCommand:dotnet.restore", + "onCommand:dotnet.restore.project", "onCommand:dotnet.restore.solution", "onCommand:dotnet.generateAssets", "onCommand:csharp.downloadDebugger", @@ -607,13 +607,13 @@ "category": ".NET" }, { - "command": "dotnet.restore", + "command": "dotnet.restore.project", "title": "Restore Project", "category": ".NET" }, { "command": "dotnet.restore.solution", - "title": "Restore solution", + "title": "Restore Solution", "category": ".NET" }, { diff --git a/src/features/commands.ts b/src/features/commands.ts index 6632379ea..4791e28f3 100644 --- a/src/features/commands.ts +++ b/src/features/commands.ts @@ -24,15 +24,7 @@ export default function registerCommands(server: OmniSharpServer, platformInfo: let d1 = vscode.commands.registerCommand('o.restart', () => restartOmniSharp(server)); let d2 = vscode.commands.registerCommand('o.pickProjectAndStart', async () => pickProjectAndStart(server, optionProvider)); let d3 = vscode.commands.registerCommand('o.showOutput', () => eventStream.post(new ShowOmniSharpChannel())); - let d4 = vscode.commands.registerCommand('dotnet.restore', fileName => { - if (fileName) { - dotnetRestoreForProject(server, fileName, eventStream); - } - else { - dotnetRestoreAllProjects(server, eventStream); - } - }); - + let d4 = vscode.commands.registerCommand('dotnet.restore.project', () => dotnetRestoreAllProjects(server, eventStream)); let d5 = vscode.commands.registerCommand('dotnet.restore.solution', () => dotnetRestoreSolution(server, eventStream)); // register empty handler for csharp.installDebugger @@ -123,73 +115,39 @@ function projectsToCommands(projects: protocol.ProjectDescriptor[], eventStream: } export async function dotnetRestoreAllProjects(server: OmniSharpServer, eventStream: EventStream): Promise { - - if (!server.isRunning()) { - return Promise.reject('OmniSharp server is not running.'); + let descriptors = await getProjectDescriptors(server); + eventStream.post(new CommandDotNetRestoreStart()); + let commands = await Promise.all(projectsToCommands(descriptors, eventStream)); + let command = await vscode.window.showQuickPick(commands); + if (command) { + return command.execute(); } - - let info = await serverUtils.requestWorkspaceInformation(server); - - let descriptors = protocol.getDotNetCoreProjectDescriptors(info); - - if (descriptors.length === 0) { - return Promise.reject("No .NET Core projects found"); - } - - let commandPromises = projectsToCommands(descriptors, eventStream); - - return Promise.all(commandPromises).then(commands => { - return vscode.window.showQuickPick(commands); - }).then(command => { - if (command) { - return command.execute(); - } - }); } export async function dotnetRestoreSolution(server: OmniSharpServer, eventStream: EventStream): Promise { - - if (!server.isRunning()) { - return Promise.reject('OmniSharp server is not running.'); - } - - let info = await serverUtils.requestWorkspaceInformation(server); - let descriptors = protocol.getDotNetCoreProjectDescriptors(info); - - if (descriptors.length === 0) { - return Promise.reject("No .NET Core projects found"); - } - + let descriptors = await getProjectDescriptors(server); + eventStream.post(new CommandDotNetRestoreStart()); for (let descriptor of descriptors) { await dotnetRestore(descriptor.Directory, eventStream); } } -export async function dotnetRestoreForProject(server: OmniSharpServer, filePath: string, eventStream: EventStream) { - +async function getProjectDescriptors(server: OmniSharpServer) { if (!server.isRunning()) { return Promise.reject('OmniSharp server is not running.'); } let info = await serverUtils.requestWorkspaceInformation(server); - let descriptors = protocol.getDotNetCoreProjectDescriptors(info); - if (descriptors.length === 0) { return Promise.reject("No .NET Core projects found"); } - for (let descriptor of descriptors) { - if (descriptor.FilePath === filePath) { - return dotnetRestore(descriptor.Directory, eventStream, filePath); - } - } + return descriptors; } async function dotnetRestore(cwd: string, eventStream: EventStream, filePath?: string) { return new Promise((resolve, reject) => { - eventStream.post(new CommandDotNetRestoreStart()); - let cmd = 'dotnet'; let args = ['restore']; diff --git a/src/observers/InformationMessageObserver.ts b/src/observers/InformationMessageObserver.ts index 2c42d7e28..6a8019ad2 100644 --- a/src/observers/InformationMessageObserver.ts +++ b/src/observers/InformationMessageObserver.ts @@ -22,8 +22,8 @@ export class InformationMessageObserver { private async handleOmnisharpServerUnresolvedDependencies(event: ObservableEvent.OmnisharpServerUnresolvedDependencies) { let csharpConfig = this.vscode.workspace.getConfiguration('csharp'); if (!csharpConfig.get('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 in the solution'. Please execute the restore command to continue.`; + return showInformationMessage(this.vscode, message, {title: "Restore", command: "dotnet.restore.solution"}); } } } diff --git a/test/unitTests/logging/InformationMessageObserver.test.ts b/test/unitTests/logging/InformationMessageObserver.test.ts index f3abc58a9..223c1e3dd 100644 --- a/test/unitTests/logging/InformationMessageObserver.test.ts +++ b/test/unitTests/logging/InformationMessageObserver.test.ts @@ -22,11 +22,14 @@ suite("InformationMessageObserver", () => { let commandDone: Promise; let vscode = getVsCode(); let infoMessage: string; - let relativePath: string; let invokedCommand: string; let observer: InformationMessageObserver = new InformationMessageObserver(vscode); setup(() => { + infoMessage = undefined; + invokedCommand = undefined; + doClickCancel = undefined; + doClickOk = undefined; commandDone = new Promise(resolve => { signalCommandDone = () => { resolve(); }; }); @@ -35,7 +38,7 @@ suite("InformationMessageObserver", () => { [ { event: getUnresolvedDependenices("someFile"), - expectedCommand: "dotnet.restore" + expectedCommand: "dotnet.restore.solution" } ].forEach((elem) => { suite(elem.event.constructor.name, () => { @@ -53,7 +56,6 @@ suite("InformationMessageObserver", () => { test('The information message is shown', async () => { observer.post(elem.event); - expect(relativePath).to.not.be.empty; expect(infoMessage).to.not.be.empty; doClickOk(); await commandDone; @@ -79,11 +81,6 @@ suite("InformationMessageObserver", () => { teardown(() => { commandDone = undefined; - infoMessage = undefined; - relativePath = undefined; - invokedCommand = undefined; - doClickCancel = undefined; - doClickOk = undefined; }); function getVsCode() { @@ -107,11 +104,6 @@ suite("InformationMessageObserver", () => { return undefined; }; - vscode.workspace.asRelativePath = (pathOrUri?: string, includeWorspaceFolder?: boolean) => { - relativePath = pathOrUri; - return relativePath; - }; - return vscode; } }); \ No newline at end of file From f62460192251e2c814f99c7ac09ad3c8c466de10 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Wed, 9 May 2018 16:55:17 -0700 Subject: [PATCH 4/9] use dotnet restore all --- package.json | 6 +++--- src/features/commands.ts | 2 +- src/observers/InformationMessageObserver.ts | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4c55dd883..6daf8cde0 100644 --- a/package.json +++ b/package.json @@ -278,7 +278,7 @@ "onCommand:o.pickProjectAndStart", "onCommand:o.showOutput", "onCommand:dotnet.restore.project", - "onCommand:dotnet.restore.solution", + "onCommand:dotnet.restore.all", "onCommand:dotnet.generateAssets", "onCommand:csharp.downloadDebugger", "onCommand:csharp.listProcess", @@ -612,8 +612,8 @@ "category": ".NET" }, { - "command": "dotnet.restore.solution", - "title": "Restore Solution", + "command": "dotnet.restore.all", + "title": "Restore Packages", "category": ".NET" }, { diff --git a/src/features/commands.ts b/src/features/commands.ts index 4791e28f3..9998b2006 100644 --- a/src/features/commands.ts +++ b/src/features/commands.ts @@ -25,7 +25,7 @@ export default function registerCommands(server: OmniSharpServer, platformInfo: let d2 = vscode.commands.registerCommand('o.pickProjectAndStart', async () => pickProjectAndStart(server, optionProvider)); let d3 = vscode.commands.registerCommand('o.showOutput', () => eventStream.post(new ShowOmniSharpChannel())); let d4 = vscode.commands.registerCommand('dotnet.restore.project', () => dotnetRestoreAllProjects(server, eventStream)); - let d5 = vscode.commands.registerCommand('dotnet.restore.solution', () => dotnetRestoreSolution(server, eventStream)); + let d5 = vscode.commands.registerCommand('dotnet.restore.all', () => dotnetRestoreSolution(server, eventStream)); // register empty handler for csharp.installDebugger // running the command activates the extension, which is all we need for installation to kickoff diff --git a/src/observers/InformationMessageObserver.ts b/src/observers/InformationMessageObserver.ts index 6a8019ad2..db722353a 100644 --- a/src/observers/InformationMessageObserver.ts +++ b/src/observers/InformationMessageObserver.ts @@ -20,10 +20,11 @@ export class InformationMessageObserver { } private async handleOmnisharpServerUnresolvedDependencies(event: ObservableEvent.OmnisharpServerUnresolvedDependencies) { + //to do: determine if we need the unresolved dependecies message let csharpConfig = this.vscode.workspace.getConfiguration('csharp'); if (!csharpConfig.get('suppressDotnetRestoreNotification')) { let message = `There are unresolved dependencies in the solution'. Please execute the restore command to continue.`; - return showInformationMessage(this.vscode, message, {title: "Restore", command: "dotnet.restore.solution"}); + return showInformationMessage(this.vscode, message, { title: "Restore", command: "dotnet.restore.solution" }); } } } From 931ca3d22cfb5972c30c96ac714e1be2556e8ba9 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Wed, 16 May 2018 16:58:28 -0700 Subject: [PATCH 5/9] Renamed functions and added return types --- src/features/commands.ts | 14 +++++++------- src/observers/InformationMessageObserver.ts | 2 +- .../logging/InformationMessageObserver.test.ts | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/features/commands.ts b/src/features/commands.ts index 9998b2006..27de1f9c6 100644 --- a/src/features/commands.ts +++ b/src/features/commands.ts @@ -24,8 +24,8 @@ export default function registerCommands(server: OmniSharpServer, platformInfo: let d1 = vscode.commands.registerCommand('o.restart', () => restartOmniSharp(server)); let d2 = vscode.commands.registerCommand('o.pickProjectAndStart', async () => pickProjectAndStart(server, optionProvider)); let d3 = vscode.commands.registerCommand('o.showOutput', () => eventStream.post(new ShowOmniSharpChannel())); - let d4 = vscode.commands.registerCommand('dotnet.restore.project', () => dotnetRestoreAllProjects(server, eventStream)); - let d5 = vscode.commands.registerCommand('dotnet.restore.all', () => dotnetRestoreSolution(server, eventStream)); + let d4 = vscode.commands.registerCommand('dotnet.restore.project', () => pickProjectAndDotnetRestore(server, eventStream)); + let d5 = vscode.commands.registerCommand('dotnet.restore.all', () => dotnetRestoreAllProjects(server, eventStream)); // register empty handler for csharp.installDebugger // running the command activates the extension, which is all we need for installation to kickoff @@ -58,7 +58,7 @@ function restartOmniSharp(server: OmniSharpServer) { } } -async function pickProjectAndStart(server: OmniSharpServer, optionProvider: OptionProvider) { +async function pickProjectAndStart(server: OmniSharpServer, optionProvider: OptionProvider): Promise { let options = optionProvider.GetLatestOptions(); return findLaunchTargets(options).then(targets => { @@ -114,7 +114,7 @@ function projectsToCommands(projects: protocol.ProjectDescriptor[], eventStream: }); } -export async function dotnetRestoreAllProjects(server: OmniSharpServer, eventStream: EventStream): Promise { +async function pickProjectAndDotnetRestore(server: OmniSharpServer, eventStream: EventStream): Promise { let descriptors = await getProjectDescriptors(server); eventStream.post(new CommandDotNetRestoreStart()); let commands = await Promise.all(projectsToCommands(descriptors, eventStream)); @@ -124,7 +124,7 @@ export async function dotnetRestoreAllProjects(server: OmniSharpServer, eventStr } } -export async function dotnetRestoreSolution(server: OmniSharpServer, eventStream: EventStream): Promise { +async function dotnetRestoreAllProjects(server: OmniSharpServer, eventStream: EventStream): Promise { let descriptors = await getProjectDescriptors(server); eventStream.post(new CommandDotNetRestoreStart()); for (let descriptor of descriptors) { @@ -132,7 +132,7 @@ export async function dotnetRestoreSolution(server: OmniSharpServer, eventStream } } -async function getProjectDescriptors(server: OmniSharpServer) { +async function getProjectDescriptors(server: OmniSharpServer): Promise { if (!server.isRunning()) { return Promise.reject('OmniSharp server is not running.'); } @@ -146,7 +146,7 @@ async function getProjectDescriptors(server: OmniSharpServer) { return descriptors; } -async function dotnetRestore(cwd: string, eventStream: EventStream, filePath?: string) { +async function dotnetRestore(cwd: string, eventStream: EventStream, filePath?: string): Promise { return new Promise((resolve, reject) => { let cmd = 'dotnet'; let args = ['restore']; diff --git a/src/observers/InformationMessageObserver.ts b/src/observers/InformationMessageObserver.ts index db722353a..473517f0c 100644 --- a/src/observers/InformationMessageObserver.ts +++ b/src/observers/InformationMessageObserver.ts @@ -24,7 +24,7 @@ export class InformationMessageObserver { let csharpConfig = this.vscode.workspace.getConfiguration('csharp'); if (!csharpConfig.get('suppressDotnetRestoreNotification')) { let message = `There are unresolved dependencies in the solution'. Please execute the restore command to continue.`; - return showInformationMessage(this.vscode, message, { title: "Restore", command: "dotnet.restore.solution" }); + return showInformationMessage(this.vscode, message, { title: "Restore", command: "dotnet.restore.all" }); } } } diff --git a/test/unitTests/logging/InformationMessageObserver.test.ts b/test/unitTests/logging/InformationMessageObserver.test.ts index 223c1e3dd..47e0dc2d7 100644 --- a/test/unitTests/logging/InformationMessageObserver.test.ts +++ b/test/unitTests/logging/InformationMessageObserver.test.ts @@ -38,7 +38,7 @@ suite("InformationMessageObserver", () => { [ { event: getUnresolvedDependenices("someFile"), - expectedCommand: "dotnet.restore.solution" + expectedCommand: "dotnet.restore.all" } ].forEach((elem) => { suite(elem.event.constructor.name, () => { From 09e423135b9a5c76026a752fd3a55cb963dfce77 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Wed, 16 May 2018 17:05:29 -0700 Subject: [PATCH 6/9] remove args from info message --- src/observers/utils/MessageItemWithCommand.ts | 1 - src/observers/utils/ShowInformationMessage.ts | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/observers/utils/MessageItemWithCommand.ts b/src/observers/utils/MessageItemWithCommand.ts index d0367f7db..81fec5f34 100644 --- a/src/observers/utils/MessageItemWithCommand.ts +++ b/src/observers/utils/MessageItemWithCommand.ts @@ -7,5 +7,4 @@ import { MessageItem } from "../../vscodeAdapter"; export default interface MessageItemWithCommand extends MessageItem { command: string; - args?: any; } diff --git a/src/observers/utils/ShowInformationMessage.ts b/src/observers/utils/ShowInformationMessage.ts index 5d97bc9ec..02537f3e7 100644 --- a/src/observers/utils/ShowInformationMessage.ts +++ b/src/observers/utils/ShowInformationMessage.ts @@ -4,18 +4,13 @@ *--------------------------------------------------------------------------------------------*/ import { vscode } from "../../vscodeAdapter"; -import MessageItemWithCommand from "./MessageItemWithCommand"; +import MessageItemWithCommand from "./MessageItemWithCommand"; export default async function showInformationMessage(vscode: vscode, message: string, ...items: MessageItemWithCommand[]) { try { let value = await vscode.window.showInformationMessage(message, ...items); if (value && value.command) { - if (value.args) { - vscode.commands.executeCommand(value.command, value.args); - } - else { - vscode.commands.executeCommand(value.command); - } + vscode.commands.executeCommand(value.command); } } catch (err) { From 5610f347605f0aadb1febc20aa5e662d2d0ea245 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Wed, 16 May 2018 17:09:54 -0700 Subject: [PATCH 7/9] Alter the unresolved dependencies message --- src/observers/InformationMessageObserver.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/observers/InformationMessageObserver.ts b/src/observers/InformationMessageObserver.ts index 473517f0c..64afa8823 100644 --- a/src/observers/InformationMessageObserver.ts +++ b/src/observers/InformationMessageObserver.ts @@ -20,10 +20,10 @@ export class InformationMessageObserver { } private async handleOmnisharpServerUnresolvedDependencies(event: ObservableEvent.OmnisharpServerUnresolvedDependencies) { - //to do: determine if we need the unresolved dependecies message + //to do: determine if we need the unresolved dependencies message let csharpConfig = this.vscode.workspace.getConfiguration('csharp'); if (!csharpConfig.get('suppressDotnetRestoreNotification')) { - let message = `There are unresolved dependencies in the solution'. Please execute the restore command to continue.`; + let message = `There are unresolved dependencies'. Please execute the restore command to continue.`; return showInformationMessage(this.vscode, message, { title: "Restore", command: "dotnet.restore.all" }); } } From ef58691e3c5b083665b6281a3cf1bf68c4d544c4 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Fri, 18 May 2018 10:33:20 -0700 Subject: [PATCH 8/9] Rename to Restore all projects --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6daf8cde0..4703fb96e 100644 --- a/package.json +++ b/package.json @@ -613,7 +613,7 @@ }, { "command": "dotnet.restore.all", - "title": "Restore Packages", + "title": "Restore All Projects", "category": ".NET" }, { From ddb85ec96ebee4eb5a59e613850bdf7605dae578 Mon Sep 17 00:00:00 2001 From: Akshita Agarwal Date: Tue, 29 May 2018 21:17:44 +0530 Subject: [PATCH 9/9] use a single disposable --- src/features/commands.ts | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/features/commands.ts b/src/features/commands.ts index 27de1f9c6..c21e8af27 100644 --- a/src/features/commands.ts +++ b/src/features/commands.ts @@ -21,32 +21,33 @@ import CompositeDisposable from '../CompositeDisposable'; import OptionProvider from '../observers/OptionProvider'; export default function registerCommands(server: OmniSharpServer, platformInfo: PlatformInformation, eventStream: EventStream, optionProvider: OptionProvider): CompositeDisposable { - let d1 = vscode.commands.registerCommand('o.restart', () => restartOmniSharp(server)); - let d2 = vscode.commands.registerCommand('o.pickProjectAndStart', async () => pickProjectAndStart(server, optionProvider)); - let d3 = vscode.commands.registerCommand('o.showOutput', () => eventStream.post(new ShowOmniSharpChannel())); - let d4 = vscode.commands.registerCommand('dotnet.restore.project', () => pickProjectAndDotnetRestore(server, eventStream)); - let d5 = vscode.commands.registerCommand('dotnet.restore.all', () => dotnetRestoreAllProjects(server, eventStream)); + let disposable = new CompositeDisposable(); + disposable.add(vscode.commands.registerCommand('o.restart', () => restartOmniSharp(server))); + disposable.add(vscode.commands.registerCommand('o.pickProjectAndStart', async () => pickProjectAndStart(server, optionProvider))); + disposable.add(vscode.commands.registerCommand('o.showOutput', () => eventStream.post(new ShowOmniSharpChannel()))); + disposable.add(vscode.commands.registerCommand('dotnet.restore.project', () => pickProjectAndDotnetRestore(server, eventStream))); + disposable.add(vscode.commands.registerCommand('dotnet.restore.all', () => dotnetRestoreAllProjects(server, eventStream))); // register empty handler for csharp.installDebugger // running the command activates the extension, which is all we need for installation to kickoff - let d6 = vscode.commands.registerCommand('csharp.downloadDebugger', () => { }); + disposable.add(vscode.commands.registerCommand('csharp.downloadDebugger', () => { })); // register process picker for attach let attachItemsProvider = DotNetAttachItemsProviderFactory.Get(); let attacher = new AttachPicker(attachItemsProvider); - let d7 = vscode.commands.registerCommand('csharp.listProcess', async () => attacher.ShowAttachEntries()); + disposable.add(vscode.commands.registerCommand('csharp.listProcess', async () => attacher.ShowAttachEntries())); // Register command for generating tasks.json and launch.json assets. - let d8 = vscode.commands.registerCommand('dotnet.generateAssets', async () => generateAssets(server)); + disposable.add(vscode.commands.registerCommand('dotnet.generateAssets', async () => generateAssets(server))); // Register command for remote process picker for attach - let d9 = vscode.commands.registerCommand('csharp.listRemoteProcess', async (args) => RemoteAttachPicker.ShowAttachEntries(args, platformInfo)); + disposable.add(vscode.commands.registerCommand('csharp.listRemoteProcess', async (args) => RemoteAttachPicker.ShowAttachEntries(args, platformInfo))); // Register command for adapter executable command. - let d10 = vscode.commands.registerCommand('csharp.coreclrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream)); - let d11 = vscode.commands.registerCommand('csharp.clrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream)); + disposable.add(vscode.commands.registerCommand('csharp.coreclrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream))); + disposable.add(vscode.commands.registerCommand('csharp.clrAdapterExecutableCommand', async (args) => getAdapterExecutionCommand(platformInfo, eventStream))); - return new CompositeDisposable(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11); + return new CompositeDisposable(disposable); } function restartOmniSharp(server: OmniSharpServer) {