Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug strings are truncated #6496

Closed
HughGrovesArup opened this issue Oct 5, 2023 · 19 comments
Closed

Debug strings are truncated #6496

HughGrovesArup opened this issue Oct 5, 2023 · 19 comments

Comments

@HughGrovesArup
Copy link

Type: Bug

Issue Description

Note that version 2.4.2 and before of the C# plugin does not display this behaviour.

Steps to Reproduce

  • Create a project with a string longer than 1000 chars
  • Enter debug mode and copy the string

Expected Behavior

Should be able to see full string length, or be able to configure this limit.

(We need to see the full length strings for our debugging purposes, string length has not bee an issue so far - even very long ones).

Actual Behavior

String cutoff with ellipsis

Logs

C# log

Post the output from Output-->C# here

C# LSP Trace Logs

Post the output from Output-->C# LSP Trace Logs here. Requires `dotnet.server.trace` to be set to `Trace`

Environment information

VSCode version: 1.83.0
C# Extension: 2.4.2
Using OmniSharp: false

Dotnet Information .NET SDK: Version: 7.0.306 Commit: f500069cb7

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.306\

Host:
Version: 7.0.9
Architecture: x64
Commit: 8e9a17b221

.NET SDKs installed:
2.1.700 [C:\Program Files\dotnet\sdk]
2.2.203 [C:\Program Files\dotnet\sdk]
5.0.214 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.317 [C:\Program Files\dotnet\sdk]
7.0.306 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Visual Studio Code Extensions
Extension Author Version Folder Name
autodocstring njpwerner 0.6.1 njpwerner.autodocstring-0.6.1
code-spell-checker streetsidesoftware 3.0.1 streetsidesoftware.code-spell-checker-3.0.1
csdevkit ms-dotnettools 0.5.150 ms-dotnettools.csdevkit-0.5.150-win32-x64
csharp ms-dotnettools 2.4.2 ms-dotnettools.csharp-2.4.2-win32-x64
designcheck2 designcheck 2.11.1 designcheck.designcheck2-2.11.1
docomment k--kato 1.0.0 k--kato.docomment-1.0.0
duplicate-finder tlevesque2 0.0.6 tlevesque2.duplicate-finder-0.0.6
git-graph mhutchie 1.30.0 mhutchie.git-graph-1.30.0
git-tree-compare letmaik 1.16.0 letmaik.git-tree-compare-1.16.0
gitlens eamodio 14.3.0 eamodio.gitlens-14.3.0
jupyter ms-toolsai 2023.9.1102792234 ms-toolsai.jupyter-2023.9.1102792234-win32-x64
jupyter-keymap ms-toolsai 1.1.2 ms-toolsai.jupyter-keymap-1.1.2
jupyter-renderers ms-toolsai 1.0.17 ms-toolsai.jupyter-renderers-1.0.17
live-server ms-vscode 0.4.9 ms-vscode.live-server-0.4.9
markdowntable TakumiI 0.10.4 takumii.markdowntable-0.10.4
python ms-python 2023.16.0 ms-python.python-2023.16.0
rainbow-csv mechatroner 3.7.1 mechatroner.rainbow-csv-3.7.1
rest-client humao 0.25.1 humao.rest-client-0.25.1
taskrunnercode SanaAjani 0.3.0 sanaajani.taskrunnercode-0.3.0
vetur octref 0.37.3 octref.vetur-0.37.3
vscode-dotnet-runtime ms-dotnettools 1.8.0 ms-dotnettools.vscode-dotnet-runtime-1.8.0
vscode-innosetup chouzz 1.9.2 chouzz.vscode-innosetup-1.9.2
vscode-jupyter-cell-tags ms-toolsai 0.1.8 ms-toolsai.vscode-jupyter-cell-tags-0.1.8
vscode-jupyter-slideshow ms-toolsai 0.1.5 ms-toolsai.vscode-jupyter-slideshow-0.1.5
vscode-markdownlint DavidAnson 0.52.0 davidanson.vscode-markdownlint-0.52.0
vscode-paste-image mushan 1.0.4 mushan.vscode-paste-image-1.0.4
vscode-pull-request-github GitHub 0.74.0 github.vscode-pull-request-github-0.74.0
vscode-pylance ms-python 2023.10.10 ms-python.vscode-pylance-2023.10.10
vscodeintellicode-csharp ms-dotnettools 0.1.26 ms-dotnettools.vscodeintellicode-csharp-0.1.26-win32-x64

Extension version: 2.4.2
VS Code version: Code 1.83.0 (e7e037083ff4455cf320e344325dacb480062c3c, 2023-10-03T16:12:16.321Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz (12 x 2712)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.78GB (12.82GB free)
Process Argv --folder-uri file:///c%3A/Users/Hugh.Groves/Documents/Repos/designcheck2 --crash-reporter-id 1318d4a6-2dcd-40d8-a964-cd7608499b71
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vslsvsres303:30308271
vserr242cf:30382550
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
pythonvs932:30410667
vsclangdf:30486550
c4g48928:30535728
dsvsc012cf:30540253
pynewext54:30695312
azure-dev_surveyone:30548225
2e4cg342:30602488
89544117:30613380
showlangstatbar:30737416
03d35959:30757346
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxptcf:30805731
pythonnoceb:30805159
copilotsettingc:30839828
synctok:30821570
dsvsc013:30795093
dsvsc014:30804076
diffeditorv2:30821572
pythonmpsinfo:30842941
dsvsc015:30845448

@gregg-miskelly
Copy link
Contributor

Thanks for reporting this @HughGrovesArup

Two notes:

  1. The expected behavior is that the initial value displayed should be truncated (ex: in the window text, or if you hover over it). But, if you copy it to the clipboard using 'Copy Value', that should give you the full raw text. The fact that that is still truncated is definitely a bug.
  2. While you are waiting on the fix, you can work around this for now by evaluating something like 'myBigString.Split(<insert a reasonable split here, like maybe \n>)orSystem.Linq.Enumerable.Range(0, (myBigStringVariable.Length+99)/100).Select(x => myBigStringVariable.Substring(x100, Math.Min(100, myBigStringVariable.Length-x100))).ToArray()` so that each string stays under the limit.

@HughGrovesArup
Copy link
Author

Thanks for the response, good to know that this is not intended behaviour. We can stick with 2.4.2 for now as a workaround as well.

@tisaconundrum2
Copy link

tisaconundrum2 commented Oct 6, 2023

Glad to see other people are experiencing this issue as well! I thought I was going nuts

@tisaconundrum2
Copy link

tisaconundrum2 commented Oct 6, 2023

For those wondering how to use a specific version, go to dotnet/vscode-csharp/CONTRIBUTING.md for how to create a VSIX package to install into your VS Code. Release 2.3.27 does not seem to have this issue.

@dibarbet
Copy link
Member

For those wondering how to use a specific version, go to dotnet/vscode-csharp/CONTRIBUTING.md for how to create a VSIX package to install into your VS Code. Release 2.3.27 does not seem to have this issue.

Just wanted to make a note here - you don't even have to build the vsix yourself - you can right click the extension in vscode and hit 'install another version' which will bring up a UI to revert back to an older version we published to the marketplace
image

@gregg-miskelly
Copy link
Contributor

Fixed with #6517

@gregg-miskelly
Copy link
Contributor

Full description of the new expected behavior (which will ship in the next version of the extension): 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 '...'.

@namighajiyev
Copy link

Copy value copies truncated value with ellipsis at the end.

C# : v2.6.24
Vs code insiders: 1.84.0-insider

@gregg-miskelly
Copy link
Contributor

This shipped in v2.7.25, which is now live in the marketplace.

@monster-echo
Copy link

In the v2.12.19 on macos, it's still thuncated.

image

@gregg-miskelly
Copy link
Contributor

@monster-echo the current behavior is that you will get a string truncated at 1024 characters unless you use 'Copy Value'. But I think your complaint makes sense that we should also use a larger truncation limit when evaluating from the Debug Console. I opened #6719 to track that.

@monster-echo
Copy link

monster-echo commented Dec 6, 2023

image

I mistake the extension, this sence happened in the MAUI project .

This repository is still the vscode maui extension too? @gregg-miskelly

@gregg-miskelly
Copy link
Contributor

@nomo-app
Copy link

A similar bug also happens with Flutter/Dart-debugging (right-click -> copy value gives me an incomplete string).
My full string has a length of only 132 characters, but VSCode is unable to give me the full 132 characters.
Not sure where to open this issue.

@gregg-miskelly
Copy link
Contributor

@nomo-app You would want to open that bug in the repo of whatever extension's debugger you are using (not here :)).

@durandt
Copy link

durandt commented Jan 24, 2024

I also still get that issue with debug variables truncated after 100 characters (I use v2.15.30)

I also use C# DevKit and MAUI extensions

@gregg-miskelly how are we supposed to know what extension is responsible for which parts/behaviors of the UI?

@gregg-miskelly
Copy link
Contributor

@durandt This issue is specific to CLR/CoreCLR. MAUI uses Mono on iPhone, so this issue wouldn't address that scenario. Your new issue is the appropriate home for Mono issues.

@balazsmeszegeto
Copy link

I don't use MAUI, only vscode-csharp v2.15.30, but copying string values are still truncated

@gregg-miskelly
Copy link
Contributor

@balazsmeszegeto if you have a repo, please open a new issue including steps to reproduce the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants