diff --git a/l10n/bundle.l10n.json b/l10n/bundle.l10n.json index 3403fc14c..54094eb70 100644 --- a/l10n/bundle.l10n.json +++ b/l10n/bundle.l10n.json @@ -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.", diff --git a/src/lsptoolshost/services/IDotnetDebugConfigurationService.ts b/src/lsptoolshost/services/IDotnetDebugConfigurationService.ts index e3b93b9e1..52d57d6a5 100644 --- a/src/lsptoolshost/services/IDotnetDebugConfigurationService.ts +++ b/src/lsptoolshost/services/IDotnetDebugConfigurationService.ts @@ -23,7 +23,7 @@ export interface IDotnetDebugConfigurationServiceResult { export interface IDotnetDebugConfigurationService { resolveDebugConfigurationWithLaunchConfigurationService( - projectPath: string, + projectPath: string | undefined, debugConfiguration: vscode.DebugConfiguration, token?: vscode.CancellationToken ): Promise; diff --git a/src/shared/dotnetConfigurationProvider.ts b/src/shared/dotnetConfigurationProvider.ts index 4cb2e3513..fec07860c 100644 --- a/src/shared/dotnetConfigurationProvider.ts +++ b/src/shared/dotnetConfigurationProvider.ts @@ -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 @@ -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')); + } 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) { + if (projectPath) { + projectPath = resolveWorkspaceFolderToken(projectPath, folder.uri.fsPath); + } const dotnetDebugServiceProxy = await getServiceBroker()?.getProxy( Descriptors.dotnetDebugConfigurationService @@ -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, @@ -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) { @@ -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];