Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VS 2022 automatically adds using to cs files in c# and I don't care. How is it prevented?

I mean that, suddenly, all the .cs include several using that I have not put. If I remove them VS puts them back. I do not want them.

What I have tried:

in internet and microsoft q&a not is posible validate login.
Posted
Updated 2-Nov-22 1:19am
v2

There appear to be two unrelated things here:
Quote:
VS 2022 automatically adds using to cs files in c# and I don't care. How is it prevented?
Which presumably means "I don't want all the standard using statements that VS provides when you use a new project or class template"

You can either remove them on a file-by-file basis or a whole solution: Quick Tip - Remove Unused Using References in Visual Studio[^]

Or, you can create your own templates (or alter the standard templates if you are brave enough): Create project templates - Visual Studio (Windows) | Microsoft Learn[^]

The second is
Quote:
in internet and microsoft q&a not is posible validate login.

Which is untrue. You may not be able to - but I'd suspect that is a problem at your end. My logins are validated to MS and loads of other sites every day!
We can't help you fix that.
 
Share this answer
 
v2
Comments
Member 14890678 2-Nov-22 2:59am    
I mean that, suddenly, all the .cs include several using that I have not put. If I remove them VS puts them back. I do not want them.
Visual Studio does this to help you by not needing to add them manually as you write your code. Once you hav added some code you will see that some of them are in light grey rather than black. These ones are not required for the current code you have written. You can then get VS to remove them automatically:
- Right click anywhere in the list of using statements.
- Select "Remove and Sort Usings", on the context menu.

But if you remove them all before you start coding you may find you need to add them back later. Best to wait until your code is mostly complete.
 
Share this answer
 
Comments
Member 14890678 2-Nov-22 7:11am    
But I don't want to go one by one removing what VS puts. I don't want it to put any "using".
Richard MacCutchan 2-Nov-22 7:17am    
Did you actually try what I suggested?
I found "Tools", "Text Editor", "C#", "Advanced", "Using Directives", "Suggest Usages for types in .Net Assemblies" and unchecked it. I hope this is it. Thank you all.
 
Share this answer
 
Comments
Richard MacCutchan 2-Nov-22 7:31am    
Well, I guess you did not test it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900