Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2010: While debugging, how can I copy string values containing carriage returns out of variables?

When I am stepping through code in c# (not sure if it's an issue in VB.NET) and looking at SQL stored in a string variable, sometimes I like to copy it and paste it into Notepad or my SQL program. If it contains carriage returns, though, it actually copies to my clipboard as line1\r\nline2. Is there a native method of copying this with actual carriage returns rather than carriage return escape codes?

Edit: This also applies to tabs which show as \t. This is happening because my code is reading SQL from a text file and the text file contains carriage returns and tabs. The alternative is to 1) not have any carriage returns or tabs in the SQL (which makes for ugly SQL) or 2) strip them out when reading the SQL into my string variable. I am not really keen to those options just for the sake of simplifying the debugging process, though.

like image 701
oscilatingcretin Avatar asked May 25 '12 14:05

oscilatingcretin


People also ask

How do I change the value while debugging in Visual Studio?

In most languages supported by Visual Studio, you can edit your code in the middle of a debugging session and continue debugging. To use this feature, click into your code with your cursor while paused in the debugger, make edits, and press F5, F10, or F11 to continue debugging.

How do you copy debugging?

Right click on the player, then select Copy debug info from the menu. To share the debug information, paste it from your computer.

Is it possible to change the value of a variable while debugging?

Yes u can if you have the authorization: while debugging do a doubleclick on the variable, the system'll show the name and the value of the variable, change the value and press CHANGE icon.

How do I go back to previous line while debugging in Visual Studio?

So, if you've just taken a step in live debugging (F10 or F11), you can use the Step Backward button to quickly navigate to the previous step. This will automatically put Visual Studio in Historical debugging mode, at the line of code you've stepped back to.


2 Answers

It depends where you copy the value from.

If you hover your mouse over the variable when debugging, or look in the Locals window, you should see a little magnifying glass symbol in the tooltip.
Clicking this will open the Text Visualiser which should take account of any linebreaks.

For example, if my code is:

string test = "hello" + Environment.NewLine + "world";

Then I can look in Locals (notice it still shows \r\n there) or hover over test to see:

magnifying glass

This opens the Text Visualiser from where you can copy/paste:

enter image description here

like image 159
Widor Avatar answered Oct 23 '22 04:10

Widor


Put a breakpoint on the statment which has the variable (whole value you want to copy). As the control comes on the statement, move your mouse-pointer on the variable name. You will see a balloon box showing the variable name, a binocular icon and the value of the variable. Click on the binocular icon or the small down-arrow icon beside the binocular icon to view in it in text visualizer. Hope this is what you are looking at. This is in context with C# and hopefully its the same in VB.NET (but not sure).

like image 22
Shant Avatar answered Oct 23 '22 04:10

Shant