Ensure that you've installed sharpen to an existing eclipse installation as explained here.
Use Ant scripts to run Sharpen
and translate your Java code to C#. The best way for this is to define an Ant macro which you then can reuse. This task takes two arguments. The first argument is the path to a valid Eclipse workspace which contains the project to translate. The second parameter is the project in the workspace which you want to translate.
<macrodef name="sharpen">
<attribute name="workspace"/>
<attribute name="resource"/>
<element name="args" optional="yes"/>
<sequential>
<java taskname="sharpen"
fork="true"
classname="org.eclipse.core.launcher.Main"
failonerror="true" timeout="1800000">
<classpath>
<fileset dir="${eclipse.home}/plugins">
<include name="org.eclipse.equinox.launcher_*.jar"/>
</fileset>
</classpath>
<arg value="-clean"/>
<arg value="-data"/>
<arg file="@{workspace}"/>
<arg value="-application"/>
<arg value="sharpen.core.application"/>
<arg value="@{resource}"/>
<args/>
</java>
</sequential>
</macrodef>
Now you can use this task to sharpen your project. First ensure that your project is in a valid Eclipse workspace. Then you specify the workspace and the sources of the project:
<target name="sharpen">
<sharpen
workspace="C:\temp\sharpenExamples\"
resource="example/src">
<args>
<arg value="@sharpen-config"/>
</args>
</sharpen>
</target>
Additionally you can pass the sharpen configuration as a file-name. When you add a '@' in front of the file-name sharpen will read that file and use all configuration flags of that. For example:
-pascalCase+ -nativeTypeSystem -nativeInterfaces
You can find a list of all Sharpen configuration flags here and a list of all Sharpen annotations here.
The example Ant scripts can be downloaded here.