Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, September 11, 2017 10:15 PM
I recently checkout out a class module from TFS (using Visual Studio 2015), made some changes and then used the 'compare' item from the pop-up menu to see what changed since I checked the code out. To my surprise, I found that the capitalization of text contained within a literal (quoted) string had changed... and not by me. It seems something automatically changed "ON" to "On" and "TO" to "To" It even changed "on" to "On" in a few cases. Now mind you if these were comments or programming code that was not a literal text string this would not be a big deal But it is a big deal when you are doing a select case statement on the upper case of some value passed in. It is a big deal when the text "Last modified on" get changed to "Last modified On" and that appears in the user interface.
Could Visual Studio really have done this? I have no other explanation. If yes, how do i turn this off? It will introduce subtle bugs for sure.
Thank You! - Andy
All replies (11)
Monday, September 11, 2017 10:25 PM
Hello,
I'm confident it's not Visual Studio and hard to see that TFS is doing this. We have been on TFS for many years and never seen anything remotely like this. I have to ask, have you done any customization to TFS ?
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator
Monday, September 11, 2017 11:03 PM
Thank you for the reply. We don't have any customizations to TFS or Visual Studio. I didn't know such things were possible but then again I have not had a need for it.
It is definitely visual studio. I have just reproduced it.
Thank You! - Andy
Monday, September 11, 2017 11:14 PM
Just because this is producible in Visual Studio does not mean it's Visual Studio as TFS is a plugin to Visual Studio.
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator
Monday, September 11, 2017 11:21 PM
Here is how to reproduce it. Here is a select case statement:
' Sample select case statement to reproduce string literal reformatting in Visual Basic (Visual Studio 2015)
Select Case Strings.UCase(someStringVariable)
Case "ALL UPPER CASE 1", "ALL UPPER CASE 2", "ALL UPPER CASE 3"
Case "ALL UPPER CASE LITERAL WITH PROGRAMMING KEYWORDS LIKE TO AND NEW"
End Select
Now remove the double quote that appears at the start of "ALL UPPER CASE 2" and then click off (away) from the same line of code. Visual Studio will then re-parse/reformat all code that appears after, underlining the syntax problem and at the same time changing any programming keywords that happen to appear within any string literal appearing after the string literal that was changed/broken. In this example, a whole lot of words in the second "case" line get changed. The words CASE, WITH, LIKE, AND NEW get converted to Case, With, Like, To, And, New.
It gets worse... it will make this change throughout the rest of the module. The damage cannot be undone by just fixing the mistake that caused it. In my original case, I inserted another choice that I had copied/pasted from somewhere else but I had not copied the starting double quote. By the time I was notified of the error it was too late.
In prior versions of Visual Studio, the underscore character was used as a line continuation. Now that an explicit line continuation character is no longer available, the parser/compiler doesn't know where to stop. Maybe that has something to do with it.
Thank You! - Andy
Tuesday, September 12, 2017 5:40 AM
Hi Andy,
Welcome to the MSDN forum.
I tried to create a new VB console application, then copy your code into the Main() function and remove the double quote before “ALL UPPER CASE 2” and move the focus to other places, those code not be formatted as yours, please check the following result:
Does this issue happens to all your projects or just this specific project? Please try to create a new VB project to check if the issue occurs or not. If it works fine, which means this issue is more relates to the current project and you can try to restart VS, reopen/clean the solution, delete the hidden .vs folder to test it.
If all projects can reproduce this issue, please have a try with the following:
- Go to Tools>Import and Export Settings>Reset all settings, back up your current setting and choose ‘General’ to restore to the default setting, then create a new project to have a try.
- Open CMD as administrator and navigate to the VS 2015 installation folder like C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE and run the command: devenv /safemode to check if the installed extensions caused this issue.
Best regards,
Sara
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]
Tuesday, September 12, 2017 6:43 PM | 3 votes
It is the feature in Visual Studio that reformats your code to make it look consistent. In this case, you can find the setting under Tools->Options->Text Editor->Basic->Advanced->Pretty listing (reformatting) of code.
Thank You! - Andy
Wednesday, September 13, 2017 6:45 AM
Hi Andy,
Thank you for your update.
>>In this case, you can find the setting under Tools->Options->Text Editor->Basic->Advanced->Pretty listing (reformatting) of code.
In VS 2015, this option default checked and it also checked when I recorded the video that shared in my previous reply. I also tried to uncheck it and check this result again, it got the same result, those words CASE, WITH, LIKE, AND NEW not be formatted and changed.
Meanwhile, I also checked this in my another VS 2015 on the different computer, still cannot reproduce this issue, it seems this issue only occurs in your VS, have you tried the troubleshot methods that I mentioned before?
Best regards,
Sara
MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected]
Monday, March 19, 2018 1:21 PM
This occurs on all VS. For all project types.
Exactly as described, remove a quote from the start of a string and all the remaining text switches (string into code and code into string). Then VS capitalizes the words (is becomes Is, select becomes Select).
If I turn off "Pretty listing (reformatting) of code" then this problem goes away.
I'm confident that setting is what causes the issue (at least for me).
I am going to keep pretty listing off permanently until they fix this bug.
Thanks,
-Trevor
Monday, March 19, 2018 2:40 PM
Hi Andy,
This is an old thread but if you haven't closed we will keep trying to resolve your problem.
Please uncheck the checkbox highlighted in the screenshot below to disable that behavior:
Thanks,
If you like this or another reply, vote it up!
If you think this or another reply answers the original question, mark it or propose it as an answer.
Mauricio Feijo
www.mauriciofeijo.com
Monday, March 19, 2018 3:13 PM
This wasn't a problem in VS 2012. I think the reason why it is a problem with VS 2015 is because they removed the need to put an underscore at the end of a line to signify that the next line is a continuation of the current line.
Now, VS has to guess where the end of the line is and will reformat text until it reaches that point. If you have a start quote with no end quote, it will look for the end quote which could be a very long way away, reformatting everything along the way. Just a theory but it makes sense to me.
I am very disappointed at the response from Microsoft so far. I have gotten everything from "it cannot be a problem because I have never experienced it" to "I did a quick test and found nothing so create a stand alone something that does my work for me" (sarcasm added).
Thank You! - Andy
Monday, June 18, 2018 6:19 AM
I have faced exactly same problem when I committed changes and introduced regressions that happened to be linked to VS changes of VB quoted text. In my case, VC changed XML Tags and SQL statements. For example, VS replaced NOT or DATE by Not and Date in XML Tags and it broke my program (tags are case sensitive).
For me it is a really big deal because it means that you cannot trust the editor (which is supposed to be *THE* program that - as a developer - you have to trust).
I have switched off for now the Pretty Listing functionality. Will see if problems is still there. Looking at the replies, it does not look like this is taken seriously which is really shocking: VS is actually destroying your program while you edit it????