Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove check for projectPath for resolveDebugConfiguration #6754

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"Cannot create .NET debug configurations. The server is still initializing or has exited unexpectedly.": "Cannot create .NET debug configurations. The server is still initializing or has exited unexpectedly.",
"Cannot create .NET debug configurations. The active C# project is not within folder '{0}'.": "Cannot create .NET debug configurations. The active C# project is not within folder '{0}'.",
"Does not contain .NET Core projects.": "Does not contain .NET Core projects.",
"'{0}' was not set in the debug configuration.": "'{0}' was not set in the debug configuration.",
"'{0}' request is not supported for the '{1}' configuration.": "'{0}' request is not supported for the '{1}' configuration.",
"'{0}' was not provided in the debug configuration.": "'{0}' was not provided in the debug configuration.",
"Can not find an opened workspace folder. Please open a folder before starting to debug with a '{0}' configuration'.": "Can not find an opened workspace folder. Please open a folder before starting to debug with a '{0}' configuration'.",
"No launchable target found.": "No launchable target found.",
"No launchable target found for '{0}'": "No launchable target found for '{0}'",
"Cannot resolve .NET debug configurations. The server is still initializing or has exited unexpectedly.": "Cannot resolve .NET debug configurations. The server is still initializing or has exited unexpectedly.",
"Unable to determine a configuration for '{0}'. Please generate C# debug assets instead.": "Unable to determine a configuration for '{0}'. Please generate C# debug assets instead.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface IDotnetDebugConfigurationServiceResult {

export interface IDotnetDebugConfigurationService {
resolveDebugConfigurationWithLaunchConfigurationService(
projectPath: string,
projectPath: string | undefined,
debugConfiguration: vscode.DebugConfiguration,
token?: vscode.CancellationToken
): Promise<IDotnetDebugConfigurationServiceResult>;
Expand Down
44 changes: 36 additions & 8 deletions src/shared/dotnetConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ function resolveWorkspaceFolderToken(projectPath: string, folderPath: string): s
}

export class DotnetConfigurationResolver implements vscode.DebugConfigurationProvider {
static dotnetType = 'dotnet';

constructor(
private workspaceDebugInfoProvider: IWorkspaceDebugInformationProvider,
private dotnetWorkspaceConfigurationProvider: DotnetWorkspaceConfigurationProvider
Expand All @@ -73,12 +75,24 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
}

if (debugConfiguration.request !== 'launch') {
throw new Error(`'${debugConfiguration.request}' is unsupported.`);
if (!debugConfiguration.request) {
throw new Error(vscode.l10n.t("'{0}' was not set in the debug configuration.", 'request'));
gregg-miskelly marked this conversation as resolved.
Show resolved Hide resolved
} else {
throw new Error(
vscode.l10n.t(
"'{0}' request is not supported for the '{1}' configuration.",
debugConfiguration.request,
DotnetConfigurationResolver.dotnetType
)
);
}
}

let projectPath: string = debugConfiguration.projectPath;
if (folder && projectPath) {
projectPath = resolveWorkspaceFolderToken(projectPath, folder.uri.fsPath);
let projectPath: string | undefined = debugConfiguration.projectPath;
if (folder) {
WardenGnaw marked this conversation as resolved.
Show resolved Hide resolved
if (projectPath) {
projectPath = resolveWorkspaceFolderToken(projectPath, folder.uri.fsPath);
}

const dotnetDebugServiceProxy = await getServiceBroker()?.getProxy<IDotnetDebugConfigurationService>(
Descriptors.dotnetDebugConfigurationService
Expand All @@ -96,6 +110,11 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
throw new UnavaliableLaunchServiceError();
}
} catch (e) {
if (!projectPath) {
throw new LaunchServiceError(
vscode.l10n.t("'{0}' was not provided in the debug configuration.", 'projectPath')
);
}
if (e instanceof UnavaliableLaunchServiceError) {
return await this.resolveDebugConfigurationWithWorkspaceDebugInformationProvider(
folder,
Expand All @@ -109,15 +128,20 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
} finally {
dotnetDebugServiceProxy?.dispose();
}
} else {
throw new Error(
vscode.l10n.t(
"Can not find an opened workspace folder. Please open a folder before starting to debug with a '{0}' configuration'.",
DotnetConfigurationResolver.dotnetType
)
);
}

return debugConfiguration;
}

//#endregion

private resolveDotnetDebugConfigurationServiceResult(
projectPath: string,
projectPath: string | undefined,
result: IDotnetDebugConfigurationServiceResult
): vscode.DebugConfiguration {
if (result.error) {
Expand All @@ -135,7 +159,11 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro

const debugConfigArray = result.configurations;
if (debugConfigArray.length == 0) {
throw new LaunchServiceError(vscode.l10n.t("No launchable target found for '{0}'", projectPath));
if (!projectPath) {
throw new LaunchServiceError(vscode.l10n.t('No launchable target found.'));
} else {
throw new LaunchServiceError(vscode.l10n.t("No launchable target found for '{0}'", projectPath));
}
}
if (debugConfigArray.length == 1) {
return debugConfigArray[0];
Expand Down