You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Variable Substitution in launch.json not visible in debug configuration provider #85206
*duplicateIssue identified as a duplicate of another issue(s)debugDebug viewlet, configurations, breakpoints, adapter issuesfeature-requestRequest for new features or functionality
According to this paragraph variable substitution is supposed to work also in launch.json, used to configure debug sessions. However it appears not to work, at least I don't get the resolved variables in my DebugConfigurationProvider.resolveDebugConfiguration function. The passed in options still contain the unresolved variables, making it so impossible to use the given values (e.g. the current file, given as ${file} to set up my debugger.
Here's a sshot that shows the extension host with the launch setting and the debug config resolver:
VS Code version: Code 1.40.1 (8795a98, 2019-11-13T16:47:44.719Z)
OS version: Darwin x64 19.0.0
System Info
Item
Value
CPUs
Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz (12 x 3500)
By design variable substitution occurs after DebugConfigurationProvider.resolveDebugConfiguration and before passing the launch config to the debug adapter.
This makes it possible to have DebugConfigurationProvider.resolveDebugConfiguration add additional variables.
Hmm, sorry, that makes not much sense given the description of the resolve function:
Resolves a debug configuration by filling in missing values or by adding/changing/removing attributes.
How can I change attributes, if I cannot understand them? Seems there is a discrepancy between the purpose you intent and what can be understood from the description.
That bears a side question: if the resolve function is not intented to validate configuration values (and cancel the debug session if something is wrong), what else should we use instead for that kind of processing?
The description of resolveDebugConfiguration makes a lot of sense since "filling in missing" values and "adding/changing/removing attributes" can be done without a need to see the "final" values.
Evidence for this you can see in node-debug's resolve method.
Any validation that can only be performed on the final values can be done (and is actually done) in the debug adapter (see launchRequest in the node-debug DA).
Having said this, I can still imagine to introduce a new aboutToLaunch method on the DebugConfigurationProvider that receives the "final" fully resolved debug configuration.
I've changed this issue into a feature request and I'm now waiting for upvotes...
I see your points, however launching the debug adapter might involve quite a few things to do, which are unnecessary when there are problems with the files being debugged. Hence my original idea was to figure out everything in the resolve function upfront, before I even create the debug adapter. I'll move my validation logic to launchRequest then. Thanks for the hint.
A new validation function might still be useful (be it named aboutToLaunch or validate or whatever).
We will add another hook resolveDebugConfiguration2 to the DebugConfigurationProvider that receives the debug configuration with all variables resolved.
I've created an extension API request for this: #87450
With this API all code that relies on resolved variables can be moved from resolveDebugConfiguration to resolveDebugConfiguration2.
That's great news Andre Weinand (@weinand)! As for the naming I suggest processResolvedDebugConfiguration to indicate this something that follows the resolution step. Another name could be validateDebugConfiguration which also indicates that this is a step after resolution and should be used to check all final values for their correctness (do file exists? etc.). I prefer the second name, now that I found it :-)
resolveDebugConfiguration2 works best for me. The name is clear that it does the same thing as resolveDebugConfiguration with minor differences. processResolvedDebugConfiguration is also ok for me.
Some other naming ideas: handleResolvedDebugConfiguration, resolveResolvedDebugConfiguration (sounds funky)
validateDebugConfiguration does not work for me since it sounds like it does more than what it actually will do
After talking to Johannes Rieken (@jrieken) we agreed on the expressive resolveDebugConfigurationWithSubstitutedVariables (which becomes a nominee at the VS Code longest-variable-name contest).
If it's only about the variables substitution you could go another route: provide an API to resolve the values. It would be totally fine for me to call that to resolve all variables and act on them in the original resolveDebugConfiguration. You probably already have such a function interally. Just make it public and you you will not need that new hook.
Mike Lischke (@mike-lischke) yes, we've considered this as well but providing (and using) a variable resolver function as API is tricky because variables can be tied to commands which might result in arbitrary user interactions (e.g. if an interactive variable is used more than once, we only show the UI once and apply the resulting value in different places). So we really want to stay away from that approach and use the two-phase approach instead.
I've added a new optional hook resolveDebugConfigurationWithSubstitutedVariables to the DebugConfigurationProvider.
Support for it will be available in the next Insiders (or immediately if you are running out of source).
Please note: this is proposed API which might still change until the end of this milestone (January).
Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.
*duplicateIssue identified as a duplicate of another issue(s)debugDebug viewlet, configurations, breakpoints, adapter issuesfeature-requestRequest for new features or functionality
Activity
vscodebot commentedon Nov 20, 2019
(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
weinand commentedon Nov 20, 2019
By design variable substitution occurs after
DebugConfigurationProvider.resolveDebugConfigurationand before passing the launch config to the debug adapter.This makes it possible to have
DebugConfigurationProvider.resolveDebugConfigurationadd additional variables.mike-lischke commentedon Nov 20, 2019
But how can I then determine the actual values for the variables if not in that method, which is supposed to resolve the configuration?
weinand commentedon Nov 20, 2019
All resolved values are available in your debug adapter which is part of your extension.
mike-lischke commentedon Nov 21, 2019
Hmm, sorry, that makes not much sense given the description of the resolve function:
How can I change attributes, if I cannot understand them? Seems there is a discrepancy between the purpose you intent and what can be understood from the description.
That bears a side question: if the resolve function is not intented to validate configuration values (and cancel the debug session if something is wrong), what else should we use instead for that kind of processing?
weinand commentedon Nov 21, 2019
The description of
resolveDebugConfigurationmakes a lot of sense since "filling in missing" values and "adding/changing/removing attributes" can be done without a need to see the "final" values.Evidence for this you can see in node-debug's resolve method.
Any validation that can only be performed on the final values can be done (and is actually done) in the debug adapter (see
launchRequestin the node-debug DA).Having said this, I can still imagine to introduce a new
aboutToLaunchmethod on theDebugConfigurationProviderthat receives the "final" fully resolved debug configuration.I've changed this issue into a feature request and I'm now waiting for upvotes...
mike-lischke commentedon Nov 21, 2019
I see your points, however launching the debug adapter might involve quite a few things to do, which are unnecessary when there are problems with the files being debugged. Hence my original idea was to figure out everything in the resolve function upfront, before I even create the debug adapter. I'll move my validation logic to
launchRequestthen. Thanks for the hint.A new validation function might still be useful (be it named
aboutToLaunchorvalidateor whatever).weinand commentedon Dec 20, 2019
We will add another hook
resolveDebugConfiguration2to theDebugConfigurationProviderthat receives the debug configuration with all variables resolved.I've created an extension API request for this: #87450
With this API all code that relies on resolved variables can be moved from
resolveDebugConfigurationtoresolveDebugConfiguration2.Mike Lischke (@mike-lischke) Connor Peet (@connor4312) roblourens Isidor Nikolic (@isidorn)
Please let me know if anybody has ideas for a better name than
resolveDebugConfiguration2.mike-lischke commentedon Dec 21, 2019
That's great news Andre Weinand (@weinand)! As for the naming I suggest
processResolvedDebugConfigurationto indicate this something that follows the resolution step. Another name could bevalidateDebugConfigurationwhich also indicates that this is a step after resolution and should be used to check all final values for their correctness (do file exists? etc.). I prefer the second name, now that I found it :-)1 remaining item
isidorn commentedon Dec 23, 2019
resolveDebugConfiguration2works best for me. The name is clear that it does the same thing asresolveDebugConfigurationwith minor differences.processResolvedDebugConfigurationis also ok for me.Some other naming ideas:
handleResolvedDebugConfiguration,resolveResolvedDebugConfiguration(sounds funky)validateDebugConfigurationdoes not work for me since it sounds like it does more than what it actually will doweinand commentedon Dec 23, 2019
Johannes Rieken (@jrieken)
processResolvedDebugConfigurationorresolveDebugConfiguration2, what do you prefer?weinand commentedon Dec 23, 2019
After talking to Johannes Rieken (@jrieken) we agreed on the expressive
resolveDebugConfigurationWithSubstitutedVariables(which becomes a nominee at the VS Code longest-variable-name contest).isidorn commentedon Dec 23, 2019
Works for me. At least it is clear what it does exactly.
mike-lischke commentedon Dec 23, 2019
If it's only about the variables substitution you could go another route: provide an API to resolve the values. It would be totally fine for me to call that to resolve all variables and act on them in the original
resolveDebugConfiguration. You probably already have such a function interally. Just make it public and you you will not need that new hook.weinand commentedon Dec 23, 2019
Mike Lischke (@mike-lischke) yes, we've considered this as well but providing (and using) a variable resolver function as API is tricky because variables can be tied to commands which might result in arbitrary user interactions (e.g. if an interactive variable is used more than once, we only show the UI once and apply the resulting value in different places). So we really want to stay away from that approach and use the two-phase approach instead.
add API resolveDebugConfigurationWithSubstitutedVariables; see #85206
weinand commentedon Dec 23, 2019
I've added a new optional hook
resolveDebugConfigurationWithSubstitutedVariablesto theDebugConfigurationProvider.Support for it will be available in the next Insiders (or immediately if you are running out of source).
Please note: this is proposed API which might still change until the end of this milestone (January).
weinand commentedon Jan 8, 2020
/duplicate #87450
vscodebot commentedon Jan 8, 2020
Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.
Happy Coding!
weinand commentedon Jan 8, 2020
Mike Lischke (@mike-lischke) the new API is now official and in vscode.d.ts.