How do I stop Visual Studio from adding random usings?

130 Views Asked by At

I think this is VS (not VS Code) trying to be helpful - it auto-adds a using whenever it thinks I need one.

However, in current C# most usings are not needed, I only expect to see one or two on most files.

Edit a file in Visual Studio for 20 mins and I suddenly have 15, and they'll all random. Not completely invalid, but often from the more obscure dependencies that aren't relevant to the class I'm working on (often referenced in the same solution but not a dependency of the project, even indirectly).

For instance, I'll type public Parser GetParser(... and (even though Parser.cs is a file next to this one and in the same namespace) VS will add using VendorLibrary.LegacyFormats.UsedInOneObscurePlace.Parsers;.

This is annoying, and either gets picked up in the PR review ("why do you have 15 usings here?") or a build exception (Parser is ambiguous between CurrentProjectNamespace.Parser and VendorLibrary.LegacyFormats.UsedInOneObscurePlace.Parsers.Parser).

This affects everyone on my team, not just me.

Anyone know what causes this and how I can stop it?

0

There are 0 best solutions below