Tuesday, October 19, 2010

SharpDevelop

Recently , I started working with the SharpDevelop , open source IDE for the .Net platform . It is same as NetBeans and Visual Studio IDE and provides almost same features . Previously I have worked on VSTA as tool for developing addin's for a application. VSTA is the subset of Visual studio and provided many ways to extend the IDE . I have done many customization in the IDE with VSTA programming interface. In VSTA using ENVDTE namespace we get hold of the extensibility framework for IDE and its funtionalities. We can provide our own custom menu, menuitems, toolbar,toolbar items , we can extend the contextmenus of IDE , get hold of many IDE command like build ,rebuild, edit many properties of the IDE like platform target, reference path, active configuration etc. Apart form all these we can define our own project templates, wizards (IDEWizards) etc and can add projects and project items at runtime. We can use CodeDom to generate code , create assemblies and build them.

Can I achieve same thing using ShareDevelop ? To find out that, I got source code of ShareDevelop and started digging it. Sharpdevelop is based on addin model . It consist of a small core and all its functionalities are held by addins . Core contains the code to extend the SharpDevelop via all the other addin's. SharpDevelop Addin's are simple xml files and the binaries associated with them (.dll etc). For example Addin name myaddin will have a single xml file with extension .addin :- myaddin.addin and one or more binaries having the implementation of addin (myaddin.dll ). Xml file contain some nodes specific to the addin general information .Main thing to notice in addin xml are the extension nodes .Extension nodes starts with the name path which has the attribute named "name" that defines the path where this extension will be added up on the SharpDevelop core.

<path name="/SharpDevelop/Workspace/MainMenu">;

SharpDevelop contains this concept of paths . SharDevelop core and the addin responsible for the base functionality of the SharpDelvelop (ICSharpCode.SharpDevelop.addin) defines some paths upon which the functionalities can be extended. Paths represent the way via which we can find a node in a tree where "/" defines the root node. In fact the SharpDevelop maintains the tree structure for all the addin's that extend it . So we can extend the base with a addin and that addin will become the tree node for addin tree.If that addin defines a extension point then further a next addin can extend this addin. This features of extending a existing addin is not there in VSTA framework. SharpDevelop core contains many services for basic functionalities like property, resource, gui etc handling. Another concept other than paths are codons. In addin xml file we can find the codons as :--


<Path name = "/SharpDevelop/Workspace/MainMenu">
<MenuItem id = "File" label = "&File">
<MenuItem id = "Separator1" label = "-"/>
<MenuItem id = "Exit"
label = "E&xit"
class = "NCvs.Gui.Commands.ExitCommand"/>
</MenuItem>
</Path>



-

We can see all the elements inside the path node . As i have said, path node defines the extension point in SharpDevelop and it also defines the node that will be added to MainMenu of SharpDevelop . What about the elements inside path node, they all are codons. Codons are the element that specify the behaviour of the elements inside the program. So path tells us the extension point and the menuitem "File" is added under this path node. Menuitem "File" also contains the element Menuitem "Seperator1 " and "Exit". These codons will arranged under the "File" codon which is under the MainMenu path. No we have a treenode under the path Mainmenu. What we get from example is that SharDevelop contains a AddIn Tree that contains the AddIn Tree Nodes , AddIn tree nodes conatin the AddIns and in turn Addins contain the Codons. Addin Tree contains various service to load the addins and build the tree. AddinTreeNode conatins the method BuildChildItems that returns the list of all the built codons from a addin. Addin class contains all the information about the codons inside it and all the info of assemblies needed to create the runtime object of the codon. It gets all this info from the xml file . Codon class contains a methos Buiditem that creates the runtime instance of the codon. So the built codon is the in memory representation of the codon item in addin xml file. Shardevelop core contains many builder and factory classes to load the assemblies containg the codon definitions and build the in memory tree for the Addin from addin xml file and entire AddIn tree.

But can I do all the stuff that I did with VSTA , described above at starting ? I think with the help of Base Addin i can start experimenting . In next post I will start with creating our own project template in SharpDevelop. Hope ,somebody will find it useful.

http://www.codeproject.com/KB/cs/ICSharpCodeCore.aspx
http://www.icsharpcode.net/opensource/sd/
http://sharpdevelop.codeplex.com/

No comments:

Post a Comment