dotnet/vscode-csharp

coreclr debug configuration should support input variables for `envFile`

karolz-ms opened this issue · 6 comments

VS Code has a mechanism called "input variables" where debug configuration values can be resolved by running arbitrary commands, picking an item from predefined list, or prompting the user: https://code.visualstudio.com/docs/editor/variables-reference#_input-variables

Node.js and Python debug configuration providers support this mechanism. Unfortunately, coreclr seems to lack this support.

Repro steps

  1. Create a debug configuration that uses an input variable, for example
{
    "configurations": [
        {
            "name": "Debug API",
            "type": "coreclr",
            "request": "launch",
            // other properties as necessary
            "envFile": "${input:getPathToFile}"
        }
    ],
    "inputs": [
        {
            "id": "getPathToFile",
            "type": "promptString"
             // The really interesting/important case is type==command.
             // promptString is used just to simplify the repro
         }
    ]
}
  1. Try using the configuration

Expected result

Should prompt the user for the path to the .env file

Actual result

Can't parse envFile ${input:getPathToFile} because of Error: ENOENT: no such file or directory, open '${input:getPathToFile}'

The C# extension does support 'inputs', except for envFile. I am not sure if it would be possible for envFile to support inputs or not -- we handle envFile in our configuration resolver, which runs before inputs are completed. I don't know if we can push it to a later stage.

Well, Node and Python do support input variables for envFile, so maybe C# can do that too.

Maybe @connor4312 can help by explaining how it is done, or point us to relevant code in JS debugger extension?

I don't think how it is done in the JS debugger will be relevant -- we could make this work by reimplementing envFile natively in our debug adapter. But if there isn't a good way to solve this without doing that I think we would probably just "Won't Fix" this bug.

js-debug handles it at launch time, but you could also change this extension to resolve envFile after variables are substituted via the relatively-new post-substitution method in the resolver.

@gregg-miskelly we came to the point in our schedule where we will need this, so I am going to try to come up with a PR if that is OK with you

@karolz-ms Sounds great