How can I prevent Visual Studio 2022 Intellisense Autocorrect from creating code that results in message IDE0049 "Name can be simplified"? - c#

If I type the following code into Visual Studio 2022 Professional Edition:
public string foo = string.Empty;
Visual Studio will automatically modify this to String.Empty and then issue this warning:
IDE0049 Name can be simplified.
Activating the "potential fixes" will suggest changing the code back to string.Empty - as I had originally entered.
Is there any way to prevent this without losing other significant functionality that Intellisense autocomplete provides?

Related

Can Visual Studio list current preprocessor defines in intellisense?

I'm working in C#, in Visual Studio Community Edition 2015. When I type # the intellisense list appears, with an option for #if. If I type #if then nothing shows up in an intellisense list until I hit CTRL+Space and even then, the only things in the list are true and false even though there are many symbols defined, and Visual Studio knows about them, as it properly grays out code that is preprocessed out.
How can I have Visual Studio list all currently available preprocessor defines in the intellisense list for autocompleting after #if?
In VS 2015 and 2017, when we define the complication symbols in file or properties page, the intellisense can only popups the true or false and it is by design, I found some other community members already reported this user voice to the VS product team, you can have a look at this user voice: https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/13348074-intellisense-for-c-conditional-compilation-symbol and vote it, then waiting for the response from the VS product team.

Visual Studio 2015 Update 3 not giving error without building

My visual studio 2015 lost its capabilities to detect errors on a class without building. Before I'm able to receive errors after pausing typing but now its not giving any.
Here in this image.
You can clearly see that i typed an invalid keyword on VS but after waiting for so long or even saving the file multiple times, it's not giving any error. Any way to fix this?

Disable syntax checking in Visual Studio 2015 (Community)

I'm currently using Visual Studio 2015 Community to do ASP.NET in C#.
While it might seem counterproductive, I disabled Intellisense to improve my memorization abilities for class names and members (Intellisense was too helpful and I could always type Ctrl-J if need be). I tried to do the same for C# so as to code with as few interruptions as possible in the long run, by learning from my inattention mistakes and focusing more on what I'm writing. But I can't find anything in the settings to do the job cleanly (i.e without changing the error underline color)
So is it possible to disable code syntax checking ?
Thanks in advance

Visual Studio 2015 - auto-collapse #regions and inactive code

In every version of Visual Studio up to 2013, code wrapped in #regions and inactive code in #if statements are automatically collapsed when you open a C# code file for the first time, when "enter outlining mode when files open" is enabled.
I'm trying to figure out how to enable this in Visual Studio 2015 RC, but even turning on "enter outlining mode when files open" doesn't seem to have any effect. If anything, it seems that the file opens, and then VS activates outlining mode a split second later, without checking to see if anything needs to be collapsed.
Well, it looks like the auto-collapse feature works again in VS2015 Update 1, so the answer now seems to be "install Update 1."
Visual Studio 2015 does not currently have this functionality built in.
You might want to check out the I Hate #Regions extension.
It can automatically expand regions when opening a file.
It looks like it's still a problem with VB, not C#:
"Incorrect VB code collapsing in VS2015 update 1 #9189"
https://github.com/dotnet/roslyn/issues/9189
It's still broken in Update 3, so hopefully they address it in Update 4.

Visual Studio - Value cannot be null. Parameter name: child

When I move a button from the Designer in Visual studio I get this error
it couldn't be annoying because if I run the solution I do not get any error at runtime, even if in my designer buttons becomes like this:
and if I try to move the exsisting groupbox (or I try to add a new one) it crashes (visual studio).
How can I debug Visual Studio to understand better my Designer problem? Because when it crashes, Visual Studio close and reopen by itself without asking anything.
Or even is a known bug and there is a simple solution? (but i didn't find anything similar on google)

Categories