For an explorative prototype project I wanted to use some existing Java code to build a SharePoint plugin. Therefore, the first thing that needs to be done is create some C# code for the backend. I found out about “Sharpen” an automatic conversion tool built and open sourced by versant I used the tutorial taken from versants community pages and followed these steps using eclipse and its subclipse svn client:

Checkout sharpen.core from db4o’s subversion repository at Right click the freshly checked out project in the “Package Explorer” and choose “Export” from the context menu; Expand the “Plug-in Development” folder and select “Deployable plug-ins and fragments”; Set “Destination” to the root folder of your eclipse installation and click “Finish”;

After completing these steps I created a simple java project called “ConverterTest”. Then I created my class “” in package “de”. I added some simple code like this: package de; public class SomeClass { public String dude; public SomeClass() { dude = “convert me!”; } public void print() { System.out.print(dude); } } Since I am only interested in converting source code and not so much in automated C# builds I modified the example xml ant files accordingly. So in my ConverterTest project i created my build.xml ant-file:

Then I created build-properties.xml like this:

Finally I downloaded the sharpen-common.xml and placed it in my project. Then I ran my build.xml file as an Ant Build using the context menu and the “Run As->Ant Build” command. Then I automagically got the following C# code in “build/” namespace de { public class SomeClass { public string dude; public SomeClass() { dude = “convert me!”; } public virtual void print() { System.Console.Out.Write(dude); } } } An here we go :-) Obviously the generated code violates some source code naming conventions but what is important is that it is runnable. The rest can easily be fixed using resharper or Visual Studios built in refactoring tools. Next I’ll try to convert some complicated code in Part 2.