-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
VB Editor changed VB keywords casing although they are used as literal strings in my code! #35028
Comments
Note: the only word that didnt change is douple, because it has a typo! I missed this in testing and would go unnoticed except for this faital editor error :) |
And this is a third place:
It was "get" but changedd to "Get"! |
A fourth one:
It was "object" but changed to "Object". I am still fixing the test errors! |
Same here
and here:
|
I fixed those, and updated the repo: The solution that cuased this is: it contains the ZML.cs in the Vazor app. This class contains those VB lower cass keywords. |
We do not change code inside strings. However, what may have happened to you is that you changed a quote somewhere in your file, causing your strings/non-strings to become inverted. You then performed an action that triggers cleanup (like saving the file) and the keywords in non-string areas got case corrected.
Without a clear set of repro steps, it's unlikely anything can be done here. As it stands, it's likely that you were editing and left the code in a state where VB itself thought your strings/non-strings were flipped. IN that case, this would be correcting the appropriate sections of your code. As such, this is all likely by design. If you can get repro steps that shows that actual strings were changes, feel free to reopen with that information. Thanks! |
@CyrusNajmabadi |
That's what undo is for.
The editor reparses what is necessary to construct a full parse tree from the code you have written.
If you feel the editor is slow, please file feedback in VS. You can use the information here on how to do is: https://github.com/dotnet/roslyn/wiki/Reporting-Visual-Studio-crashes-and-performance-issues It's pointless to speculate as slowness could be any number of issues.
Yes. This is how C# and VB and TypeSript and F# and all the other languages work. As you type, the file is continually rechecked to see if there are issues.
I don't see the relation between the issues.
You have to supply a realistic repro that allows people to determine what the root cause of hte issue is. Right now, it might just be user error on your part. Roslyn currently has tens of thousands of tests (if not more). Something may have slipped through, but asking people to "test it" isn't going to solve anything since it's absolutely not clear at all what went wrong or what is at fault. |
Let's focus on that. This should be done when the file opened and at build time. Suppose I opened a class file, and the editor checked it and it is OK. |
As i said: The editor reparses what is necessary |
Feel free to contribute any improvements you think will make things better.
Feel free to disable this feature (which VB has had since the beginning): |
I would better want the editor to stop formatting the file while it contains syntax errors. This will prevent this case changing issue prevent and adding then and other block endings in strange places. |
This is interesting. That would mean a single error in a file would block formatting unnecessarily for the entire file. I think we've gotten a little in the weeds here regarding implementation details. @VBAndCs it sounds like what you want is for the formatter to be resilient to error cases around incorrectly escaped strings. This way formatting works for the entire file but doesn't format the area around the string. I still don't know what the correct case for identifying this syntactically would be, but we can figure that out later :) |
@jmarolf |
Good point, more specifically we don't want to formatter to change capitalization around string literals. |
This would likely be very unpleasant. 99.9% of the time a file has syntax errors, and we depend on formatting so that you can do things like hit enter and have everything properly aligned and whatnot.
If you create a PR we can discuss and consider the implications of the change.
You can do this today: |
|
@VBAndCs please provide a repo of the issue you are running into. |
@CyrusNajmabadi |
I can think of one reason: |
Without a repro, there's no real way to make a code change here as tehre's no way to actually validate any change would solve this issue.
That sounds like a different bug. Feel free to either file it, or add whatever information is necessary to the bug you filed to help get it resolved.
@VBAndCs You have been told several times how you can report issues with performance to the Roslyn team. Please follow those instructions. Again, just repeating this info here doesn't do anything. Please actually provide the necessary information that has been asked for so that issues can be driven to resolution. It's quite possible you're running into perf bugs that no one else has seen. As such, the only way to fix them is to get you to actually submit real reports containing the necessary data. |
I have done that here: |
@VBAndCs That doesn't contain the information being asked for. That's an issue where you ran into an unrecoverable error. If you're reporting slowness (as per |
I faced a similar issue just now:
I added a new test method2 in the class, and ran the tests, but the test method 2 failed. When I checked it, I found that this part of the string literal has changed by adding a space before In another test method I hade this:
The editor erased the space before Model so it became '<Model.Count` I have 4 failed methods for the same reason: adding or deleting a space from a literal! |
@paul1956 |
@CyrusNajmabadi |
@VBAndCs I cannot repro this. what is your repro that shows that you can "mess up all next lines" by doing this? For all i know, this is due to some plugin or something else you're doing. |
So, how do you know it's roslyn that's doing this?
I have tried. I can't figure anything out that would cause this. Everything i try locally (including deleting random quotes, or adding random quotes, or change code and editing around things), doens't repro any problems.
Nothing changed here. VB added this back in VS2015.
What do you think can be done with the issue in this state? |
@CyrusNajmabadi |
I have tried this. I cannot repro what you are saying.
I have tried this. I cannot repro what you are seeing.
It definitely was. We've written tons of tests for both C# and VB using the VB editor. This includes lots of combnations of strings/xml-literals/etc. inside pieces of VB code. Many many thousands of tests have been written this way. |
I caught one:
|
This is not true. I was able to replace and then complete the ` thus ending the xml snippet.
If you don't actually end the snippet then of course VB will think the remainder is part of the XML. That's how xml works after all :)
I would recommend finishing your incomplete constructs. Note: if you don't want automatic pretty-listing of code, i already showed how you could disable that here: #35028 (comment) It seems you did not listen to that advice. If you have pretty listing enabled, then the LS will pretty list your code. If you don't want this happen automatically, then disable the feature. Then you can hit |
This is a bad design for xml literals. This issue can always happen when editing an xml literal such as pasting a part of a literal then starting to complete it, or mistakenly selecting the end tag with a previous part and deleting... etc. |
Why is it not a solution?
You can def contribute a fix here if you want :-) |
I think that's what it does. The problem is that you have contents in your xml that actually look like code. |
Design review conclusion:
|
@vatsalyaagrawal |
@VBAndCs Thanks for the clarification. Yes, the same conclusion would apply to XML literals. |
This issue state is |
Closing out as wr are not planning on investing in this area. |
Version Used:
VS.NET 2019 Community
I had this Function in VB
You can notice the statement:
Dim t = type.Trim().ToLower()
Then I check the values of t using
Select case
Obviously, I wouldn't change to small case the compare with strings containing upper case letters!
This code isn't what I wrote! The editor suddenly changed the case of all VB keywords although they are just quoted strings!
This happened also in another function where I used the string "declare" but suddenly found it became "Declare"!
Also I found a strange
Then
added after a string although there is noIf
nearby!The sudden failure of unit testes (that passed before) reveals all this!
I had to repair all these editor mistakes, but I am afraid to happen again!
I don't know what triggers this strange action. I had these codes running for days! This just happened in the past few minutes, and I have no reason to think about!
Note:
It seems related to XML literals. I explained how to reproduce this in #35028 (comment)
The text was updated successfully, but these errors were encountered: