Skip to content

Commit 0e17bc1

Browse files
Fix unit test debugging post October VSCode breaking change (#1800)
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.
1 parent f993d74 commit 0e17bc1

File tree

4 files changed

+9
-21
lines changed

4 files changed

+9
-21
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"tslint-microsoft-contrib": "^2.0.12",
6464
"typescript": "^2.0.3",
6565
"vsce": "^1.7.0",
66-
"vscode": "^1.0.3"
66+
"vscode": "^1.1.6"
6767
},
6868
"runtimeDependencies": [
6969
{
@@ -190,7 +190,7 @@
190190
}
191191
],
192192
"engines": {
193-
"vscode": "^1.12.0"
193+
"vscode": "^1.15.0"
194194
},
195195
"activationEvents": [
196196
"onLanguage:csharp",

src/features/codeLensProvider.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,9 @@ export default class OmniSharpCodeLensProvider extends AbstractProvider implemen
134134
toRange(node.Location),
135135
{ title: "run test", command: 'dotnet.test.run', arguments: [testFeature.Data, fileName, testFrameworkName] }));
136136

137-
if (this._server.isDebugEnable()) {
138-
bucket.push(new vscode.CodeLens(
139-
toRange(node.Location),
140-
{ title: "debug test", command: 'dotnet.test.debug', arguments: [testFeature.Data, fileName, testFrameworkName] }));
141-
}
137+
bucket.push(new vscode.CodeLens(
138+
toRange(node.Location),
139+
{ title: "debug test", command: 'dotnet.test.debug', arguments: [testFeature.Data, fileName, testFrameworkName] }));
142140
}
143141
}
144142
}

src/features/dotnetTest.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,10 @@ export default class TestManager extends AbstractProvider {
304304
}
305305
})
306306
.then(() => this._getLaunchConfiguration(debugType, fileName, testMethod, testFrameworkName, targetFrameworkVersion, debugEventListener))
307-
.then(config => vscode.commands.executeCommand('vscode.startDebug', config))
307+
.then(config => {
308+
const workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(fileName));
309+
return vscode.debug.startDebugging(workspaceFolder, config);
310+
})
308311
.catch(reason => {
309312
vscode.window.showErrorMessage(`Failed to start debugger: ${reason}`);
310313
if (debugEventListener != null) {

src/omnisharp/server.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ export class OmniSharpServer {
7878
private _channel: vscode.OutputChannel;
7979
private _logger: Logger;
8080

81-
private _isDebugEnable: boolean = false;
82-
8381
private _serverProcess: ChildProcess;
8482
private _options: Options;
8583

@@ -146,10 +144,6 @@ export class OmniSharpServer {
146144
return this._channel;
147145
}
148146

149-
public isDebugEnable(): boolean {
150-
return this._isDebugEnable;
151-
}
152-
153147
// --- eventing
154148

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

287281
return this._doConnect();
288-
}).then(() => {
289-
return vscode.commands.getCommands()
290-
.then(commands => {
291-
if (commands.find(c => c === 'vscode.startDebug')) {
292-
this._isDebugEnable = true;
293-
}
294-
});
295282
}).then(() => {
296283
// Start telemetry reporting
297284
this._telemetryIntervalId = setInterval(() => this._reportTelemetry(), TelemetryReportingDelay);

0 commit comments

Comments
 (0)