-
-
Notifications
You must be signed in to change notification settings - Fork 418
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
C# debugger has a very low (1024 chars) JSON length limit #206
Comments
Maybe we can use the "Copy value" command somehow
That is fallback implementation vscode-debug-visualizer/extension/src/VisualizationBackend/GenericVisualizationSupport.ts Line 69 in f8c740a
Maybe we should add a csharp specific debug backend and use "watch" instead of repl vscode-debug-visualizer/extension/src/VisualizationBackend/PyVisualizationSupport.ts Line 56 in f8c740a
|
Thanks for the quick response!
I just meant that there are ways to send longer JSON strings to the visualizer, through a StringBuilder object for instance. If you don't manage to get the clean solutions working, this may be a reasonable alternative. It could be handled also as a fallback implementation, and would only require the user to convert the string I am not familiar with how the debugger and the extension work, so I have no idea if switching to "watch" would solve the issue. Also maybe you could add this choice in the parameters of the extension somewhere? |
I think there actually might be a setting for this extension to configure watch/reply. I don't have a csharp env at the moment, can you try? |
Sure, I can try in about 4 hours I think (time to go back home). What setting do I have to change? I think I found something from the readme:
Where I could change "lldb" to "coreclr","repl" to "watch" (and remove the expressionTemplate)? |
Exactly |
Unfortunately that didn't work, the string is still truncated (no change from before)... I'm sure the settings were well loaded because changing expressionTemplate worked. But I have no way of checking if the backend was set correctly. |
I found a solution! 🥳 Although it's a hack, I managed to bypass the string length limit of the C# debugger.
So if we create an empty object without any variables, and only a ToString method that returns the JSON string (stored as a static variable in another class) without the surrounding curly braces, the visualizer gets the correct string: class JsonString {
public JsonString(string json) { JsonStringContainer.json = json;}
public override string ToString() { return JsonStringContainer.json[1..^1]; }
}
class JsonStringContainer {
public static string json = "";
} And then instead of visualizing a string "debugVisualizer.debugAdapterConfigurations": {
"coreclr": {
"expressionTemplate": "new JsonString(${expr})",
}
} I am able to plot 100,000 points without an issue. For the record there seems to be a limit but much higher (I couldn't plot 1 million points), but it's more than enough like this. |
Up for a PR? :) The string based approach should still work for backwards compat reasons. Also, make sure that your suggestion does not have escaping issues. |
I'm not too sure about how this can be integrated. The JsonString class that is needed cannot be defined at debug time (it seems we can't define classes in the C# debugger). So the only way to have it is to have the user include the class in their code before compiling. I'll try to think of other ways but I'm out of ideas (I've tried anonymous classes, struct...). |
I am unsure how I can use this. Could you give me a bit more explanations? 😅 |
Just use
|
@ErwanFagnou Looks like I am facing similar issue of json string limitation with cpp debugger Shed some light here. |
Problem description
Hi! I wanted to use this extension with my C# project, and it worked really well.
However when I wanted to plot slightly more complex plots (like 1000 points), the visualization does not work.
I believe this is a MAJOR issue, considering in the most simple plot i cannot plot more than 218 points...
The reason is that the C# debugger truncates the strings in the debugger console to 1024 characters (in the error message above the string is cut at item 218 and ends with three dots. As explained here, the limit does not seem to be controllable (contrary to other languages with the same issues), however when right clicking the text we can copy the full (untruncated) text.
Possible solutions
I thought of a few ways of fixing this:
Environment details
The text was updated successfully, but these errors were encountered: