Stop visual studio debug putting slash in string containing double quotes - c#

I hit this odd behavour yesterday in Visual Studio 2015 where I was making a string that started and ended with double quotes. In stepping through the code I hovered over the result to see the contents and there were back slashes in the string - what! (see image below). Cutting a long story short, I figured out the debug view of the variable is displaying with the escaping backslashes - which in my opinion is misleading.
Does any one know if there is a way to disable this in Visual Studio so that it just displays the value as either ""bob*"" or without indication of the string type "bob*" ?
P.S. Yes I know, it seems a bit newbie to be using VS for years before noticing this behavour. Also the image is not showing our production code :)

This is expected. Because you are under debug mode you are given the dev version of the string.
To get a user friendly version of the string (actual value without slash) you just have to click on the magnify glass icon on the left

Related

Visual Studio possible bug for weird bracket behavior

I am writing some C# code with visual studio and I have a weird behavior with brackets. Let's see an example.
First I write this code:
Then when I add a single bracket with AltGr + Shift + [ I get this:
The entire class gets selected. How can I avoid this? The issue came out after the update to the latest version.
I am using the latest version of everything. I have VS 15.8.0, C# 7.3 and the .NET 4.7.2, any idea?
Please note that some times, after a { the entire class gets selected and I am not able to type the closed bracket }.
This happens when I write C++ as well. (like a new Console App). I have tested it right now in an empty project and the issue is here on C++ as well (VS 15.8.0, C++17). I have added a random c++ function to a library of mine and I have this behavior like in C#!
Possible solution
When I get the entire text selected, I press esc and the text gets deselected (plus the cursor is still at the right place). This is annoying AND this wasn't a problem 2 hours ago (when I had the old version).
I have an Italian keyboard and I can reproduce this behavior after the update. The fact is:
AltGr + Shift + { adds an open bracket as expected
AltGr + Shift + } selects the entire declaration of the class/struct in which you are creating the method
I wasn't able to find the keyword map that generates this behaviour (under Tools > Environment > Keyboard).
A solution may be the following: be sure that you have the automatic bracket completion enabled (which is already, by default) and type only the open bracket. In this way, when you type { you automatically get the closed bracket.
What if you need to type a } then? Well, you can use Alt + 125 and you'll get the close bracket (open bracket is Alt + 123.

Strange name and value appearing in Watch window

Does anyone have any idea what this means in the Watch window, how it was caused and how I could fix it?
I can't seem to find a specific line of code which is breaking it, it appears before the constructor of a class. I don't know what is causing it. I am programming in C# using Visual Studio 2015.
Has anyone else had an issue of this before?
A non-image version of the output is:
此᫈暔熚攺ᙋᲰ耀㼴͹픑㨊攼ᙉᵬ耀 error CS0726: '᫈暔熚攺ᙋᲰ耀㼴͹픑㨊攼ᙉᵬ耀' is not a valid format specifier
I'm not great at languages, but it appears to be a mixture of Chinese, Korean and various unicode characters. All of my code is written in English.
EDIT After further investigation, changing the text value or deleting it will make it not reaper when stepping through the code (Until it hits an exception in my code), or relaunching the debugger.
This is the Watch window - it contains a list of variables you specifically want to watch while debugging. It is not related in any way to a line of code. When you hit a break point, you can enter any value at all in the Name column - if it matches a variable that is currently in scope the value column will show its current value otherwise an error saying it is not in scope.
The names are saved somewhere so they persist when VS is restarted, so it is possible it is due to corruption of that file or if you cut & paste from somewhere using an unexpected character set.
The Name column must be a valid variable name (no spaces) or an expression (spaces allowed but it must be a valid expression) - anything after the valid portion of input may be considered as a format specifier (for example to limit number of array elements) - this error is related to that.
You can simply delete this entry & it will be gone permanently. There is no problem with your code.
Compiler Error CS0726
Visual Studio 2008 Other Versions
'format specifier' is not a valid format specifier
This error occurs in the debugger. When you type a variable name into one of the debugger windows, you can follow it with a comma, and then a format specifier. Examples are: myInt, h or myString,nq. This error arises when the compiler does not recognize the Format Specifiers in C#.
Check your VS language :
On the Tools menu, click Options.
In the Options dialog box, expand Environment and then click International Settings.
In the Language list, choose the language in which the UI text should appear in the development environment.

Why is this System.InvalidOperationException's target backwards?

I'm using DotNetBrowser and currently when I close my application I get the error System.InvalidOperationException in DotNetBrowser.dll (Channel is already closed).
When attempting to debug why this was occurring, I opened up the exception's details and found something strange. The StackTrace, TargetSite, DeclaringType, ReflectedType, etc., are all written backwards.
Is this because DotNetBrowser wrote their code backwards? Is this a bug with Visual Studio? What's going on?
Dot net adds RTL markers in the text.
copy the text in a text editor(notepad or so) hit CTRL + Home, type a ' single quote, CTRL + END type: '.split('').reverse().join("") (It will appear reversed but will still do it's stuff correctly)
Open a browser, hit f12, move to console and paste the the entire document and hit enter.
so in this case:
console.log('egassM.segassM.CPI.slanretnl.resworBteNtoD('.split('').reverse().join(""))
And then you have the readable message in your console.
This is the worst type of security.
You may notice that some entries are written backwards, some are messed up and some other entries are missing.
The release build of DotNetBrowser is obfuscated and protected, that's why the stack trace entries related to its internal logic are unreadable.

Visual studio "inconsistent line endings"

I'm new to VS, never really used it much. Prefer other IDE's but when it's a toss up between VS and MonoDevelop, I was told VS was the better choice.
I set it as my default editor in Unity and it's giving me this message every so often
The line endings in this file are not consistent. Do you want to normalize the endings?
Then it gives me a list such as
Windows (CR LF)
Macintosh (CR)
Unix (LF)
How can I stop this from coming up?
You can turn off that check in Tools/Options/Environment/Documents
Uncheck "Check for consistent line endings on load"
If you don't want to cover up by changing the document setting, you can try and remediate by replacing the faulty line endings. See post 'how to fix inconsistent line endings for whole vs solution.

Can't type certain square brackets in Visual Studio 2010 + Resharper

In certain cases typing an opening square bracket results in nothing at all. In particular when I want to type them on a variable in the right side of assignment expression:
arr[i] = arr
So I cant type, for example:
arr[i] = arr[9]
It has something to do with Resharper. However, turning of autocomplete and stuff doesn't seem to solve it. Anyone familiar with this problem?
I had the same issue the first time I insalled Resharper.
Look under Tools > Options > Environment > Keyboard to what is bound to Ctrl+Alt+^ (equals to AltGr+[ since I suppose you work on an AZERTY keyboard). Easiest way of doing is by just entering it as a new shortcut.
Remove or rebind the shortcut that comes up and you're good to go.
I had the almost same issue in Visual Studio Express 2012. I couldn't write theese -> } <-.
(Same problem as you, #hazard)
After reading #Bart's answer, I saw that Ctrl+Alt+0 was connected to something called "View.ViewCode". So I removed that shortcut and it worked.
What's weird though, is that I COULD write }s during the first few hours I used VS2012 after installing it.

Categories