Skip to content

Commit c01efc0

Browse files
authored
Fix Attach to .NET Process before Roslyn LSP is ready (#7427)
* Fix Attach to .NET Process before Roslyn LSP is ready This PR passes the roslynServerStartedProcess to the coreClrDebug activate call as the Roslyn Server registers the 'coreclr' DebugConfigurationProvider that will handle the process listing for the user to select the process ID. If the configuration provider is not registered but the adapter factory is, it will send it to the debugger without a processName or processId and will fail with that error.
1 parent 25dc516 commit c01efc0

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

l10n/bundle.l10n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@
191191
"Unexpected message received from debugger.": "Unexpected message received from debugger.",
192192
"[ERROR]: C# Extension failed to install the debugger package.": "[ERROR]: C# Extension failed to install the debugger package.",
193193
"Could not find a process id to attach.": "Could not find a process id to attach.",
194+
"Unable to launch Attach to Process dialog: ": "Unable to launch Attach to Process dialog: ",
194195
"[ERROR] The debugger cannot be installed. The debugger is not supported on '{0}'": "[ERROR] The debugger cannot be installed. The debugger is not supported on '{0}'",
195196
"[ERROR] The debugger cannot be installed. The debugger requires macOS 12 (Monterey) or newer.": "[ERROR] The debugger cannot be installed. The debugger requires macOS 12 (Monterey) or newer.",
196197
"[WARNING]: x86 Windows is not supported by the .NET debugger. Debugging will not be available.": "[WARNING]: x86 Windows is not supported by the .NET debugger. Debugging will not be available.",

src/coreclrDebug/activate.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export async function activate(
2626
context: vscode.ExtensionContext,
2727
platformInformation: PlatformInformation,
2828
eventStream: EventStream,
29-
csharpOutputChannel: vscode.OutputChannel
29+
csharpOutputChannel: vscode.OutputChannel,
30+
languageServerStartedPromise: Promise<any> | undefined
3031
) {
3132
const disposables = new CompositeDisposable();
3233

@@ -66,6 +67,19 @@ export async function activate(
6667
// Register a command to fire attach to process for the coreclr debug engine.
6768
disposables.add(
6869
vscode.commands.registerCommand('csharp.attachToProcess', async () => {
70+
// Ensure dotnetWorkspaceConfigurationProvider is registered
71+
if (languageServerStartedPromise) {
72+
try {
73+
await languageServerStartedPromise;
74+
} catch (e: any) {
75+
if (e as Error) {
76+
throw new Error(vscode.l10n.t('Unable to launch Attach to Process dialog: ') + e.message);
77+
} else {
78+
throw e;
79+
}
80+
}
81+
}
82+
6983
vscode.debug.startDebugging(
7084
undefined,
7185
{

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ export async function activate(
323323
context,
324324
platformInfo,
325325
eventStream,
326-
csharpChannel
326+
csharpChannel,
327+
roslynLanguageServerStartedPromise ?? omnisharpLangServicePromise
327328
);
328329
}
329330

0 commit comments

Comments
 (0)