views:

115

answers:

3

When developing for Java in Eclipse, I can hit Ctrl+Shift+O to "Organize Imports", to have the IDE figure out which libraries I'm likely trying to use, and import them automatically.

Is there is a similar feature in MonoDevelop for programming C#?

EDIT:

I'm very to new C# and the whole Microsoft space. If there is no way to do this, how would one normally determine which library contained the class they were trying to use?

+1  A: 

I don't know a lot about MonoDevelop; Visual Studio 2008 has an "Organize Usings" menu that drops unnecessary usings. I think the ability to reference missing namespaces automatically is a feature only in the third-party Resharper addin.

Re your second question: the MSDN page for a class tells you the assembly and namespace you need in order to use that class. I normally do a Google search for "site:msdn.microsoft.com NameOfClass".

Tim Robinson
Use Google-Fu, or rely on Resharper in Visual Studio to add the `using` clauses automatically. I usually use Google, even though I have Resharper installed.
skolima
Just use the class you want, like Path. If you do not have the correct "using" clause, you can expand the smart tip over your class and it will add it automagically. (Or the keyboard shortcut is Ctrl-Period.)
jpobst
+2  A: 

I do not think MD currently has the first feature.

Although recent version has the possibility to add "using namespace" for classes you are using.

For example, type: List<int> =

Right click on List and you will have Resolve menu that will add proper using statement to the top of the file. Although it will search only referenced libraries, and will not add anything to references.

There is a refactor menu on usings, too, that can remove uneeded usings from file.

(I'm not sure if this features are avaialble in MD 2.0 or 2.2 or only trunk, as I'm using the trunk version)

silk
+1  A: 

A similar feature was added in MonoDevelop 2.2 (the latest version).

You can use it by right-clicking on an unrecognized type, and hovering over "Resolve":

alt text

If the type is recognized (i.e., if you were already using Gdk; in the above example), you will not see this menu.

If you're using Ubuntu Karmic, the version of MonoDevelop in the repositories is 2.0. You'll need to add this PPA to upgrade. If you're using Windows or OS X, you can download MonoDevelop 2.2 from the MonoDevelop website.

Matthew