Random namespaces

Every once and a while. Some random namespace that I don’t use pops up such as Unity.VisualScripting or System.Net.

Is there something I’m doing wrong or a setting i need to change?

Your IDE is “helpfully” automatically inserting using directives as you type and accept its autocomplete suggestions. You should slow down a little and make sure you’re accepting a suggestion from the namespace you actually want, or turn off that feature in your IDE.

1 Like

So for Visual Studio, it’s simply typos that add namespaces when pressing tab?

I mean it’s not typoing it. When you press tab it will show you what it’s about to add. If you accept its suggestion, it will add what it showed you. Sometimes that just happens very fast.

1 Like

Actually it might be something else.
If you copy (?) some code in VS and paste in the other file, then it will try to add namespaces automaticaly, however sometimes it might add wrong namespaces, because it processed it wrong. I don’t remember if it’s just a bug or just broken feature, but this one can be turned off somewhere.

do methods count?

 if (MathDefault.Odds(60))
    {
          item.SetResources(WorldItem.StartingResources.half);
    }
  else
    {
          item.SetResources(WorldItem.StartingResources.minimal);
    }

This is a new feature that got added in a recent Visual Studio 2022 update. It’ll include intellesense suggestions outside of currently implemented namespaces, but for those suggestions you’ll see the namespace appended to the suggestion.

You can turn the feature off (don’t know how off the top of my head), but I don’t mind as it speeds up the process for me. Just need to pay a little more attention to what you’re hitting Tab on.

It’s “show items from unimported namespaces” in Tools → Options → Text Editor → C# → IntelliSense.

Screenshot

8893446--1216230--upload_2023-3-21_21-55-41.png

A certain chatbot told me that’s where it was despite pretending that it’s cutoff is September 2021.