Skip to content

Commit a3e2596

Browse files
authored
Merge pull request #55 from DanielCarmingham/fix-debug-aspnet-apps
Fix debug aspnet apps
2 parents f7f31f9 + 90e2fb3 commit a3e2596

4 files changed

Lines changed: 18 additions & 38 deletions

File tree

package-lock.json

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "debugmcpextension",
33
"displayName": "DebugMCP",
44
"description": "Let AI agents debug your code inside VS Code — breakpoints, step-through execution, variable inspection, and expression evaluation. Automatically exposes itself as an MCP (Model Context Protocol) server for seamless integration with AI assistants.",
5-
"version": "1.0.9",
5+
"version": "1.1.0",
66
"publisher": "ozzafar",
77
"author": {
88
"name": "Oz Zafar",
@@ -92,6 +92,7 @@
9292
"@modelcontextprotocol/sdk": "^1.26.0",
9393
"@types/express": "^5.0.3",
9494
"express": "^5.2.1",
95+
"jsonc-parser": "^3.3.1",
9596
"zod": "^3.25.76"
9697
},
9798
"devDependencies": {

src/debuggingExecutor.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ export class DebuggingExecutor implements IDebuggingExecutor {
3838
config: vscode.DebugConfiguration
3939
): Promise<boolean> {
4040
try {
41-
if (config.type === 'coreclr') {
42-
// Open the specific test file instead of the workspace folder
43-
const testFileUri = vscode.Uri.file(config.program);
44-
await vscode.commands.executeCommand('vscode.open', testFileUri);
45-
vscode.commands.executeCommand('testing.debugCurrentFile');
46-
return true;
47-
}
4841
const workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(workingDirectory));
4942
return await vscode.debug.startDebugging(workspaceFolder, config);
5043
} catch (error) {
@@ -344,24 +337,7 @@ export class DebuggingExecutor implements IDebuggingExecutor {
344337
* Check if there's an active debug session that is ready for debugging operations
345338
*/
346339
public async hasActiveSession(): Promise<boolean> {
347-
// Quick check first - no session at all
348-
if (!vscode.debug.activeDebugSession) {
349-
return false;
350-
}
351-
352-
try {
353-
// Get the current debug state and check if it has location information
354-
// This is the most reliable way to determine if the debugger is truly ready
355-
const debugState = await this.getCurrentDebugState();
356-
357-
// A session is ready when it has location info (file name and line number)
358-
// This means the debugger has attached and we can see where we are in the code
359-
return debugState.sessionActive && debugState.hasLocationInfo();
360-
} catch (error) {
361-
// Any error means session isn't ready (e.g., Python still initializing)
362-
console.log('Session readiness check failed:', error);
363-
return false;
364-
}
340+
return vscode.debug.activeDebugSession !== undefined;
365341
}
366342

367343
/**

src/utils/debugConfigurationManager.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import * as vscode from 'vscode';
44
import * as path from 'path';
55
import * as fs from 'fs';
6+
import * as jsonc from 'jsonc-parser';
67

78
/**
89
* Interface for configuration management operations
@@ -43,11 +44,8 @@ export class DebugConfigurationManager implements IDebugConfigurationManager {
4344
const launchJsonDoc = await vscode.workspace.openTextDocument(launchJsonPath);
4445
const launchJsonContent = launchJsonDoc.getText();
4546

46-
// Parse the JSON (removing comments and trailing commas first)
47-
let cleanJson = launchJsonContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
48-
// Remove trailing commas before closing brackets/braces
49-
cleanJson = cleanJson.replace(/,(\s*[}\]])/g, '$1');
50-
const launchConfig = JSON.parse(cleanJson);
47+
// Parse JSONC (JSON with comments and trailing commas)
48+
const launchConfig = jsonc.parse(launchJsonContent);
5149

5250
if (launchConfig.configurations && Array.isArray(launchConfig.configurations) && launchConfig.configurations.length > 0) {
5351
// If a specific configuration name is provided, find it
@@ -150,6 +148,7 @@ export class DebugConfigurationManager implements IDebugConfigurationManager {
150148
'.tsx': 'node',
151149
'.java': 'java',
152150
'.cs': 'coreclr',
151+
'.csproj': 'coreclr',
153152
'.cpp': 'cppdbg',
154153
'.cc': 'cppdbg',
155154
'.c': 'cppdbg',
@@ -259,11 +258,8 @@ export class DebugConfigurationManager implements IDebugConfigurationManager {
259258
const launchJsonDoc = await vscode.workspace.openTextDocument(launchJsonPath);
260259
const launchJsonContent = launchJsonDoc.getText();
261260

262-
// Parse the JSON (removing comments and trailing commas first)
263-
let cleanJson = launchJsonContent.replace(/\/\*[\s\S]*?\*\/|\/\/.*$/gm, '');
264-
// Remove trailing commas before closing brackets/braces
265-
cleanJson = cleanJson.replace(/,(\s*[}\]])/g, '$1');
266-
const launchConfig = JSON.parse(cleanJson);
261+
// Parse JSONC (JSON with comments and trailing commas)
262+
const launchConfig = jsonc.parse(launchJsonContent);
267263

268264
if (launchConfig.configurations && Array.isArray(launchConfig.configurations)) {
269265
return launchConfig.configurations.map((config: any) => config.name || 'Unnamed Configuration');

0 commit comments

Comments
 (0)