Automatically import namespaces

Skip to end of metadata
Go to start of metadata

Whenever you use a type from a namespace that hasn’t been added with a using statement, ReSharper will offer you to add the corresponding statement on top of the file you’re in. This is indicated by a blue box shown above the type being used. To add the corresponding reference, simply press Alt+Enter.

The above assumes that the project you’re in actually references the corresponding DLL. In case it does not, ReSharper can still help you add both a DLL reference and a using statement provided the necessary DLL is referenced by some other project in your solution and the project you’re in references that project.

If that happens to be the case, you won’t get a blue pop-up. Instead, the type being used will be highlighted in red, and ReSharper will offer you a context action to add a reference to the corresponding assembly:

Selecting the top option will add a reference to System.Windows.Forms in your current project and will add a using System.Windows.Forms; statement at the top of the file.

  • No labels