Reputation: 14375
Does the Visual Studio 2012 have a facility to locate needed modules based on a keyword? I find myself spending a fair amount of time hunting down the correct module to reference with the "using" statement for various keywords. For example, today I had to search the web to learn that I needed System.ComponentModel to use the DisplayName attribute (or any other attribute I'm guessing) with a class property. In Java/Eclipse the IDE has a hot key that will attempt to locate the module for a keyword it is flagging as unresolved in the current context. Is there a similar facility in Visual Studio 2012?
Upvotes: 0
Views: 236
Reputation: 301127
A tool like Resharper
(paid!) will make the job a lot easier. It has almost become the de-facto standard in C#/VB development with Visual Studio. Resharper can reference the assembly and add the using
statements too.
With that said, use Ctrl + . after enter the class name ( in this case DisplayName
) and it should suggest namespace. But for that, the assembly has to be referenced, and many a times, it might not be.
To reiterate, get Resharper, if possible.
Upvotes: 4
Reputation: 1500275
If you already have a reference to the appropriate assembly, Visual Studio will offer to help you if you have the cursor in the troublesome name. For example, if you try to apply the attribute:
[DisplayName]
... if you put your text caret in DisplayName
and press Ctrl-period, it should offer you the option of adding the appropriate using
directive. (Or click in the little bar at the bottom left of the name, which should appear.)
I don't believe Visual Studio offers you the option of adding an assembly reference in order to find a missing type though.
Upvotes: 2