5

This question comes up a lot, is there any way to get Microsoft's attention and convince them to stop inserting this extremely annoying feature?

If I have a C# file that doesn't currently use System.Collections.Generic, and I type a line like this:

List<string> moose = new();

VS then happily inserts

using iTextSharp.text;

which is of course completely wrong.

I swear it's like Clippy all over again but without checking before making any changes.

There is an option in the Tools menu that other questions say should control this feature, but apparently Microsoft left the option in but ignores the value (although to be fair I'm not pasting anything):

enter image description here

There is another question that does say "tab completion will still auto-add missing using directives" but in my case I'm not tab-completing. I'm just typing in the line of code.

Has anyone found a way to disable this "feature"?

Betty Crokker
  • 3,001
  • 6
  • 34
  • 68
  • 1
    Yeah it's been annoyingly off for a couple of months already. For me it's been auto-importing `DocumentFormat.OpenXml.Office2019.Drawing` namespace every time I type something like `Model` (`Model3D` lives in that namespace). – CodeCaster Mar 10 '23 at 15:56
  • 5
    _is there any way to get Microsoft's attention_: [Report a problem with the Visual Studio product or installer](https://learn.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2022), [Developer Community guidelines](https://learn.microsoft.com/en-us/visualstudio/ide/developer-community-guidelines?WT.mc_id=visualstudio_community_aka_vsfeedbackguidelines&view=vs-2022), and [Developer Community](https://developercommunity.visualstudio.com/home) – Tu deschizi eu inchid Mar 10 '23 at 15:59
  • The following may (or may not) be helpful: https://stackoverflow.com/a/70097398/10024425 – Tu deschizi eu inchid Mar 10 '23 at 16:01
  • 2
    @user09938 a yes the developer community, where 250 questions a day get posted and zero answered. Welcome to customer support in 2015+. – CodeCaster Mar 10 '23 at 16:55
  • 1
    @CodeCaster: What exactly do you mean by _answered_? I received a response to both of my questions: _Needs more information_ and/or _the issue is not reproducible and will be closed within 14 days_ -- even though I included the steps necessary to reproduce the issue, Obviously not a _solution_, but some may consider a _response_ to be an _answer_. Additionally, some may consider a lack of response an answer as well. I imagine that occassionally they select a question to try to find a solution to. Who knows, maybe one will win the _question lottery_ and someone will offer a solution. – Tu deschizi eu inchid Mar 11 '23 at 20:15
  • Hello, I am sorry that according to your instructions, I added List moose = new(); to the console project of Visual Studio 2022, and did not automatically insert using iTextSharp.text;. But try to use this workaround. https://stackoverflow.com/a/63021857 – wenbingeng-MSFT Mar 14 '23 at 07:03
  • @wenbingeng-MSFT - that'd be because a new console project in VS 2022 will be using global usings and `System.Collections.Generic` is in there so no `using` needs to be inserted at all. You'd see differently if you disabled global usings in the project. – Damien_The_Unbeliever Mar 15 '23 at 14:52

1 Answers1

3

I followed the "report a problem with VS" link and got a response within about a day! Their initial answer was that the "Show items from unimported namespaces" option does what I want. Unchecking that did indeed disable the insertion of the 'using' statement.

I did submit a follow-up bug asking that they fix the text of the option, as "show items from unimported namespaces" does not at all indicate "and add using statements".

enter image description here

Betty Crokker
  • 3,001
  • 6
  • 34
  • 68
  • You can see the entire bug report, and their fix that actually worked, here: https://github.com/dotnet/roslyn/issues/67372 – Betty Crokker Mar 23 '23 at 01:44