Skip to content

Commit 0b7f6c8

Browse files
Debugger: Support Console.ReadLine with 'internalConsole' (#6569)
This PR pulls in a new version of the debugger that supports `Console.ReadLine` and `Console.Read` when using `"console":"internalConsole"` (the default value). This also updates documentation. This addresses #5704 Two other minor changes I noticed while I was here: * Updated the changelog to correctly indicate when the 'long string' fix went it * Updated links in the debugger md files that were still pointing at OmniSharp
1 parent efd9e7f commit 0b7f6c8

File tree

6 files changed

+73
-34
lines changed

6 files changed

+73
-34
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Update Razor to 7.0.0-preview.23516.2 (PR: [#6550](https://github.com/dotnet/vscode-csharp/pull/6550))
1010
* Make sure correct info is passed in code action resolve (PR: [razor#9420](https://github.com/dotnet/razor/pull/9420))
1111

12-
## 2.7.?
12+
## 2.7.25
1313
* Update Razor to 7.0.0-preview.23513.5 (PR: [#6551](https://github.com/dotnet/vscode-csharp/pull/6551))
1414
* Reduce noisy errors when viewing git diff (PR: [razor#9407](https://github.com/dotnet/razor/pull/9407))
1515
* Update Roslyn to 4.9.0-1.23513.7 (PR: [#6548](https://github.com/dotnet/vscode-csharp/pull/6548))
@@ -20,6 +20,7 @@
2020
* Fix dotnet path resolution when using snap installed packages (PR: [#6515](https://github.com/dotnet/vscode-csharp/pull/6515))
2121
* Track debugging sessions until csdevkit is initialized (PR: [#6480](https://github.com/dotnet/vscode-csharp/pull/6480))
2222
* Update vsdbg and vsdbg-ui to 2.0.4 (PR: [#6517](https://github.com/dotnet/vscode-csharp/pull/6517))
23+
* Debugger: better handle long strings ([#6496](https://github.com/dotnet/vscode-csharp/issues/6496)). Strings are truncated if they are longer than 1024 UTF-16 characters, but the full value up to 5,242,880 characters or 10 megabytes, is available using 'Copy Value' in the watch or variables window. Truncated strings will end with '...'.
2324
* Add setting to control Razor component commit behaviour (PR: [#6506](https://github.com/dotnet/vscode-csharp/pull/6506))
2425
* Razor textmate colorization fixes (PR: [#6514](https://github.com/dotnet/vscode-csharp/pull/6514))
2526

@@ -48,7 +49,6 @@
4849
* Update Razor project configuration file name (PR: [#70156](https://github.com/dotnet/roslyn/pull/70156))* added support.md file (PR: [#6478](https://github.com/dotnet/vscode-csharp/pull/6478))
4950
* Debugger: Improve the display of various debug configurations and snippets (PR: [#6456](https://github.com/dotnet/vscode-csharp/pull/6456))
5051
* Initialize Razor even if Razor doc isn't opened yet (PR: [#6473](https://github.com/dotnet/vscode-csharp/pull/6473))
51-
* Debugger: better handle long strings ([#6496](https://github.com/dotnet/vscode-csharp/issues/6496)). Strings are truncated if they are longer than 1024 UTF-16 characters, but the full value up to 5,242,880 characters or 10 megabytes, is available using 'Copy Value' in the watch or variables window. Truncated strings will end with '...'.
5252

5353
## 2.5.30
5454
* Add code action fix all support (PR: [#6310](https://github.com/dotnet/vscode-csharp/pull/6310))

debugger-launchjson.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,19 @@ Environment variables may be passed to your program using this schema:
124124

125125
The `"console"` setting controls what console (terminal) window the target app is launched into. It can be set to any of these values --
126126

127-
`"internalConsole"` (default) : the target process's console output (stdout/stderr) goes to the VS Code Debug Console. This is useful for executables that take their input from the network, files, etc. But this does **NOT** work for applications that want to read from the console (ex: `Console.ReadLine`).
127+
`"internalConsole"` (default) : the target process's console input (stdin) and output (stdout/stderr) are routed through the VS Code Debug Console. The advantage of this mode is that it allows you to see messages from both the debugger and the target program in one place, so you will not miss important messages or need to switch back and forth. This is useful for programs with simple console interactions (example: using `Console.WriteLine` and/or `Console.ReadLine`). This should NOT be used when the target program needs full control over the console, such as a program that changes the cursor position, uses `Console.ReadKey` for input, etc. See below for instructions on inputting into the console.
128128

129-
`"integratedTerminal"` : the target process will run inside [VS Code's integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal). Click the 'Terminal' tab in the tab group beneath the editor to interact with your application. Alternatively add `"internalConsoleOptions": "neverOpen"` to make it so that the default foreground tab is the terminal tab.
129+
`"integratedTerminal"` : the target process will run inside [VS Code's integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal). Click the 'Terminal' tab in the tab group beneath the editor to interact with your application. When using this mode, by default, the Debug Console will not be shown when starting debugging. This can be configured with `internalConsoleOptions`.
130130

131-
`"externalTerminal"`: the target process will run inside its own external terminal.
131+
`"externalTerminal"`: the target process will run inside its own external terminal. When using this mode, you will need to switch focus between Visual Studio Code and the external terminal window.
132+
133+
### Inputting text into the target process when using `internalConsole`
134+
135+
When using `internalConsole`, you can input text into Visual Studio Code that will be returned from `Console.ReadLine` and similar APIs that read from `stdin`. To do so, while the program is running, type text into the input box at the bottom of the Debug Console. Pressing enter will send the text to the target process. Note that if you enter text in this box while your program is stopped under the debugger, this text will be evaluated as a C# expression, not sent to the target process.
136+
137+
Example:
138+
139+
![Example of inputting text to the Console to be set to the target process's standard input](https://raw.githubusercontent.com/wiki/dotnet/vscode-csharp/images/ConsoleInput.gif)
132140

133141
## launchSettings.json support
134142

@@ -352,4 +360,4 @@ Example:
352360

353361
```json
354362
"checkForDevCert": "false"
355-
```
363+
```

debugger.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This page gives you detailed instructions on how to debug code running under .NET Core in VS Code.
33

44
#### Your Feedback​
5-
File bugs and feature requests [here](https://github.com/OmniSharp/omnisharp-vscode/issues) to help us build great tooling for .NET Core.
5+
File bugs and feature requests [here](https://github.com/dotnet/vscode-csharp/issues) to help us build great tooling for .NET Core.
66

77
### First Time setup
88
##### 1: Get Visual Studio Code
@@ -43,15 +43,15 @@ VS Code needs to be configured so it understands how to build your project and d
4343

4444
If you open the folder containing your project, the C# extension can automatically generate these files for you if you have a basic project. When you open a project and the C# extension is installed, you should see the following prompt in VS Code:
4545

46-
![Info: Required assets to build and debug are missing from your project. Add them? Yes | Close](https://raw.githubusercontent.com/wiki/OmniSharp/omnisharp-vscode/images/info-bar-add-required-assets.png)
46+
![Info: Required assets to build and debug are missing from your project. Add them? Yes | Close](https://raw.githubusercontent.com/wiki/dotnet/vscode-csharp/images/info-bar-add-required-assets.png)
4747

4848
Clicking `Yes` on this prompt should add these resources.
4949

5050
**Creating configuration files manually**
5151

5252
If your code has multiple projects or you would rather generate these files by hand, here is how --
5353

54-
**.vscode/tasks.json**: Start with [this example](https://raw.githubusercontent.com/wiki/OmniSharp/omnisharp-vscode/ExampleCode/tasks.json) which configures VS Code to launch `dotnet build`. Update the `cwd` property if your project isn't in the root of the open folder. If you don't want to build from VS Code at all, you can skip this file. If you do this, you will need to comment out the `preLaunchTask` from .vscode/launch.json when you create it.
54+
**.vscode/tasks.json**: Start with [this example](https://raw.githubusercontent.com/wiki/dotnet/vscode-csharp/ExampleCode/tasks.json) which configures VS Code to launch `dotnet build`. Update the `cwd` property if your project isn't in the root of the open folder. If you don't want to build from VS Code at all, you can skip this file. If you do this, you will need to comment out the `preLaunchTask` from .vscode/launch.json when you create it.
5555

5656
**.vscode/launch.json**: When you want to start debugging, press the debugger play button (or press <kbd>F5</kbd>) as you would normally do. VS Code will provide a list of templates to select from. Pick ".NET Core" from this list and the edit the `program` property to indicate the path to the application dll or .NET Core host executable to launch. For example:
5757

@@ -67,27 +67,27 @@ Your project is now all set. Set a breakpoint or two where you want to stop, cli
6767
If your code was built on a different computer from where you would like to run in there are a few things to keep in mind --
6868

6969
* **Source Maps**: Unless your local source code is at exactly the same path as where the code was originally built you will need to add a [sourceFileMap](https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md#source-file-map) to launch.json.
70-
* **Portable PDBs**: If the code was built on Windows, it might have been built using Windows PDBs instead of portable PDBs, but the C# extension only supports portable PDBs. See the [portable PDB documentation](https://github.com/OmniSharp/omnisharp-vscode/wiki/Portable-PDBs#how-to-generate-portable-pdbs) for more information.
70+
* **Portable PDBs**: If the code was built on Windows, it might have been built using Windows PDBs instead of portable PDBs, but the C# extension only supports portable PDBs. See the [portable PDB documentation](https://github.com/dotnet/vscode-csharp/wiki/Portable-PDBs#how-to-generate-portable-pdbs) for more information.
7171
* **Debug vs. Release**: It is much easier to debug code which has been compiled in the `Debug` configuration. So unless the issue you are looking at only reproduces with optimizations, it is much better to use Debug bits. If you do need to debug optimized code, you will need to disable [justMyCode](https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md#just-my-code) in launch.json.
7272

7373
#### [Configurating launch.json for C# Debugging](debugger-launchjson.md)
7474

7575
#### Attach Support
7676
The C# debugger supports attaching to processes. To do this, switch to the Debug tab, and open the configuration drop down.
7777

78-
![Debug launch configuration drop down](https://raw.githubusercontent.com/wiki/OmniSharp/omnisharp-vscode/images/debug-launch-configurations.png)
78+
![Debug launch configuration drop down](https://raw.githubusercontent.com/wiki/dotnet/vscode-csharp/images/debug-launch-configurations.png)
7979

8080
Select the '.NET Core Attach' configuration. Clicking the play button (or pressing <kbd>F5</kbd>) will then try to attach. In launch.json, if `processId` is set to `""` this will provide UI to select which process to attach to.
8181

8282
#### Remote Debugging
8383

84-
The debugger supports remotely launching or attaching to processes. See [Attaching to remote processes](https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes) in the wiki for more information.
84+
The debugger supports remotely launching or attaching to processes. See [Attaching to remote processes](https://github.com/dotnet/vscode-csharp/wiki/Attaching-to-remote-processes) in the wiki for more information.
8585

8686
#### Exception Settings
8787

8888
The VS Code .NET debugger supports configuration options for if the debugger stops when exceptions are thrown or caught. This is done through two different entries in the BREAKPOINTS section of the Run view:
8989

90-
![Exceptions settings in BREAKPOINTS Run View](https://raw.githubusercontent.com/wiki/OmniSharp/omnisharp-vscode/images/Exception-Settings.png)
90+
![Exceptions settings in BREAKPOINTS Run View](https://raw.githubusercontent.com/wiki/dotnet/vscode-csharp/images/Exception-Settings.png)
9191

9292
Note that the BREAKPOINTS section will be missing these entries until the first time that the folder has been debugged with the .NET debugger.
9393

package.json

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@
444444
{
445445
"id": "Debugger",
446446
"description": ".NET Core Debugger (Windows / x64)",
447-
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-4/coreclr-debug-win7-x64.zip",
447+
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-5/coreclr-debug-win7-x64.zip",
448448
"installPath": ".debugger/x86_64",
449449
"platforms": [
450450
"win32"
@@ -454,12 +454,12 @@
454454
"arm64"
455455
],
456456
"installTestPath": "./.debugger/x86_64/vsdbg-ui.exe",
457-
"integrity": "2CC5A41316626EF61CA29368913DA6BD9A98FEC0677AAF25A3513F76C1BE57DB"
457+
"integrity": "35E83F9425333AC617E288A07ECAE21A0125E822AF059135CBBC4C8893A6A562"
458458
},
459459
{
460460
"id": "Debugger",
461461
"description": ".NET Core Debugger (Windows / ARM64)",
462-
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-4/coreclr-debug-win10-arm64.zip",
462+
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-5/coreclr-debug-win10-arm64.zip",
463463
"installPath": ".debugger/arm64",
464464
"platforms": [
465465
"win32"
@@ -468,12 +468,12 @@
468468
"arm64"
469469
],
470470
"installTestPath": "./.debugger/arm64/vsdbg-ui.exe",
471-
"integrity": "39845F9C1F69D1A23C36EB3BD54E377CD1298A67E425DCF9906C055BB9388EB5"
471+
"integrity": "FF75A11B6F4293981BF9EC74666D0C1D41549EDC89F532982CE5009D0C63BCAC"
472472
},
473473
{
474474
"id": "Debugger",
475475
"description": ".NET Core Debugger (macOS / x64)",
476-
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-4/coreclr-debug-osx-x64.zip",
476+
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-5/coreclr-debug-osx-x64.zip",
477477
"installPath": ".debugger/x86_64",
478478
"platforms": [
479479
"darwin"
@@ -487,12 +487,12 @@
487487
"./vsdbg"
488488
],
489489
"installTestPath": "./.debugger/x86_64/vsdbg-ui",
490-
"integrity": "D6715726EBF09969A1341B227CC363F7D1B6D3558ADEA67349BB48B4D29502AD"
490+
"integrity": "FB219A04886B15AE8896B20ACE8A63725CBC59839CC20DA66E2061C49914918D"
491491
},
492492
{
493493
"id": "Debugger",
494494
"description": ".NET Core Debugger (macOS / arm64)",
495-
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-4/coreclr-debug-osx-arm64.zip",
495+
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-5/coreclr-debug-osx-arm64.zip",
496496
"installPath": ".debugger/arm64",
497497
"platforms": [
498498
"darwin"
@@ -505,12 +505,12 @@
505505
"./vsdbg"
506506
],
507507
"installTestPath": "./.debugger/arm64/vsdbg-ui",
508-
"integrity": "370B63DCAB00D12255891EB29BF5FB6CEC84B4457106F67017400CB19328B72D"
508+
"integrity": "1BBDCFAF4BA7A1D0A383AF7BCF498BCF535531BC385CED1E5CE1F53F3D44B2E2"
509509
},
510510
{
511511
"id": "Debugger",
512512
"description": ".NET Core Debugger (linux / ARM)",
513-
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-4/coreclr-debug-linux-arm.zip",
513+
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-5/coreclr-debug-linux-arm.zip",
514514
"installPath": ".debugger",
515515
"platforms": [
516516
"linux"
@@ -523,12 +523,12 @@
523523
"./vsdbg"
524524
],
525525
"installTestPath": "./.debugger/vsdbg-ui",
526-
"integrity": "FBC80CBA32E51151DEF28754B9E1B5B87A9153BC2DF76F71C95D752E676EA8F8"
526+
"integrity": "F166A10B134F31A048039FB13C3EEDB0C7BF60DD9276BC533C41E4A57815CD3E"
527527
},
528528
{
529529
"id": "Debugger",
530530
"description": ".NET Core Debugger (linux / ARM64)",
531-
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-4/coreclr-debug-linux-arm64.zip",
531+
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-5/coreclr-debug-linux-arm64.zip",
532532
"installPath": ".debugger",
533533
"platforms": [
534534
"linux"
@@ -541,12 +541,12 @@
541541
"./vsdbg"
542542
],
543543
"installTestPath": "./.debugger/vsdbg-ui",
544-
"integrity": "684271EB3D7715D7B96656D743F7A34F1D16F3E0464B755066305AABB45E7096"
544+
"integrity": "4A113139E24CD498CFC4F72167921B1911E03603BB1D74AEBAABE73B2F2E7FBF"
545545
},
546546
{
547547
"id": "Debugger",
548548
"description": ".NET Core Debugger (linux musl / x64)",
549-
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-4/coreclr-debug-linux-musl-x64.zip",
549+
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-5/coreclr-debug-linux-musl-x64.zip",
550550
"installPath": ".debugger",
551551
"platforms": [
552552
"linux-musl"
@@ -559,12 +559,12 @@
559559
"./vsdbg"
560560
],
561561
"installTestPath": "./.debugger/vsdbg-ui",
562-
"integrity": "B492504AC6A8FAE7D93445D037F608417DD65E14FF080AA9913CC0E8AA4BE6EA"
562+
"integrity": "C26312FC5450542231933869A2B20682057785F1BEF38BDC8828CB187829C1F7"
563563
},
564564
{
565565
"id": "Debugger",
566566
"description": ".NET Core Debugger (linux musl / ARM64)",
567-
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-4/coreclr-debug-linux-musl-arm64.zip",
567+
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-5/coreclr-debug-linux-musl-arm64.zip",
568568
"installPath": ".debugger",
569569
"platforms": [
570570
"linux-musl"
@@ -577,12 +577,12 @@
577577
"./vsdbg"
578578
],
579579
"installTestPath": "./.debugger/vsdbg-ui",
580-
"integrity": "46BAE37A95413CEB23E3B9A11B125E73DA4F2BADF75C66A19D3BCB1C389F788C"
580+
"integrity": "F49BF6AD38646DA79A4D085BC05D9D948D436871EE57C3036E5BD45688BDF9B2"
581581
},
582582
{
583583
"id": "Debugger",
584584
"description": ".NET Core Debugger (linux / x64)",
585-
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-4/coreclr-debug-linux-x64.zip",
585+
"url": "https://vsdebugger.azureedge.net/coreclr-debug-2-0-5/coreclr-debug-linux-x64.zip",
586586
"installPath": ".debugger",
587587
"platforms": [
588588
"linux"
@@ -595,7 +595,7 @@
595595
"./vsdbg"
596596
],
597597
"installTestPath": "./.debugger/vsdbg-ui",
598-
"integrity": "1A56E250BF066D46B828F00F3AA1D30C48CDB92DF37691C5E34AAD7705D22CEC"
598+
"integrity": "B8D8D0C03C1B5F2793826CA283271DC25C64494C62E748AD3B681A8B6AB535F6"
599599
},
600600
{
601601
"id": "Razor",
@@ -1850,6 +1850,11 @@
18501850
"markdownDescription": "%generateOptionsSchema.logging.diagnosticsLog.startDebuggingTracing.markdownDescription%",
18511851
"default": false
18521852
},
1853+
"csharp.debug.logging.consoleUsageMessage": {
1854+
"type": "boolean",
1855+
"description": "%generateOptionsSchema.logging.consoleUsageMessage.description%",
1856+
"default": true
1857+
},
18531858
"csharp.debug.suppressJITOptimizations": {
18541859
"type": "boolean",
18551860
"markdownDescription": "%generateOptionsSchema.suppressJITOptimizations.markdownDescription%",
@@ -2434,6 +2439,11 @@
24342439
"default": false
24352440
}
24362441
}
2442+
},
2443+
"consoleUsageMessage": {
2444+
"type": "boolean",
2445+
"description": "%generateOptionsSchema.logging.consoleUsageMessage.description%",
2446+
"default": true
24372447
}
24382448
}
24392449
},
@@ -2934,6 +2944,11 @@
29342944
"default": false
29352945
}
29362946
}
2947+
},
2948+
"consoleUsageMessage": {
2949+
"type": "boolean",
2950+
"description": "%generateOptionsSchema.logging.consoleUsageMessage.description%",
2951+
"default": true
29372952
}
29382953
}
29392954
},
@@ -3710,6 +3725,11 @@
37103725
"default": false
37113726
}
37123727
}
3728+
},
3729+
"consoleUsageMessage": {
3730+
"type": "boolean",
3731+
"description": "%generateOptionsSchema.logging.consoleUsageMessage.description%",
3732+
"default": true
37133733
}
37143734
}
37153735
},
@@ -4210,6 +4230,11 @@
42104230
"default": false
42114231
}
42124232
}
4233+
},
4234+
"consoleUsageMessage": {
4235+
"type": "boolean",
4236+
"description": "%generateOptionsSchema.logging.consoleUsageMessage.description%",
4237+
"default": true
42134238
}
42144239
}
42154240
},
@@ -5610,4 +5635,4 @@
56105635
}
56115636
]
56125637
}
5613-
}
5638+
}

0 commit comments

Comments
 (0)