Home > database >  How to stop Visual Studio 2022 to add namespace automatically after copy codes from other place
How to stop Visual Studio 2022 to add namespace automatically after copy codes from other place

Time:12-23

As the title said, now I have a problem when copy codes from anywhere, and when pasting to my source files (C#/.cs), it will add a namespace automatically, sometimes the namespace is wrong but I don't know because it was added as unused namespace, but it will have a problem later when I build the project (with Unity) because it can't find the namespace, Then I have to delete it, it is very annoying.

CodePudding user response:

Try disabling the 'Enable namespace update when moving files' option.

In Visual Studio 2022 access the setting via the menu by following...

Tools > Options > Projects and Solutions > General

CodePudding user response:

I believe this is referring to the setting Tools -> Options -> Text Editor -> C# -> Advanced -> Add missing using directives on paste.

Showing the checkbox for Add missing using directives on paste

  • Related