@@ -117,13 +117,12 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
117
117
const noDebug : boolean = debugConfiguration . noDebug ?? false ;
118
118
const preferSSL : boolean = ! this . platformInformation . isLinux ( ) && ! vscode . env . remoteName && vscode . env . uiKind != vscode . UIKind . Web ;
119
119
const launchTargets : LaunchTarget [ ] = await launchConfigurationServiceProxy . queryLaunchTargets ( projectPath , { noDebug : noDebug , preferSSL : preferSSL } , token ) ;
120
- for ( let launchTarget of launchTargets ) {
121
- const convertedLaunchTarget : vscode . DebugConfiguration | undefined = LaunchTargetToDebugConfigurationConverter . convert ( debugConfiguration , launchTarget ) ;
122
- if ( convertedLaunchTarget ) {
123
- debugConfigurations . push ( convertedLaunchTarget ) ;
124
- } else {
125
- throw new InternalServiceError ( "Unable to convert launch target to a vscode debug configuration." ) ;
126
- }
120
+ const convertedLaunchTargets : vscode . DebugConfiguration [ ] | undefined = LaunchTargetToDebugConfigurationConverter . convert ( debugConfiguration , launchTargets ) ;
121
+
122
+ if ( convertedLaunchTargets ) {
123
+ debugConfigurations = debugConfigurations . concat ( convertedLaunchTargets ) ;
124
+ } else {
125
+ throw new InternalServiceError ( "Unable to convert launch target to a vscode debug configuration." ) ;
127
126
}
128
127
129
128
if ( debugConfigurations . length == 1 ) {
@@ -209,24 +208,39 @@ export class DotnetConfigurationResolver implements vscode.DebugConfigurationPro
209
208
}
210
209
211
210
class LaunchTargetToDebugConfigurationConverter {
212
- static convert ( debugConfiguration : vscode . DebugConfiguration , launchTarget : LaunchTarget ) : vscode . DebugConfiguration | undefined {
213
- if ( launchTarget . debugEngines . length > 1 ) {
214
- throw new InternalServiceError ( `Multiple debug engines are currently unsupported: '${ launchTarget . debugEngines . join ( "," ) } '` ) ;
215
- }
211
+ static convert ( debugConfiguration : vscode . DebugConfiguration , launchTargets : LaunchTarget [ ] ) : vscode . DebugConfiguration [ ] | undefined {
212
+ let debugConfigurations : vscode . DebugConfiguration [ ] = [ ] ;
216
213
217
- if ( ExeLaunchTarget . is ( launchTarget ) ) {
218
- return LaunchTargetToDebugConfigurationConverter . convertExeLaunchTarget ( debugConfiguration , launchTarget ) ;
219
- } else if ( BrowserLaunchTarget . is ( launchTarget ) ) {
220
- LaunchTargetToDebugConfigurationConverter . convertBrowserLaunchTarget ( debugConfiguration , launchTarget ) ;
221
- throw new InternalServiceError ( `BrowserLaunchTarget is not implemented.\nDebugConfiguration: ${ debugConfiguration } \nLaunchTarget: ${ launchTarget } ` ) ;
222
- } else if ( CustomLaunchTarget . is ( launchTarget ) ) {
223
- throw new InternalServiceError ( `CustomLaunchTarget is not implemented.\nDebugConfiguration: ${ debugConfiguration } \nLaunchTarget: ${ launchTarget } ` ) ;
224
- } else if ( ErrorLaunchTarget . is ( launchTarget ) ) {
225
- // TODO: Handle launchTarget.details
226
- throw new LaunchServiceError ( launchTarget . userMessage ) ;
214
+ for ( let launchTarget of launchTargets )
215
+ {
216
+ if ( launchTarget . debugEngines . length > 1 ) {
217
+ throw new InternalServiceError ( `Multiple debug engines are currently unsupported: '${ launchTarget . debugEngines . join ( "," ) } '` ) ;
218
+ }
219
+
220
+ if ( ExeLaunchTarget . is ( launchTarget ) ) {
221
+ debugConfigurations . push ( LaunchTargetToDebugConfigurationConverter . convertExeLaunchTarget ( debugConfiguration , launchTarget ) ) ;
222
+ } else if ( BrowserLaunchTarget . is ( launchTarget ) ) {
223
+ const lastConfig : vscode . DebugConfiguration | undefined = debugConfigurations . pop ( ) ;
224
+ if ( lastConfig ) {
225
+ const browserLaunchTarget : any = LaunchTargetToDebugConfigurationConverter . convertBrowserLaunchTarget ( launchTarget ) ;
226
+ debugConfigurations . push ( {
227
+ ...lastConfig ,
228
+ ...browserLaunchTarget
229
+ } ) ;
230
+ } else {
231
+ throw new InternalServiceError ( `Expected an ExeLaunchTarget before seeing a BrowserLaunchTarget.` ) ;
232
+ }
233
+ } else if ( CustomLaunchTarget . is ( launchTarget ) ) {
234
+ throw new InternalServiceError ( `CustomLaunchTarget is not implemented.\nDebugConfiguration: ${ debugConfiguration } \nLaunchTarget: ${ launchTarget } ` ) ;
235
+ } else if ( ErrorLaunchTarget . is ( launchTarget ) ) {
236
+ // TODO: Handle launchTarget.details
237
+ throw new LaunchServiceError ( launchTarget . userMessage ) ;
238
+ } else {
239
+ throw new InternalServiceError ( `Unknown LaunchTarget type: '${ launchTarget . constructor . name } '` ) ;
240
+ }
227
241
}
228
242
229
- return undefined ;
243
+ return debugConfigurations ;
230
244
}
231
245
232
246
private static convertExeLaunchTarget ( debugConfiguration : vscode . DebugConfiguration , exeLaunchTarget : ExeLaunchTarget ) : vscode . DebugConfiguration {
@@ -243,11 +257,13 @@ class LaunchTargetToDebugConfigurationConverter {
243
257
} ;
244
258
}
245
259
246
- private static convertBrowserLaunchTarget ( debugConfiguration : vscode . DebugConfiguration , browserLaunchTarget : BrowserLaunchTarget ) : vscode . DebugConfiguration {
260
+ private static convertBrowserLaunchTarget ( browserLaunchTarget : BrowserLaunchTarget ) : any {
247
261
return {
248
- "name" : debugConfiguration . name ,
249
- "type" : browserLaunchTarget . debugEngines [ 0 ] ,
250
- "request" : debugConfiguration . request
262
+ "serverReadyAction" : {
263
+ "action" : "openExternally" ,
264
+ "pattern" : "\\bNow listening on:\\s+https?://\\S+" ,
265
+ "uriFormat" : browserLaunchTarget . url ,
266
+ }
251
267
} ;
252
268
}
253
269
}
0 commit comments