How can I find out which directives are missing due to usage?

If a usage directive is missing, is it possible that visual studio is telling me which use-directives are missing?

And if so, can I configure Visual Studio to set auto- missing directives-pointers?

Visual studio only tells me in the error list that any directive being used is missing, but I want to know which one is missing?

+3


source to share


2 answers


Visual Studio can't know what's missing from using directives, one can only guess. The same type name can appear in multiple namespaces and assemblies.

When it makes a guess, it will look for the type (s) you are using and look for referenced assemblies for the type. (Tools like Resharper can guess better / more)

If the editor shows a blue rectangle under the type:

obligatory hand drawn arrow



place your cursor on the type name and press Shift+ Alt+ F10or Ctrl+ .(shortcut for View.ShowSmartTag) and a popup will let you choose from guesswork. You can of course right-click the type and use the Allow context menu, or try and click the blue rectangle (RSI risk).

If no assembly is listed, you need to set the link first. This means that you need to figure out which assembly contains the type you want to use. If it's a .NET Framework type, you can use MSDN; on the page containing the type, it will show you which assembly and which namespace is in that type.

For example:

IEnumerable Interface

.NET Framework 4.5

Returns a counter that supports simple iteration over a set of a specific type. To view .NET. Framework source code for this type, see the referenced source.

Namespace: System.Collections.Generic

Assembly: mscorlib (in mscorlib.dll)

+6


source


If the using directive is missing, is it possible that visual studio is telling me which service directives are missing?

Not




Can I configure my visual studio to automatically install missing using-directives?

Not




Visual studio only tells me in the error list that any using directive is skipped, but I want to know what is missing?

There are cases where the required assembly reference already exists within the project reference, but the using statement may not be present in the class. It's easy because you can identify the line where the build error appears and right-click on the class and go to resolution and select the appropriate use statement.

There are times when you may not have the required assembly reference added to the project (especially when you copy the code elsewhere). first of all you will need to figure out which .NET assembly reference should be added. looking for the .net class name in the corresponding MSDN page will contain the .NET assembly information where the class is located, add a specific assembly reference, then follow the first step above.

0


source







All Articles