Skip to content

Commit

Permalink
Respond to peer review
Browse files Browse the repository at this point in the history
  • Loading branch information
captainsafia committed May 14, 2020
1 parent 2ed3e96 commit 146d0dd
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,9 @@
"properties": {
"cwd": {
"type": "string",
"description": "The directory of the Blazor WASM app, defaults to the workspace folder.",
"description": "The directory of the Blazor WebAssembly app, defaults to the workspace folder.",
"default": "${workspaceFolder}"
},
"env": {
"type": "object",
"description": "Environment variables passed to dotnet"
},
"url": {
"type": "string",
"description": "The URL of the application",
Expand All @@ -93,7 +89,7 @@
"type": ["boolean", "string"],
"default": "true",
"enum": ["verbose", true],
"description": "If true, verbose logs sent to log file. If 'verbose', send logs to console."
"description": "If true, verbose logs from JS debugger are sent to log file. If 'verbose', send logs to console."
},
"webRoot": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

// import { spawn } from 'child_process';
import * as vscode from 'vscode';

import { RazorLogger } from '../RazorLogger';
import { onDidTerminateDebugSession } from './Events';
import { onDidTerminateDebugSession } from './TerminateDebugHandler';

export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurationProvider {

Expand All @@ -17,11 +16,10 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati
const shellPath = process.platform === 'win32' ? 'cmd.exe' : 'dotnet';
const shellArgs = process.platform === 'win32' ? ['/c', 'chcp 65001 >NUL & dotnet run'] : ['run'];
const spawnOptions = {
cwd: configuration.cwd || folder && folder.uri && folder.uri.fsPath,
cwd: configuration.cwd || (folder && folder.uri && folder.uri.fsPath),
env: {
...process.env,
ASPNETCORE_ENVIRONMENT: 'Development',
...configuration.env,
},
};

Expand All @@ -41,7 +39,7 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati
terminate.dispose();
});

output.show();
output.show(/*preserveFocus*/true);

const browser = {
name: '.NET Core Debug Blazor Web Assembly in Browser',
Expand All @@ -55,8 +53,6 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati
noDebug: configuration.noDebug || false,
};

let showErrorInfo = false;

try {
/**
* The browser debugger will immediately launch after the
Expand All @@ -74,12 +70,13 @@ export class BlazorDebugConfigurationProvider implements vscode.DebugConfigurati
'[DEBUGGER] Error when launching browser debugger: ',
error,
);
showErrorInfo = true;
}

if (showErrorInfo) {
const message = `There was an unexpected error while launching your debugging session. Check the console for helpful logs and visit https://aka.ms/blazorwasmcodedebug for more info.`;
this.vscodeType.window.showErrorMessage(message);
const message = `There was an unexpected error while launching your debugging session. Check the console for helpful logs and visit the debugging docs for more info.`;
this.vscodeType.window.showErrorMessage(message, `View Debug Docs`, `Ignore`).then(async result => {
if (result === 'View Debug Docs') {
const debugDocsUri = 'https://aka.ms/blazorwasmcodedebug';
await this.vscodeType.commands.executeCommand(`vcode.open`, debugDocsUri);
}
});
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import * as psList from 'ps-list';
import { DebugSession } from 'vscode';

import { RazorLogger } from '../RazorLogger';

export async function onDidTerminateDebugSession(
event: DebugSession,
logger: RazorLogger,
targetPid: number | undefined,
) {
if (!targetPid) {
return;
}

logger.logVerbose(`[DEBUGGER] Terminating debugging session with PID ${targetPid}...`);

let processes: psList.ProcessDescriptor[] = [];
try {
processes = await psList();
} catch (error) {
logger.logError(`Error retrieving processes under PID ${targetPid} to clean-up: `, error);
}

try {
process.kill(targetPid);
processes.map((proc) => {
if (proc.ppid === targetPid) {
process.kill(proc.pid);
}
});
logger.logVerbose(`[DEBUGGER] Debug process clean-up of PID ${targetPid} complete.`);
} catch (error) {
logger.logError(`[DEBUGGER] Error terminating debug processes with PID ${targetPid}: `, error);
}
}

0 comments on commit 146d0dd

Please sign in to comment.