Skip to content

Commit 170e039

Browse files
authored
Workaround for 'coreclr' dotnetWorkspaceConfigurationProvider (#5960)
VS Code handles resolveDebugConfiguration for converting the 'dotnet' type to 'coreclr'. However, it will call resolveDebugConfigurationWithSubstitutedVariables on the 'dotnet' type and never call the 'coreclr' one. This workaround will take the 'coreclr' dotnetWorkspaceConfigurationProvider in the 'dotnet' ConfigurationProvider and just call into it as a workaround.
1 parent 9ab5f1e commit 170e039

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

src/lsptoolshost/debugger.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,22 @@ export function registerDebugger(
3636
});
3737
context.subscriptions.push(disposable);
3838

39+
const dotnetWorkspaceConfigurationProvider = new DotnetWorkspaceConfigurationProvider(
40+
workspaceInformationProvider,
41+
platformInfo,
42+
optionProvider,
43+
csharpOutputChannel
44+
);
45+
3946
// Register ConfigurationProvider
4047
context.subscriptions.push(
4148
vscode.debug.registerDebugConfigurationProvider(
4249
'dotnet',
43-
new DotnetConfigurationResolver(workspaceInformationProvider)
50+
new DotnetConfigurationResolver(workspaceInformationProvider, dotnetWorkspaceConfigurationProvider)
4451
)
4552
);
4653
context.subscriptions.push(
47-
vscode.debug.registerDebugConfigurationProvider(
48-
'coreclr',
49-
new DotnetWorkspaceConfigurationProvider(
50-
workspaceInformationProvider,
51-
platformInfo,
52-
optionProvider,
53-
csharpOutputChannel
54-
)
55-
)
54+
vscode.debug.registerDebugConfigurationProvider('coreclr', dotnetWorkspaceConfigurationProvider)
5655
);
5756
context.subscriptions.push(
5857
vscode.commands.registerCommand('dotnet.generateAssets', async (selectedIndex) =>

src/shared/dotnetConfigurationProvider.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
IDotnetDebugConfigurationService,
1515
IDotnetDebugConfigurationServiceResult,
1616
} from '../lsptoolshost/services/IDotnetDebugConfigurationService';
17+
import { DotnetWorkspaceConfigurationProvider } from './workspaceConfigurationProvider';
1718

1819
// User errors that can be shown to the user.
1920
class LaunchServiceError extends Error {}
@@ -54,7 +55,10 @@ function resolveWorkspaceFolderToken(projectPath: string, folderPath: string): s
5455
}
5556

5657
export class DotnetConfigurationResolver implements vscode.DebugConfigurationProvider {
57-
constructor(private workspaceDebugInfoProvider: IWorkspaceDebugInformationProvider) {}
58+
constructor(
59+
private workspaceDebugInfoProvider: IWorkspaceDebugInformationProvider,
60+
private dotnetWorkspaceConfigurationProvider: DotnetWorkspaceConfigurationProvider
61+
) {}
5862

5963
//#region vscode.DebugConfigurationProvider
6064

@@ -199,4 +203,17 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
199203
}
200204
throw new Error(`Unable to determine debug settings for project '${projectPath}'`);
201205
}
206+
207+
// Workaround for VS Code not calling into the 'coreclr' resolveDebugConfigurationWithSubstitutedVariables
208+
async resolveDebugConfigurationWithSubstitutedVariables(
209+
folder: vscode.WorkspaceFolder | undefined,
210+
debugConfiguration: vscode.DebugConfiguration,
211+
token?: vscode.CancellationToken
212+
): Promise<vscode.DebugConfiguration | null | undefined> {
213+
return this.dotnetWorkspaceConfigurationProvider.resolveDebugConfigurationWithSubstitutedVariables(
214+
folder,
215+
debugConfiguration,
216+
token
217+
);
218+
}
202219
}

0 commit comments

Comments
 (0)