Skip to content

Commit

Permalink
Fix unit test debugging post October VSCode breaking change (#1800)
Browse files Browse the repository at this point in the history
This checkin changes the C# extension so that unit test debugging will still work once the `vscode.StartDebug` command is removed.

To do this I changed our package.json so that we require the 1.15 (July) release of VS Code, and switched to using the new API.
  • Loading branch information
gregg-miskelly authored Oct 24, 2017
1 parent f993d74 commit 0e17bc1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"tslint-microsoft-contrib": "^2.0.12",
"typescript": "^2.0.3",
"vsce": "^1.7.0",
"vscode": "^1.0.3"
"vscode": "^1.1.6"
},
"runtimeDependencies": [
{
Expand Down Expand Up @@ -190,7 +190,7 @@
}
],
"engines": {
"vscode": "^1.12.0"
"vscode": "^1.15.0"
},
"activationEvents": [
"onLanguage:csharp",
Expand Down
8 changes: 3 additions & 5 deletions src/features/codeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,9 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
toRange(node.Location),
{ title: "run test", command: 'dotnet.test.run', arguments: [testFeature.Data, fileName, testFrameworkName] }));

if (this._server.isDebugEnable()) {
bucket.push(new vscode.CodeLens(
toRange(node.Location),
{ title: "debug test", command: 'dotnet.test.debug', arguments: [testFeature.Data, fileName, testFrameworkName] }));
}
bucket.push(new vscode.CodeLens(
toRange(node.Location),
{ title: "debug test", command: 'dotnet.test.debug', arguments: [testFeature.Data, fileName, testFrameworkName] }));
}
}
}
5 changes: 4 additions & 1 deletion src/features/dotnetTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ export default class TestManager extends AbstractProvider {
}
})
.then(() => this._getLaunchConfiguration(debugType, fileName, testMethod, testFrameworkName, targetFrameworkVersion, debugEventListener))
.then(config => vscode.commands.executeCommand('vscode.startDebug', config))
.then(config => {
const workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(fileName));
return vscode.debug.startDebugging(workspaceFolder, config);
})
.catch(reason => {
vscode.window.showErrorMessage(`Failed to start debugger: ${reason}`);
if (debugEventListener != null) {
Expand Down
13 changes: 0 additions & 13 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ export class OmniSharpServer {
private _channel: vscode.OutputChannel;
private _logger: Logger;

private _isDebugEnable: boolean = false;

private _serverProcess: ChildProcess;
private _options: Options;

Expand Down Expand Up @@ -146,10 +144,6 @@ export class OmniSharpServer {
return this._channel;
}

public isDebugEnable(): boolean {
return this._isDebugEnable;
}

// --- eventing

public onStdout(listener: (e: string) => any, thisArg?: any) {
Expand Down Expand Up @@ -285,13 +279,6 @@ export class OmniSharpServer {
this._fireEvent(Events.ServerStart, solutionPath);

return this._doConnect();
}).then(() => {
return vscode.commands.getCommands()
.then(commands => {
if (commands.find(c => c === 'vscode.startDebug')) {
this._isDebugEnable = true;
}
});
}).then(() => {
// Start telemetry reporting
this._telemetryIntervalId = setInterval(() => this._reportTelemetry(), TelemetryReportingDelay);
Expand Down

0 comments on commit 0e17bc1

Please sign in to comment.