Open BenjaminBrienen opened 1 year ago
As I was trying to do some TDD in C# on code-server/coder I encountered this aswell and took a swing at trying to figure this out.
Turns out, this doesn't come from the plugin, this is a reply from netcoredbg
- fattening up the coredbg-dbg/activate.ts
by more debug parameters for netcoredbg in the command const...
if (!executable) {
const command = path.join(common.getExtensionPath(), ".debugger", "netcoredbg", "netcoredbg" + CoreClrDebugUtil.getPlatformExeExtension());
executable = new vscode.DebugAdapterExecutable(command, ["--interpreter=vscode", "--log=file", "--engineLogging=/tmp/netcoredbg.engine.log"]);
}
actually gives you the reason for the error:
After a bit of digging, I actually found out, this is due to omnisharp
returning a string for the parameter arguments
in src/features/TestManager.ts
, function _getLaunchConfigurationForVSTest
- in turn making the full debugConfiguration
that is being sent to the netcoredbg
process something like this:
args:'exec --runtimeconfig "/server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0/Tests.runtimeconfig.json" --depsfile "/server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0/Tests.deps.json" "/server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0/testhost.dll" --port 42327 --endpoint 127.0.0.1:042327 --role client --parentprocessid 16161 --telemetryoptedin false'
cwd:'/server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0'
debuggerEventsPipeName:'/tmp/ms-dotnettools.csharp-tde-15078'
env:{}
logging:{}
name:'.NET Test Launch'
program:'/dotnet_7.0.100/dotnet'
request:'launch'
type:'coreclr'
This upsets netcoredbg
to the point where it just quits because it expects args
to be an array:
-> (C) {"command":"launch","arguments":{"logging":{},"type":"coreclr","name":".NET Test Launch","request":"launch","debuggerEventsPipeName":"/tmp/ms-dotnettools.csharp-tde-15078","program":"/dotnet_7.0.100/dotnet","args":"exec --runtimeconfig \"/server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0/Tests.runtimeconfig.json\" --depsfile \"/server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0/Tests.deps.json\" \"/server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0/testhost.dll\" --port 42327 --endpoint 127.0.0.1:042327 --role client --parentprocessid 16161 --telemetryoptedin false","cwd":"/server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0","env":{},"internalConsoleOptions":"openOnSessionStart","__sessionId":"9bcbfde8-d9df-412e-bf33-a0f5373b87dd"},"type":"request","seq":5}
<- (R) {"command":"launch","message":"can't parse: [json.exception.type_error.302] type must be array, but is string","request_seq":5,"seq":"7","success":false,"type":"response"}
Right now I am able to fix this issue by adding this code to src/coreclr-debug/debugConfigurationProvider.ts
before returning the debugConfiguration
object:
if ("args" in debugConfiguration){
if (typeof debugConfiguration["args"] === "string") {
debugConfiguration["args"] = debugConfiguration["args"].replaceAll("\"","").split(" ");
}
}
This solves the issue of the starting issue, but actually causes a separate issue - executing the command like that does work, but now causes another error down the line, as soon as it switches to the Debug console
window, as it tries to do something funky with dotnet exec
. Perhaps that may be something with my environment tho (code-server in podman/docker), so I'll leave my findings here, for someone more knowledgeable than me.
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-exec does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
This mystery is also solved, it turns out, netcordbg is funny
, the following command line is being launched:
/usr/local/bin/dotnet /dotnet_7.0.100/dotnet exec --runtimeconfig /server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0/Tests.runtimeconfig.json --depsfile /server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0/Tests.deps.json /server-root/home/kuhnchris/projects/matrix-dev/MatrixCSharpProject/Tests/bin/Debug/net6.0/testhost.dll --port 40045 --endpoint 127.0.0.1:040045 --role client --parentprocessid 12616 --telemetryoptedin false
See the double "dotnet"? For some reason the fileExec
parameter is not being set on the vscodeprotocol
side, so it basically does the appendage in netcoredbg
, see https://github.com/Samsung/netcoredbg/blob/db69338cf1606d8d327de0eaaf1694d8463af135/src/protocols/vscodeprotocol.cpp#L582
So the "change" I did in debugConfigurationProvider.ts
actually to just add a shift to the args array and push the first argument into the program value, since it gets executed and prepended anyways:
if ("args" in debugConfiguration){
if (typeof debugConfiguration["args"] === "string") {
debugConfiguration["args"] = debugConfiguration["args"].replaceAll("\"","").split(" ");
}
}
debugConfiguration["program"] = debugConfiguration["args"].shift();
return debugConfiguration;
This leaves me with the problem that this thing is now stuck. It shows me the threads on the left, you can also "halt" them and resume them, but you cannot stop or terminate it, plus you have to killall dotnet
and do a Restart Omnisharp from the Command Palette to get things back running again, so... still some things left to do. Maybe stopAtEntry
to false
or justMyCode
to false to see what's going on, but I have to stop here and continue my quest to solve this another time - if anyone else got the mental brain capacity to walk through this let me know if you got anymore success.
Thanks!
Clicking this button on a unit test:![image](https://user-images.githubusercontent.com/42162869/217040254-6fffd5cf-ce3c-49ec-9bbd-be6a6d080a0e.png)
Results in:![image](https://user-images.githubusercontent.com/42162869/217039907-328e97b5-b844-4fd4-8b2a-36d47a7d3be3.png)
can't parse: [json.exception.type_error.302] type must be array, but is string
launch.json:
(Also happens with default configuration)
My best guess is that the error is coming from here, but I truly have no idea. https://github.com/OmniSharp/omnisharp-vscode/blob/f807bafc3a332ea612f7b82a7bc0dc1a793825de/src/coreclr-debug/debuggerEventsProtocol.ts#L39
Pop!_OS .NET 7.0.102 XXX/.vscode-oss/extensions/muhammad-sammy.csharp-1.25.0-universal/.omnisharp/1.39.0-net6.0/OmniSharp.dll
Log: