devxlogo

MonoDevelop: Visual Studio Lite for the Linux Developer

MonoDevelop: Visual Studio Lite for the Linux Developer

onoDevelop is an open source integrated development environment for Linux platform users. This IDE is a replica of the original Microsoft .NET editor and also contains Windows support. The editor was primarily designed for C# and other .NET languages, but the latest version supports Java, Boo,Python,Vala, C, and C++ also. Its has the following features:

    * Advanced Text Editing: Code completion support for C# 3, code templates, code folding.
    * Configurable workbench: Fully customizable window layouts, user defined key bindings, external tools.
    * Multiple language support: C#, Visual Basic.Net, C/C++ etc.
    * Integrated Debugger: For debugging Mono and native applications.
    * GTK# Visual Designer: Easily build GTK# applications.
    * ASP.NET: Create web projects with full code completion support and test on XSP, the Mono web server.
    * Other tools: Source control, makefile integration, unit testing, packaging and deployment, localization.

Figure 1. Develop: This figure shows the Mono Develop Environment.

The MonoDevelop is the core runtime of MonoDevelop. Together with some basic services, it provides the Add-in engine, which is fundamental to the platform, since almost everything in MonoDevelop is an add-in. It not only provides an API for loading add-ins, but also command-line and graphical tools for managing those add-ins.

The Projects API is to develop applications that create, open, change, build and do whatever you need to do with MonoDevelop projects. The MonoDevelop IDE puts together all the previous services to offer a powerful and extensible IDE for managing development projects.

There are many kind of projects you can build upon the MonoDevelop platform. Here are some examples:

    * IDE extensions: You can implement add-ins which add new capabilities to the MonoDevelop IDE. Add-ins can create new pads, file viewers, add new menus and menu options, extend the project and class tree, etc.
    * Project extensions: You can provide new types of projects with custom file formats and build rules. Any application making use of the Projects API will be able to read and manage your projects.
    * Development tools: If you are building a development tool and don’t want to integrate it into the IDE, you can create your own GUI (or just console UI) and still take advantage of the Projects API and the add-in engine.
    * Other applications: If you just want to implement an application and take advantage of the MonoDevelop add-in engine, you just need to link to the MonoDevelop Core.
Figure 2. Build It: This graphic shows the MonoDevelop Architecture.

There are basically three layers:

    * The Core layer provides basic services for applications (not specific to development tools).
    * The Projects layer implements the project object model, which development tools can use to organize files.
    * The top layer is the IDE itself.

In the Core and Projects layers, GUI dependent functionality is implemented in separate assemblies.

MonoDevelop.Core

This assembly implements the core runtime of MonoDevelop, which include:

    * Add-in engine. It has two parts: the runtime engine (manages loading of add-ins and its extensions), and the add-in management API (manages installation of add-ins).
    * Process management: methods for creating and controlling processes, and for creating out-of-process objects.
    * Configuration properties: a service for storing configuration information.
    * Progress monitoring: A set of classes and interfaces that implement a pattern for monitoring the progress of operations.

MonoDevelop.Core.Gui

This assembly implements the following services:

    * Resources: It can be used to get fonts and stock icons.
    * MessageService: Common methods for displaying error dialogs, warning dialogs, informative dialogs and yes/no question dialogs.
    * DispatchService: Provides methods which simplify the thread management in MonoDevelop (see Thread Management).
    * Common dialogs to build wizards and options panels.
    * Some basic progress monitors.

The only extension point of this assembly can be used by add-ins to define new stock icons.

MonoDevelop.Projects

This assembly implements the project object model of MonoDevelop: the Project class, ProjectFile, Combine, CombineEntry etc. It provides the following functionalities:

    * Loading/Saving projects.
    * Building projects.
    * Executing projects.
    * Parse source code files and assemblies, and query class information.

It also provides several extension points:

    * Project Types: project types can define specific build rules or particular file organizations.
    * File Formats: a file format extension can implement a custom reader and writer for projects.
    * Language Bindings: can be used to add support for additional .NET languages.

MonoDevelop.Projects.Gui

This assembly provides:

    * Some dialogs for displaying project information, such as project or combine options.
    * The IconService, which can be used to get icons that represent projects, classes, methods, etc.
    * The code completion engine.

Add-ins can extend the project and combine options dialog by adding new custom options panels.

MonoDevelop.Ide

This assembly implements the MonoDevelop IDE, which is based on all services described so far. It provides a root object (IdeApp) which gives access to all IDE features:

    * The workbench: Documents, pads, layouts, status bar, progress monitors.
    * Project operations: this is a GUI front-end to everything you can do with a project: loading, saving, building, running, showing options, etc.
    * The Command Service: it can be used to define new commands, create menus, context menus and toolbars (see The Command System).

The IDE provides many extension points. Here are some of them:

    * Pads: dockable pads.
    * Views: file content viewers.
    * Commands: add-in can define new commands and integrate them in menus and toolbars.
    * Tree Node Builders: can be used to extend the solution pad, the class pad and any other TreeViewPad based pad. Node builders can create or hide nodes, add overlay icons, add menu options, etc.
    * Menus and Toolbars: add-ins can add new commands to existing menus and toolbars, or create new menus or toolbars.
    * Preferences panels: the preferences dialog can be extended with new options panels.
Figure 3. Properties: This graphic shows the Mono Solution Properties.

Sample Code on Locking and Threading

// class libraryclass Blah {    Hashtable ht;    void Foo (int zzz, Entry blah) {       lock (ht) {           ht.Add (zzz, blah);       }    }     void Bar ()    {       lock (ht) {          foreach (Entry e in ht)             EachBar (e);       }    }     virtual void EachBar (Entry e)    {    }} // Userclass MyBlah {    void DoStuff ()    {       lock (this) {          int i = GetNumber ();          Entry e = GetEntry ();                    Foo (i, e);       }    }     override void EachBar (Entry e)    {        lock (this) {           DoSomething (e);        }    }}

Sample Code Defining Class Structure

   class X : Y {	bool Method (int argument_1, int argument_2)	{		if (argument_1 == argument_2)			throw new Exception (Locale.GetText ("They are equal!"); 		if (argument_1 < argument_2) {			if (argument_1 * 3 > 4)				return true;			else				return false;		} 		//		// This sample helps keep your sanity while using 8-spaces for tabs		// 		VeryLongIdentifierWhichTakesManyArguments (			Argument1, Argument2, Argument3,			NestedCallHere (				MoreNested));	} 	bool MyProperty {		get {			return x;		} 		set {			x = value;		}	} 	void AnotherMethod () 	{		if ((a + 5) != 4) {		} 		while (blah) {			if (a)				continue;			b++;		}	}} 

Figure 4. Test: This figure shows a Unit Test Project Supported by Mono.

Sample Code on Conditional Compilation

            #if NET_2_0                CODE_FOR_2_0            #else                CODE_FOR_1_0            #endif 

Best Practices

Correctness is essential for the Mono class libraries. Because our code is called by many other people, we often must be more pendantic than most people would be when writing code. These items are guidelines of some things you should check for.

The class libraries are grouped together in the assemblies they belong. Each directory here represents an assembly, and inside each directory we divide the code based on the namespace they implement.

In addition, each assembly directory contains a Test directory that holds the NUnit tests for that assembly. We use a new build system which is described by various README files in mcs/build. The build process typically builds an assembly, but in some cases it also builds special versions of the assemblies intended to be used for testing.

MonoDevelop: Extended features

Autosave

MonoDevelop now keeps a copy on disk of all edits done in a file, even if the file has not been saved. In case of a crash, a file recovery dialog is shown which allows restoring unsaved changes.

Code Templates

The latest Mono develop Templates have placeholders. When the template is inserted, the cursor will be moved to the first placeholder and the user can move between placeholders by pressing TAB. Placeholders can be linked to other text in the template, which will be automatically updated. For example, a template for the 'for' statement can have a placeholder for the iteration variable, and when the name of the variable is entered all references to that variable in the template are automatically updated.

Block Selection

Block selection in the editor is now supported by pressing Alt while selecting text.

Big Performance Improvements

The editor is now much faster and will be more responsive when editing large files.

Code Formatting

A new C# formatter has been implemented. This formatter has plenty of formatting options which can be configured per-project. The new Format Document command (available in Edit -> Format -> Format Document) formats the current file following the options specified for the file file type and active project.

When the 'on the fly code formatting' option is enabled, MonoDevelop will automatically format blocks of code following the formatting options set in the project.

XML Documentation Shown in Code Completion

Documentation written in the code using the XML documentation format will now be shown in the Code Completion window.

Code Generator

The 'Show Code Generation Window' command (Alt + Insert by default) allows quickly generating snippets of code based on the current context. Here are some examples:

    * Generate a constructor, initializing a set of selected fields.
    * Generate properties for a set of fields.
    * Override base class members.
    * Implement ToString().
    * Implement equality methods.
    * Introduce a parameter null check in a method.
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist